[gst-devel] GStreamer in double loop

Arnout Vandecappelle arnout at mind.be
Sat Jun 20 11:55:11 CEST 2009


 [This is actually not about GStreamer anymore, but what the heck.]

On Friday 19 June 2009 00:48:39 Jeffrey Barish wrote:
> Here's what's baffling me.  This works:
>
>         loop = gobject.MainLoop()
>         context = loop.get_context()
>         while True:
>             context.iteration(False)
>             time.sleep(1.0)
>
> This doesn't:
>
>         loop = gobject.MainLoop()
>         context = loop.get_context()
>         while True:
>             context.iteration(True)

 Since you haven't registered any sources for the main loop, it will block 
forever.  And unless you created another thread or signal handler somewhere 
that calls loop.quit(), there is no way to get out of it.

> The difference is that the second one blocks on the iteration.  What is it
> about blocking that is incompatible with running this code in its own
> thread?

 AFAIK mainloops aren't really meant to be controlled from multiple threads.  
Inside the context.iteration(True), the mainloop will block waiting for an 
event on any of its registered sources.  Once it's blocking, I don't think 
adding a source from another thread interrupts the block.  You'd probably 
need to do a loop.quit() and re-run the mainloop.

 Regards,
 Arnout


-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  D206 D44B 5155 DF98 550D  3F2A 2213 88AA A1C7 C933




More information about the gstreamer-devel mailing list