When command SNDRV_PCM_TRIGGER_STOP is asked in snd_pcm_ops trigger(), which buffer in the buffer list should be the last one to output by the DMA?
In our blackfin ad1981 linux driver, there is an output ring with "periods" buffers. Each buffer is of the size of "period_size".
After ALSA starts playing, several buffers ahead of current one running by the DMA controller are usually filled in advance by the ALSA layer. When command SNDRV_PCM_TRIGGER_STOP is asked in snd_pcm_ops trigger(), which buffer should be the last one to output by the DMA?
1. Current buffer, which is running by the DMA controller
2. The last buffer, which the DMA controller just finished outputting and snd_pcm_ops pointer() is notifiyed to ALSA layer. Does this mean current buffer in DMA should be abandoned in the middle?
3. The last buffer, which the ALSA layer has just filled in snd_pcm_ops copy()?
Thanks
Quoted 5 lines · Sonic Zhang
After ALSA starts playing, several buffers ahead of current one running by the DMA controller are usually filled in advance by the ALSA layer. When command
SNDRV_PCM_TRIGGER_STOPis asked insnd_pcm_opstrigger(), which buffer should be the last one to output by the DMA?
When the stop trigger is called, the stream should be stopped immediately, that is, you should, if possible, not even wait for the end of the current buffer.
When an application calls snd_pcm_drain(), ALSA stops filling the buffer and waits until the data has played before calling the stop trigger.
HTH
Clemens