[alsa-devel] Too many snd_pcm_mmap_readi calls

Clemens Ladisch clemens at ladisch.de
Wed May 7 14:58:59 CEST 2014

Jan Homann wrote:
> In my opinion mmap_begin just tells the alsa-lib that someone is about
> to access the buffer.

With mmap_begin, you ask the device how many frames are available in the
buffer (and get a pointer to them).  With mmap_commit, you tell the
device how many frames you actually read.

> I am using mmap because of its good performance.

Using mmap makes sense only when you are accessing the samples in the
buffer directly.  If you just copy the frames into your own buffer,
there is *no* difference whatsoever to snd_pcm_readi.

> Under normal condition with snd_pcm_mmap_readi my program uses about
> 1% of cpu-time where snd_pcm_readi uses about 75%.

It's likely that you do not correctly wait for frames being available
in your real program.

> Do you know a good tutorial about using mmap_readi?

This: use snd_pcm_readi instead.


More information about the Alsa-devel mailing list