[MPlayer-dev-eng] [PATCH] Add audio support for sndio API.

Alexandre Ratchov alex at caoua.org
Fri Dec 20 01:36:03 CET 2013


On Thu, Dec 19, 2013 at 01:32:05PM +0100, Reimar Döffinger wrote:
> Alexandre Ratchov <alex at caoua.org> wrote:
> >On Thu, Dec 19, 2013 at 11:25:25AM +0100, Reimar Döffinger wrote:
> >> Alexandre Ratchov <alex at caoua.org> wrote:
> >> Sorry, but this makes 0 sense to me. Delay is something you
> >> calculate yourself in e.g. movcb, you don't get it from sndio, so
> >> I don't understand how what sndio does helps you.
> >
> >During playback, the delay is defined as:
> >
> >delay = (samples_written - samples_played) / sample_rate
> >
> >where samples_played is the sum of "deltas" reported by the
> >onmove() call-back.
> >
> >It can't be negative (sndio pauses when the buffer is empty)
> 
> It can still become negative if you end up updating delay in a
> way that makes it mismatch the actual buffer fill. You set it to
> 0, which would only be correct if reset discarded the buffers,
> but previously we said it doesn't. The documentation as usual
> doesn't document the behaviour at all, so I can't know what it
> does.
> 
> >> Also, since reset does not drop the buffers I can't see how it
> >> should be correct to set delay to 0, any new data should be
> >> delayed by as much time as there is data the old buffers.
> >>
> >
> >When we call sio_start() to resume, we consider buffers are drained
> >(thus empty)
> 
> You can't just "consider" them empty when they aren't.
> Either reset discards the buffers or it does not. You said it
> doesn't, so the buffers are not empty after reset and setting
> delay to 0 is wrong (since delay 0 should mean the buffers are
> empty).

according to the man page "The sio_stop() function stops playback
and recording and puts the audio subsystem in the same state as
after sio_open() is called."

So the "contract" is: after sio_stop() returns, the device can be
used as if it was freshly opened & configured (implies empty
buffer). For the bare hardware, this means DMA stopped, buffer
empty. If the server is used, it may drain some data in the
background using its own buffers, but all this is hidden from the
client.

So, it's ok to assume the buffer is empty after sio_stop().

-- Alexandre


More information about the MPlayer-dev-eng mailing list