Interesting, what the correct way to stop playing then?
The ALSA core could pad the stream with silence up to the end of the period when drain is called. It knows what the hw ptr value should be at the next interrupt, which doesn't appear to be available to user space.
On Fri, Nov 25, 2011 at 12:38 PM, Clemens Ladisch clemens@ladisch.de wrote:
Trent Piepho wrote:
When the driver schedules the final period, couldn't it check if the device is draining, and if so try to end playback at the right time.
The ALSA framework was designed for cards where DMA doesn't need to be scheduled continuously, so it is assumed that stopping happens asynchronously.
You could try to check the PCM state, but it's possible that the call to snd_pcm_drain() happens after you've scheduled the final period.
Regards, Clemens