[MPlayer-dev-eng] [PATCH] Fix ao_dsound looping tail audio when shorter than video

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Mar 6 23:54:59 CET 2009


On Fri, Mar 06, 2009 at 04:49:35PM -0500, David Bolen wrote:
> The attached proposed patch corrects this.  The basic flaw appears to
> be that ao_dsound sets up the play buffer in looping mode.  I don't
> understand why (it's not a requirement for a secondary DirectSound
> buffer), but since I definitely get some audio glitches if it isn't
> set, for the moment I'm willing to go with "because it works" as the
> reason it was done this way originally.

You misunderstood how this works, contrary to ao_win32 there is only one
buffer, and that one is read and written like a ring buffer, i.e.
MPlayer would write some data at the start, dsound would start playing
from the start, then later MPlayer writes another bit of data right
after the data it wrote previously while dsound continues playing the
buffer. If one of them reach the end they will just continue from the
front again.
Which also means your change is wrong, if e.g. MPlayer writes that final
chunk to the front of the buffer but dsound still plays somewhere in the
middle, disabling looping will cause that final part not to be played at
all (in so far even the current code is wrong).
dsound should have some overrun detection stuff that maybe would allow
you to make it stop at the right place. As an alternative, you could
overwrite as much as possible with zeros (i.e. everything that has
already been played).



More information about the MPlayer-dev-eng mailing list