>No, NO...
>
>Never do this mistake, you cannot use mmap_begin result to know how many
>frames are available: it simply does not work with non HW PCM.
>
>You *have* to use snd_pcm_avail_update() for that.

I was simplifying my loop for pedagogical purposes. Of course I use
snd_pcm_avail_update() initially.

>I rewrite your loop:
>
>       avail = snd_pcm_avail_update(pcm);
>       while (avail > 0) {
>               frames = min(avail, block_size);
>               snd_pcm_mmap_begin(pcm, areas, &offset, &frames);
>               process(frames);
>               snd_pcm_mmap_commit(pcm, offset, frames);
>               avail -= frames;
>       }
>
>As you see you don't need to reduce frames after mmap_begin.

NO!!! the value returned by snd_pcm_mmap_begin() may exceed the number
we are allowed to process in one block (no malloc-activity is allowed
during process(), so all the buffers have to be correctly sized
already). ardour had been suffering from lots of random segfaults
because i wrote a loop exactly like the one you have above. 

the question is: do we call snd_pcm_mmap_commit() as soon as some of
the frames are handled, or after everything is done? i felt it
preferable to update the driver's view of world ASAP.

--p

_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to