Class: Gst::Bus

Inherits:
Object
  • Object
show all
Defined in:
lib/gst/bus.rb

Instance Method Summary collapse

Instance Method Details

#add_watch(priority = GLib::PRIORITY_DEFAULT, &block) ⇒ Object



20
21
22
# File 'lib/gst/bus.rb', line 20

def add_watch(priority=GLib::PRIORITY_DEFAULT, &block)
  add_watch_full(priority, &block)
end

#add_watch_fullObject



19
# File 'lib/gst/bus.rb', line 19

alias_method :add_watch_full, :add_watch

#poll(*args) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/gst/bus.rb', line 41

def poll(*args)
  events = nil
  timeout = nil

  n_args = args.size
  case n_args
  when 0
  when 1
    case args[0]
    when Hash
      options = args[0]
      events = options[:events]
      timeout = options[:timeout]
    when Integer
      timeout = args[0]
    else
      events = args[0]
    end
  when 2
    events, timeout = args
  else
    message = "wrong number of arguments "
    message << "(given #{n_args}, expected 0..2)"
    raise ArgumentError, message
  end
  poll_raw(events || :any,
           timeout || CLOCK_TIME_NONE)
end

#poll_rawObject



40
# File 'lib/gst/bus.rb', line 40

alias_method :poll_raw, :poll

#sync_handler(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gst/bus.rb', line 24

def sync_handler(&block)
  @sync_handler = lambda do |bus, message|
    begin
      block.call(bus, message)
    rescue Exception
      $stderr.puts("An exception is raised in " +
                     "#{self.class}\##{__method__} callback: #{block}")
      $stderr.puts("#{$!.class}: #{$!.message}")
      $stderr.puts($@)
      BusSyncReply::DROP
    end
  end
  set_sync_handler(&@sync_handler)
end