[alsa-devel] Question about SNDRV_PCM_STATE_DRAINING and DMA transfer

Kuninori Morimoto kuninori.morimoto.gx at gmail.com
Fri Sep 26 06:36:23 CEST 2014


Hi Mark, ALSA ML

We noticed that DMA seems transfered +1 time when Ctrl-C happen.
But, is this correct ? is this our driver bug ?
our buffer_size is 8192, and DMA transfers 2048 in 1 time.

1. Ctrl-C happen

   wait_for_avail() of snd_pcm_lib_write1() returns -ERESTARTSYS immediately
   no transfer() are called any more.

2. DMA transfer interrupt happen

   This is normal from driver point of view
   It calls snd_pcm_period_elapsed() and try to transfer next 2048 byte

3. snd_pcm_common_ioctl1() :: SNDRV_PCM_IOCTL_DRAIN is called

   it goes to SNDRV_PCM_STATE_DRAINING status in snd_pcm_drain()
   and it wait until all drained.

4. 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 2048 this time.

5. 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 4096 this time.

6. 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 6144 this time.

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   

2) / 4) / 5) / 6) / 7) continue DMA transfer.
but, 1) already quited from snd_pcm_lib_write1() I guess.
So, 2) and 7) uses same buffer ?
What/Where is wrong ?

Best regards
---
Kuninori Morimoto


More information about the Alsa-devel mailing list