[alsa-devel] ALSA processor usage is too high

Adam Rosenberg adam at alcorn.com
Fri Nov 5 16:19:53 CET 2010


On Fri, Nov 5, 2010 at 10:31 AM, Clemens Ladisch <clemens at ladisch.de> wrote:
> Adam Rosenberg wrote:
>> I am trying to decode 8 MP3 files simultaneously.  Each file is 3
>> minutes 11 seconds long.  When I just decode the files and copy the
>> PCM data to memory it takes 2 minutes 36 seconds.  When I do the same
>> test after opening 8 ALSA PCM streams and while writing data to them
>> it takes 4 minutes 37 seconds.  This is much too slow for what should
>> be a simple copy operation.
>
> Are you using the "hw" device?  Otherwise, it's not a simple copy op.

I am using the hw device for each stream.

>
> How much CPU does "aplay -D hw -t raw -f dat /dev/zero" use?
>

I do not know how to calculate CPU usage for a given process.

All of my calculations have just been done by running the application
I wrote (which has to do a number of other things while decoding mp3
data and playing audio).  I time the application from start to finish
to determine if it is handling all of the tasks in an acceptable
amount of time.

For the audio playback I am polling the streams using
snd_pcm_avail_update() and then writing the number of frames available
using snd_pcm_writei().  I am trying to squish this whole project into
2mb of flash so I will not be able to include aplay in the final os
image.

I am able to add aplay for testing so I used your command to open the
8 streams, removed the audio processing from my application, and ran
the test again.  The result was 4 minutes and 35 seconds, which is
basically the same as the result from the test within my application
and much too slow.

Thanks,
Adam


More information about the Alsa-devel mailing list