[alsa-devel] ASoC: mmap or read/write?
Hi,
I'm writing an alsa application for recording & playing 16 channel audio.
The application is intended to run on an embedded platform & the resources are highly constrained. My application is not performing well with read/write methods. I'm considering using mmap but not able to get the right documentation or start, so I want to know whether mmap really offers any advantages or not.
Does the mmap method has any advantages over read/write? Is there any thumb rule to decide when to use mmap or read/write?
-Prasant
Prasant J wrote:
I'm writing an alsa application for recording & playing 16 channel audio.
The application is intended to run on an embedded platform & the resources are highly constrained.
Then I wonder how you manage to handle 16 channels. What hardware is this?
My application is not performing well with read/write methods.
How much CPU usage?
Does the mmap method has any advantages over read/write?
No, except when then samples are generated in/consumed from the device's buffer directly without copying them around, and even then it's unlikely that the time needed for copying actually matters.
Is there any thumb rule to decide when to use mmap or read/write?
Yes; use read/write.
Regards, Clemens
On Thu, Oct 18, 2012 at 2:39 PM, Clemens Ladisch clemens@ladisch.de wrote:
Prasant J wrote:
I'm writing an alsa application for recording & playing 16 channel audio.
The application is intended to run on an embedded platform & the resources are highly constrained.
Then I wonder how you manage to handle 16 channels. What hardware is this?
I'm working with Beaglebone (ARM Cortex-A8 720 MHz). (Currently failures are for 8 channels 32 bit / 16 bit, but our final target is 16 channels)
My application is not performing well with read/write methods.
How much CPU usage?
The CPU usage is around 35% (as seen in top)
I have managed to get Audio capture working fine (after certain linux optimizations) but playback is giving under-runs (only when PLAYBACK & CAPTURE run together) I was wondering that changing access method to mmap (currently I'm using read/write) may give me some more CPU time.
Does the mmap method has any advantages over read/write?
No, except when then samples are generated in/consumed from the device's buffer directly without copying them around, and even then it's unlikely that the time needed for copying actually matters.
Is there any thumb rule to decide when to use mmap or read/write?
Yes; use read/write.
OK. You say read/write is the best apart from the one use case you mentioned, makes sense, because, irrespective I use read/write or mmap, in my case, I will anyway have to copy the buffers to mmap-ed area.
Regards, Clemens
Thanks for inputs!
Regards, Prasant
participants (2)
-
Clemens Ladisch
-
Prasant J