4 Sink elements consume data. They normally have no source pads.
6 Typical sink elements include:
8 - audio/video renderers
12 Sinks are harder to construct than other element types as they are
13 treated specially by the GStreamer core.
18 A sink always returns ASYNC from the state change to PAUSED, this
19 includes a state change from READY->PAUSED and PLAYING->PAUSED. The
20 reason for this is that this way we can detect when the first buffer
21 or event arrives in the sink when the state change completes.
23 A sink should block on the first EOS event or buffer received in the
24 READY->PAUSED state before commiting the state to PAUSED.
26 FLUSHING events have to be handled out of sync with the buffer flow
27 and take no part in the preroll procedure.
29 Events other than EOS do not complete the preroll stage.
34 - TODO: PREROLL_LOCK can be removed and we can safely use the STREAM_LOCK.
38 # commit the state. We return TRUE if we can continue
39 # streaming, FALSE in the case we go to a READY or NULL state.
40 # if we go to PLAYING, we don't need to block on preroll.
64 # sync an object. We have to wait for the element to reach
65 # the PLAYING state before we can wait on the clock.
66 # some items do not need synchronisation (most events) so the
67 # get_times method returns FALSE (not syncable)
68 # need_preroll indicates that we are not in the PLAYING state
69 # and therefore need to commit and potentially block on preroll
70 # if our clock_wait got interrupted we commit and block again.
71 # The reason for this is that the current item being rendered is
72 # not yet finished and we can use that item to finish preroll.
75 # get timing information for this object
76 syncable = get_times (obj, &start, &stop)
87 # release PREROLL_LOCK and wait. prerolled can be observed
90 PREROLL_WAIT (releasing PREROLL_LOCK)
95 if (valid (start || stop))
98 ret = wait_clock (obj,start)
102 # if the clock was unscheduled, we redo the
104 if (ret == UNSCHEDULED)
108 # render a prerollable item (EOS or buffer). It is
109 # always called with the PREROLL_LOCK helt.
116 # preroll and syncing done, now we can render
119 | # sinks that sync on buffer contents do like this
120 | while (more_to_render)
122 | if (ret == interrupted)
124 render (buffer) ----->| PREROLL_WAIT (releasing PREROLL_LOCK)
130 # queue a prerollable item (EOS or buffer). It is
131 # always called with the PREROLL_LOCK helt.
132 # This function will commit the state when receiving the
133 # first prerollable item.
134 # items are then added to the rendering queue or rendered
135 # right away if no preroll is needed.
136 queue (obj, prerollable)
142 # first item in the queue while we need preroll
143 # will complete state change and call preroll
151 # then see if we need more preroll items before we
154 if (queuelen <= maxqueue)
158 # now clear the queue and render each item before
159 # rendering the current item.
160 while (queue.hasItem)
161 render_object (queue.remove())
167 # various event functions
170 # events must complete preroll too
175 ret = queue (event, TRUE)
182 # the newsegment must be used to clip incoming
183 # buffers. Then then go into the queue as non-prerollable
184 # items used for syncing the buffers
190 ret = queue (event, FALSE)
197 # set flushing and unblock all that is waiting
198 event ----> subclasses can interrupt render
209 # unset flushing and clear all data and eos
221 # the chain function checks the buffer falls within the
222 # configured segment and queues the buffer for preroll and
237 # no datapassing is going on so we always return ASYNC
246 # we grab the preroll lock. This we can only do if the
247 # chain function is either doing some clock sync, we are
248 # waiting for preroll or the chain function is not being called.
250 if (prerolled || eos)
265 ---> subclass can interrupt render
266 # we grab the preroll lock. This we can only do if the
267 # chain function is either doing some clock sync
268 # or the chain function is not being called.
272 if (prerolled || eos)
279 ---> subclass can interrupt render
280 # we grab the preroll lock. Set to flushing and unlock
281 # everything. This should exit the chain functions and stop