[alsa-devel] snd_pcm_writei VS snd_pcm_mmap_writei

Clemens Ladisch clemens at ladisch.de
Fri Nov 19 09:21:30 CET 2010

Jaroslav Kysela wrote:
> On Fri, 19 Nov 2010, Irfan Shaikh wrote:
> >         Please tell me
> >         a) Difference between working of snd_pcm_mmap_writei and snd_pcm_writei ?
> The mmap functions does not require user space / kernel context switches.
> >         b) Performance wise which is better ?
> > 
> >         When i use gettimeofday almost profile time comes almost same for both of them.
> With current hw power, there are no major differences.

Yes, the context switches have no noticeable impact on latency or

The only case where using the mmap functions makes sense is when the
program generates the samples on the fly and can write them directly
into the device's buffer.  If, however, the samples are already in some
other buffer and are to be copied into the device's buffer, then this is
_exactly_ the same situation as snd_pcm_writei.

If your algorithm requires that you always use snd_pcm_mmap_writei,
then you shouldn't have used mmap in the first place.


More information about the Alsa-devel mailing list