Re: [PATCH 5/6 v2] sound: Add n64 driver

Lauri Kasanen
2021-01-11T12:02:37Z

On Mon, 11 Jan 2021 11:11:39 +0100
Takashi Iwai <tiwai@suse.de> wrote:

> > This almost works, speed is correct, but the last part is played twice.
>
> Oh yes, at the last IRQ, the push should be avoided.
> I guess that the code order should be changed to the following way:
>
> 1. advance the position for a period size
> 2. call snd_pcm_period_elapsed()
> 3. check if the stream is still running
> 4. copy the next chunk and update nextpos

This order gives correct pointer advancing etc, but now it's hitting a
new problem: the pcm core is reusing the buffer from under the audio
card. It's writing new data to the area that is currently being read by
DMA.

I assume the core expects DMA to be instant, but in this card's case
it's ondemand, reading bytes as needed.

By restoring the memcpy buffer, I get good audio with this new order
(sans occasional crackling due to the memcpy taking too long).

- Lauri