[MPlayer-dev-eng] PulseAudio drain timeout
Ivan Kalvachev
ikalvachev at gmail.com
Sun Feb 5 21:10:37 CET 2012
In commit r34652 I've committed a simple workaround for the 2 second
delay when draining the audio stream in PulseAudio.
While the fix works for the most cases, the person who helped me find
the solution (Rune Heggtveit) found some cases where it doesn't work.
He have written a workaround that works for these cases. As he hasn't
sent his code to the maillist I'm posting it instead. It needs a
little more polishing. e.g. implement broken_drain like the existing
broken_pause. (the big ugly if() is mine, if the patch doesn't
compile, it's probably my fault).
How does it work:
The old workaround sleeps while the already written data is played.
However if the playback have just been initiated and the internal
buffer haven't been filled, the actual audio playback is not yet
started. As it haven't been started, no mater how long does we wait,
the audio won't be played.
So Rune's code fills the remaining internal buffer with zeroes
(silence), so the data is pushed to the sound-server. Then it waits
for the original amount of useful audio data to be played, before
resetting the stream.
(in Rune's original code the drain function was still called after the
reset, I put it in the else{}. You can take a look while the code is
still present in http://codepad.org/a40dMZZ1 .
In short, with this code you can play files smaller than PA internal
buffer without triggering the dreadful 2 second delay.
FYI, I don't have PA on my system and I'm happy staying this way.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pulseaudio_small2sec.patch
Type: application/octet-stream
Size: 1848 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20120205/fb4ec581/attachment.obj>
More information about the MPlayer-dev-eng
mailing list