[alsa-devel] ALSA with dmix performance issue...
bogdan.sandulescu at yahoo.com
Mon Nov 12 10:13:15 CET 2012
While implementing a multiple sounds playback using 'dmix' plugin, I've encountered several performance issues. Here they are:
1. The snd_pcm_open(&pPcmPlayHandle, "plug:'dmix:RATE=8000'" , SND_PCM_STREAM_PLAYBACK, 0) - used to playback multiple sounds with dmix pluging, it is taking around 70ms to complete. This is a very long period, considering there are some sounds to be played which have 50ms lenght! Is it possible to decrease this value?
2. Same issue with the "setting Parameters" sequence. It is also taking around 80ms to complete; Is it possible to decrease this value?
3. The architecture of my module is done as follows:
- MainThread() -> receives sound play requests and creates new thread/threads based on such requests * PlayThreads() -> created whenever a sound playback is needed; it opens() the dmix, setting parameters; output data; close dmix; exit thread at playback completion; multiple PlayThreads() could be active at the same time!
I have tried to move all 'common' sound settings and the pcm_open() - in order to optimize runtime - into the MainThread (operation done only once), and the PlayThreads are responsible just of outputing data. However, this resulted in incorrect ALSA functionality: when more than two playbacks are active at the same time, all Play threads , except the first activated one, cannnot access the PCM handle correctly: returned code -77 (EBADFD), in some other cases returned -5 (EIO)...
Are there any other methods I can optimize the runtime performance?
Thank you in advance for any answers,
More information about the Alsa-devel