gst_bus_add_watch without using g_main_loop_new and run
Tim-Philipp Müller
t.i.m at zen.co.uk
Wed Nov 21 00:13:56 PST 2012
On Tue, 2012-11-20 at 21:48 -0800, deepthips wrote:
Hi,
> Is there any way to use gst_bus_add_watch without using main_loop call.? I
> saw a code snippet where bus_watch is done without creating a mail loop and
> unfortunately its not working for me. So I guess they used some other
> mechanism for the same purpose. I tried the gst_bus_set_sync_handler and it
> will work, but I want it was separate thread handling messages. Any help is
> appreciated.
The 'watch' API is made especially with a GLib/Gtk main loop in mind. If
you don't run a main loop, you can use
gst_bus_have_pending()
gst_bus_pop()
gst_bus_timed_pop()
gst_bus_timed_pop_filtered()
whenever your application thread has some spare cycles to do so. If you
have a different kind of main loop or messaging system, you could
install a sync handler (called streaming threads), and signal your
application thread to check the bus for messages.
Alternatively, you could just start a thread of your own and do
gst_bus_timed_pop() in a loop with a -1 timeout. You can then send that
thread a custom application message to make it shutdown when needed.
(This solution means you might still need to be careful about
interacting with any other application threads though..)
Cheers
-Tim
More information about the gstreamer-devel
mailing list