[alsa-devel] [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense

Grant Likely grant.likely at secretlab.ca
Sat Nov 7 19:53:30 CET 2009

On Sat, Nov 7, 2009 at 6:04 AM, Jon Smirl <jonsmirl at gmail.com> wrote:
> On Sat, Nov 7, 2009 at 7:51 AM, Jon Smirl <jonsmirl at gmail.com> wrote:
>> On Sat, Nov 7, 2009 at 3:34 AM, Grant Likely <grant.likely at secretlab.ca> wrote:
>>> Sound drivers PCM DMA is supposed to free-run until told to stop
>>> by the trigger callback.  The current code tries to track appl_ptr,
>>> to avoid stale buffer data getting played out at the end of the
>>> data stream.  Unfortunately it also results in race conditions
>>> which can cause the audio to stall.
>> I leave in an hour and I will be off net for a week so I can't look at these.
> There is a surefire way to fix this but I have resisted doing it
> because it is fixing a symptom not a cause.
> Simply have the driver zero out the buffer in the completion interrupt
> before handing it back to ALSA. Then if ALSA lets us play invalid data
> the invalid data will be silence. I implemented this and it works
> every time.
> Downside is a big memset() in an IRQ handler.

... and then the driver may as well manually copy the audio data from
the buffer into the PSC FIFO.  No win here.

The other option (which I think is how ALSA is designed) is for
userspace to insert silence at the end of playback data so that the
stop trigger lands in a safe place.


More information about the Alsa-devel mailing list