abe7afda411ed441e864f40b2d77f768824c1741
[platform/upstream/gstreamer.git] / docs / random / wtay / eos3
1
2 case 1) 
3
4 (--------------------------------------------------)
5 ! bin                                              !
6 ! (--------)         (--------)         (--------) !
7 ! ! fakesrc!         !identity!         !fakesink! !
8 ! !       src ----- sink     src ---- sink       ! !
9 ! (--------)         (--------)         (--------) !
10 (--------------------------------------------------)
11
12 .scheduling.
13   
14   case1 has just one scheduled entity (chain) no problem here.
15
16 .eos.
17
18   fakesrc detects the end of stream. It just returned the last buffer.
19   The next _pull will cause the srcpad to trigger gst_pad_set_eos ().
20   After that it will return a NULL buffer.
21
22   gst_pad_set_eos() will notify the parent about the plugins attempt to
23   signal eos. the parent disables scheduling for the chain containing
24   fakesrc.
25   
26   no more chains are being scheduled so the bin fires EOS.
27
28
29 case 2) 
30
31
32 (-----------------------------------------------------------------------)
33 ! bin                                                                   !
34 !                                                     (---------------) !
35 !                                                     !thread         ! !
36 ! (--------)         (--------)         (--------)    !     (--------)! !
37 ! ! fakesrc!         !identity!         !  queue !    !     !fakesink!! !
38 ! !       src ----- sink     src ---- sink       src ---- sink       !! !
39 ! (--------)         (--------)         (--------)    !     (--------)! !
40 !                                                     (---------------) !
41 (-----------------------------------------------------------------------)
42
43 .scheduling.
44
45   case2 has two scheduled entities: fsr-i-q, q-fsk.
46   The first one is scheduled by the bin, the second one by the thread.
47   
48 .eos.
49
50   fakesrc detects the end of stream. It just returned the last buffer.
51   The next _pull will cause the srcpad to trigger gst_pad_set_eos ().
52   After that it will return a NULL buffer.
53
54   gst_pad_set_eos() will notify the parent about the plugins attempt to
55   signal eos. the parent will take chain1 out if its scheduled chains.
56
57   the bin does not fire EOS yet because the thread has not yet signaled 
58   EOS.
59
60   after the queue has sent out the last buffer, its calls eos on its
61   src pad. the chain with the queue is removed from the threads scheduled
62   chains. there are no more chains to schedule, the thread fires EOS.
63
64   The bin now has no more scheduled chains and no more pending subbins,
65   it fires EOS.
66
67
68 case 3) 
69
70 (-----------------------------------------------------------------------)
71 ! bin                                                                   !
72 !                                                     (---------------) !
73 !                                                     !thread         ! !
74 ! (--------)         (--------)         (--------)    !     (--------)! !
75 ! ! fakesrc!         !  tee   !         ! queue1 !    !     !fakesink!! !
76 ! !       src ----- sink     src ---- sink       src ---- sink       !! !
77 ! (--------)         !        !         (--------)    !     (--------)! !
78 !                    !        !                       (---------------) !
79 !                    !        !                                         !
80 !                    !        !                       (---------------) !
81 !                    !        !                       !thread         ! !
82 !                    !        !         (--------)    !     (--------)! !
83 !                    !        !         ! queue2 !    !     !fakesink!! !
84 !                    !       src ---- sink       src ---- sink       !! !
85 !                    !        !         (--------)    !     (--------)! !
86 !                    (--------)                       (---------------) !
87 (-----------------------------------------------------------------------)
88
89 .scheduling.
90
91   case3 has tree scheduled entities: fsr-t(-q1,-q2), q1-fsk. q2-fsk
92   the first one is managed by the bin, the second two are managed by the
93   threads.
94   
95 .eos.
96
97   fakesrc detects the end of stream. It just returned the last buffer.
98   The next _pull will cause the srcpad to trigger gst_pad_set_eos ().
99   After that it will return a NULL buffer.
100
101   chain1 is taken out of the scheduling algorithm of the bin.
102
103   after a while, the threads finish their scheduling and fire EOS too.
104
105   The bin now has no more scheduled chains and no more pending subbins,
106   it fires EOS.
107   
108   
109 case 4) 
110
111 (-----------------------------------------------------------------------)
112 ! bin                                                                   !
113 !                                                     (---------------) !
114 !                                                     !thread         ! !
115 ! (--------)       (----------)         (--------)    !     (--------)! !
116 ! ! fakesrc!       !mpeg1parse!         ! queue1 !    !     !fakesink!! !
117 ! !       src -- sink        src ---- sink       src ---- sink       !! !
118 ! (--------)       !          !         (--------)    !     (--------)! !
119 !                  !          !                       (---------------) !
120 !                  !          !                                         !
121 !                  !          !                       (---------------) !
122 !                  !          !                       !thread         ! !
123 !                  !          !         (--------)    !     (--------)! !
124 !                  !          !         ! queue2 !    !     !fakesink!! !
125 !                  !         src ---- sink       src ---- sink       !! !
126 !                  !          !         (--------)    !     (--------)! !
127 !                  (----------)                       (---------------) !
128 (-----------------------------------------------------------------------)
129
130   this case differs from case3 in that one of the queues can be empty
131   while the other isn't. we assume queue1 is empty while queue2 isn't yet.
132
133 .scheduling.
134
135   case3 has tree scheduled entities: fsr-t(-q1,-q2), q1-fsk. q2-fsk
136   the first one is managed by the bin, the second two are managed by the
137   threads.
138   
139 .eos.
140
141   fakesrc detects the end of stream. It just returned the last buffer.
142   The next _pull will cause the srcpad to trigger gst_pad_set_eos ().
143   After that it will return a NULL buffer.
144
145   chain1 is taken out of the scheduling algorithm of the bin.
146
147   after a while, the threads finish their scheduling and fire EOS too.
148   chain2 (with  queue1) is taken out of the scheduling first because it
149   is empty.
150
151   chain3 (with queue2) finally removes its last scheduled chain and
152   fires EOS.
153
154   The bin now has no more scheduled chains and no more pending subbins,
155   it fires EOS.
156   
157   
158 case 5) 
159
160 (-----------------------------------------------------------------------)
161 ! bin                                                                   !
162 !                                                     (---------------) !
163 !                                                     !audiosink      ! !
164 ! (--------)       (----------)         (--------)    !               ! !
165 ! !disksrc1!       ! effect   !         ! mixer  !    !               ! !
166 ! !       src -- sink        src ---- sink     src -- sink            ! !
167 ! (--------)       (----------)         !        !    !               ! !
168 !                                       !        !    (---------------) !
169 ! (--------)       (----------)         !        !                      !
170 ! !disksrc2!       ! effect   !         !        !                      !
171 ! !       src -- sink        src ---- sink       !                      !
172 ! (--------)       (----------)         (--------)                      !
173 (-----------------------------------------------------------------------)
174
175   This is a simple audio mixer (mp3audio mixer).
176   We assume disksrc1 is going to be in EOS while disksrc2 is still in !EOS
177
178
179 .scheduling.
180
181   two chains are detected: disksrc1-effect-mixer-audiosink, 
182   disksrc2-effect-mixer-audiosink
183
184 .eos.
185
186   disksrc1 has passed the last buffer in the _get function. with its next 
187   call to _get, it will return a NULL buffer and set the src pad to EOS.
188
189   the EOS call travels up till the mixer element because it has overridden
190   the handler. The first chain is disabled from the scheduler.
191
192   finally disksrc2 run into EOS, same procedure as with disksrc1, except
193   now the mixer also sets EOS to its src pad, chain2 becomes inactive too
194   and the bin fires EOS because there are no more chains to schedule.
195   
196   somebody sets the location of disksrc1 to a new mp3 file, the srcpad 
197   is set to !EOS, chain1 is scheduled again, mixer is activated again too
198   and audio is playing again...
199
200
201 case 6) 
202
203 (-------------------------------------------------------------------------------------)
204 ! bin                                                                                 !
205 !                                                                   (---------------) !
206 ! (---------------------------------------------)                   !audiosink      ! !
207 ! ! thread1                                     !                   !               ! !
208 ! ! (--------)       (----------)      (-----)  !   (--------)      !               ! !
209 ! ! !disksrc1!       ! effect   !      !queue!  !   ! mixer  !      !               ! !
210 ! ! !       src -- sink        src -- sink  src -- sink     src -- sink             ! !
211 ! ! (--------)       (----------)      (-----)  !   !        !      !               ! !
212 ! (---------------------------------------------)   !        !      !               ! !
213 !                                                   !        !      (---------------) !
214 ! (---------------------------------------------)   !        !                        !
215 ! ! thread2                                     !   !        !                        !
216 ! ! (--------)       (----------)      (-----)  !   !        !                        !
217 ! ! !disksrc2!       ! effect   !      !queue!  !   !        !                        !
218 ! ! !       src -- sink        src -- sink  src -- sink      !                        !
219 ! ! (--------)       (----------)      (-----)  !   (--------)                        !
220 ! (---------------------------------------------)                                     !
221 (-------------------------------------------------------------------------------------)
222
223   This is a simple audio mixer (mp3audio mixer).
224   We assume disksrc1 is going to be in EOS while disksrc2 is still in !EOS
225
226 .scheduling.
227
228   Scheduling is a bit tricky here: we have two threads with each one chain ds1-e-q and
229   ds2-e-q. the mixer element is loop based and forms a third chain, mixer-audiosink
230
231 .eos.
232
233   disksrc1 has passed the last buffer in the _get function. with its next 
234   call to _get, it will return a NULL buffer and set the src pad to EOS.
235
236   the EOS call travels up till the queue element because it has overridden
237   the handler. The first chain is disabled from the scheduler. thread1 fires EOS
238   because it does not have any chains to schedule.
239
240   the mixer element pulls buffers from queue1 until queue1 is empty. At that time,
241   queue1 sets the pad to EOS, mixer now knows that it does not have to request
242   another buffer from that pad again.
243
244   disksrc2 finally sets its pad to EOS, rendering chain2 unscheduled which makes
245   the thread2 fire an EOS.
246
247   the mixer element pulls buffers from queue2 until queue2 is empty. At that time,
248   queue2 sets the pad to EOS, mixer now knows that it does not have to request
249   another buffer from that pad again. all pads for the mixer are in EOS now so
250   it sets the src pad to EOS. the last chain now also becomes unscheduled and
251   the bin fires EOS.
252
253