[MPlayer-dev-eng] PulseAudio drain timeout
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Feb 5 23:26:38 CET 2012
On 5 Feb 2012, at 21:10, Ivan Kalvachev <ikalvachev at gmail.com> wrote:
> 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.
IMO that is too messy and too much code for a bug workaround.
Just do only the sleep if a broken pulseaudio is detected.
If you think it will annoy users, print a warning message making clear who is to blame so they visit the right people with a cluebat.
More information about the MPlayer-dev-eng
mailing list