[gst-devel] gstreamer thread problem?

Tim Müller t.i.m at zen.co.uk
Wed Jun 14 11:58:01 CEST 2006


On Wed, 2006-06-14 at 09:32 +0000, woo john wrote:

>   My question is :
> 
> 1 whether a source element can work at pull mode or push mode ?

That depends on the element (some only support one type, some support
both types, and some support pull-mode only under certain circumstances,
like with certain URIs).


>   2 if it is at pull mode, is there a thread assigned for it?
>     if it is at push mode, is there a thread assigned for it?

Yes, there is always at least one streaming thread, the difference is
just which element is driving the pipeline. Example:

   cdiocddasrc ! audioconvert ! audioresample ! autoaudiosink

cdiocddasrc only works push-based. The source will create a thread and
push out data as fast as it can, the audio sink will then block
according to the timestamps etc.


   cdiocddasrc ! audioconvert ! audioresample ! queue ! autoaudiosink

The source will create a thread and push out data as fast as it can. The
queue will block when it hits one of the configured max limits. The
queue will start a thread of its own when its source pad is linked and
push out data towards the sink. So here you have two streaming threads
altogether.


   filesrc ! wavparse ! ... ! autoaudiosink

filesrc can operate both pull and push-based. Wavparse will check if
upstream supports pull mode and use that if possible. So in this case
wavparse creates a thread and reads data from filesrc via
gst_pad_pull_range() as fast as it can and pushes buffers out as fast as
it can (and the sink will block to sync against the clock according to
the timestamps on the buffers).



>   3 As i know,I can insert a queue between a source element and the 
> downstream elements. In this case,what mode does the source element work? 
> pull or push?

If you insert a queue, you force the right/downstream side of the queue
to be push-based. What happens to the left/upstream side of the queue
depends on the elements, if there is only a source upstream then the
source will operate in push-mode, e.g.:

   filesrc ! queue ! wavparse ! ... ! autoaudiosink

will force wavparse to work in streaming mode rather than pull-based
like in the example above.

Hope this helps.

Cheers
 -Tim






More information about the gstreamer-devel mailing list