Added case6: a multithreaded audio mixer setup.

Original commit message from CVS:
Added case6: a multithreaded audio mixer setup.
This commit is contained in:
Wim Taymans 2001-01-13 02:12:44 +00:00
parent 8ea591ef29
commit 92820d240d

View file

@ -198,29 +198,56 @@ case 5)
and audio is playing again...
case 6)
(-------------------------------------------------------------------------------------)
! bin !
! (---------------) !
! (---------------------------------------------) !audiosink ! !
! ! thread1 ! ! ! !
! ! (--------) (----------) (-----) ! (--------) ! ! !
! ! !disksrc1! ! effect ! !queue! ! ! mixer ! ! ! !
! ! ! src -- sink src -- sink src -- sink src -- sink ! !
! ! (--------) (----------) (-----) ! ! ! ! ! !
! (---------------------------------------------) ! ! ! ! !
! ! ! (---------------) !
! (---------------------------------------------) ! ! !
! ! thread2 ! ! ! !
! ! (--------) (----------) (-----) ! ! ! !
! ! !disksrc2! ! effect ! !queue! ! ! ! !
! ! ! src -- sink src -- sink src -- sink ! !
! ! (--------) (----------) (-----) ! (--------) !
! (---------------------------------------------) !
(-------------------------------------------------------------------------------------)
This is a simple audio mixer (mp3audio mixer).
We assume disksrc1 is going to be in EOS while disksrc2 is still in !EOS
.scheduling.
Scheduling is a bit tricky here: we have two threads with each one chain ds1-e-q and
ds2-e-q. the mixer element is loop based and forms a third chain, mixer-audiosink
.eos.
disksrc1 has passed the last buffer in the _get function. with its next
call to _get, it will return a NULL buffer and set the src pad to EOS.
the EOS call travels up till the queue element because it has overridden
the handler. The first chain is disabled from the scheduler. thread1 fires EOS
because it does not have any chains to schedule.
the mixer element pulls buffers from queue1 until queue1 is empty. At that time,
queue1 sets the pad to EOS, mixer now knows that it does not have to request
another buffer from that pad again.
disksrc2 finally sets its pad to EOS, rendering chain2 unscheduled which makes
the thread2 fire an EOS.
the mixer element pulls buffers from queue2 until queue2 is empty. At that time,
queue2 sets the pad to EOS, mixer now knows that it does not have to request
another buffer from that pad again. all pads for the mixer are in EOS now so
it sets the src pad to EOS. the last chain now also becomes unscheduled and
the bin fires EOS.