2.0 beta init
[framework/multimedia/gstreamer0.10.git] / docs / design / part-preroll.txt
1 Preroll
2 -------
3
4 A sink element can only complete the state change to PAUSED after a buffer
5 has been queued on the input pad or pads. This process is called prerolling
6 and is needed to fill the pipeline with buffers so that the transition to
7 PLAYING goes as fast as possible with no visual delay for the user.
8
9 Preroll is also crucial in maintaining correct audio and video synchronisation
10 and ensuring that no buffers are dropped in the sinks.
11
12 After receiving a buffer (or EOS) on a pad the chain/event function should
13 wait to render the buffers or in the EOS case, wait to post the EOS
14 message. While waiting, the sink will wait for the preroll cond to be signalled.
15
16 Several things can happen that require the preroll cond to be signalled. This
17 include state changes or flush events. The prerolling is implemented in
18 sinks (see part-element-sink.txt)
19
20
21 Committing the state
22 ~~~~~~~~~~~~~~~~~~~~
23
24 When going to PAUSED and PLAYING a buffer should be queued in the pad. We also
25 make this requirement for going to PLAYING since a flush event in the PAUSED
26 state could unqueue the buffer again.
27
28 The state is commited in the following conditions:
29
30  - a buffer is received on a sinkpad
31  - an EOS is received on a sinkpad.
32
33 We require the state change to be commited in EOS as well since an EOS means
34 by definition that no buffer is going to arrive anymore.
35
36 After the state is commited, a blocking wait should be performed for the 
37 next event. Some sinks might render the preroll buffer before starting this
38 blocking wait.
39
40
41 Unlocking the preroll
42 ~~~~~~~~~~~~~~~~~~~~~
43
44 The following conditions unlock the preroll:
45
46  - a state change
47  - a flush event
48
49 When the preroll is unlocked by a flush event, a return value of
50 GST_FLOW_WRONG_STATE is to be returned to the peer pad.
51
52 When preroll is unlocked by a state change to PLAYING, playback and
53 rendering of the buffers shall start.
54
55 When preroll is unlocked by a state change to READY, the buffer is
56 to be discarded and a GST_FLOW_WRONG_STATE shall be returned to the
57 peer element.
58