Control of pipeline and g_main_loop in a daughter thread
Tim-Philipp Müller
t.i.m at zen.co.uk
Wed Apr 3 07:37:47 PDT 2013
On Wed, 2013-04-03 at 07:22 -0700, Wes Miller wrote:
Hi,
> Curious. Every example I have ever seen has the pipeline set to PLAYING
> followed by a main loop run(). I always thought it took the mainloop for
> the pipeline to run but now I'm guessing it's really just something for the
> program to do till the pipeline ends. (True?)
>
> Would a LONG sleep work just as well? or would the sleep stall the
> pipeline?
You can do a sleep, or anything else you want - as long as you don't
exit the process obviously. GStreamer will start its own streaming
threads and do its stuff there. If you just sleep you obviously won't
get any notifications about errors, tags, EOS, etc.
But you could just do a
do {
GstMessage *msg = gst_bus_timed_pop (bus, -1);
switch (msg) {
...
}
gst_message_unref(msg);
} while (!quit) {
- no main loop involved.
> Would a program loop work? Say:
>
> stateChgRc = gst_element_set_state( myPipeline, GST_STATE_PLAYING );
> while (true)
> {
> std::cin x;
> if ( EXITCODE == do_something_with( x ) ) break;
> }
>
> or would that also stall the pipeline?
That would be fine and would not stall the pipeline.
(The idea is that when you have a GUI, then GStreamer's data processing
should not interfere with your user interface being drawn - you don't
want your UI to freeze just because GStreamer takes a while to do
something somewhere).
Cheers
-Tim
More information about the gstreamer-devel
mailing list