[alsa-devel] Question about SNDRV_PCM_STATE_DRAINING and DMA transfer

Clemens Ladisch clemens at ladisch.de
Fri Sep 26 09:35:37 CEST 2014


Kuninori Morimoto wrote:
> We noticed that DMA seems transfered +1 time when Ctrl-C happen.
> But, is this correct ? is this our driver bug ?
> [...]
> 7. DMA transfer interrupt happen
>
>    It calls snd_pcm_period_elapsed() and try to transfer next 2048 byte
>    snd_pcm_playback_avail() in snd_pcm_update_state() return 8192 this time.
>    then, it calls snd_pcm_drain_done()
>
> 9. snd_soc_dai_ops :: trigger called with SNDRV_PCM_TRIGGER_STOP
>
>    driver stops DMA transfer

There is no strong synchronization between snd_pcm_drain() and the rest
of the system; snd_pcm_drain() just waits for an underrun to happen.

In other words, the last actual DMA transfer is likely to contain
invalid (outdated) samples, but gets aborted immediately.


Regards,
Clemens


More information about the Alsa-devel mailing list