[alsa-devel] ALSA with dmix, help needed
Hello,
I am struggling for some time now with dmix plugin from ALSA. Could anyone please answer to these questions:
1. Is ALSA library with DMIX plugin suitable for real-time embedded systems: where it's needed small api latencies, fast output to dma/serial bus and no audible defects?
2. Is it reliable to use ALSA commands from different threads? (e.g. open() in one master thread, writei() from child threads)?
3. Is it normal that two consecutive writei() calls to generate underrun - this happens only just after opening the dmix device.
e.g.:
if( snd_pcm_writei(pPcmPlayHandle, (pu8WavDataBuf), 2048) < 0) fprintf(stderr, "Underrun encountered: application didn't sent enough data to the ALSA buffer \n"); if( snd_pcm_writei(pPcmPlayHandle, (pu8WavDataBuf+4096),2048) < 0) fprintf(stderr, "Underrun encountered: application didn't sent enough data to the ALSA buffer \n");
The second writei() generates this underrun error (-32), even though there is no delay between these two calls. The get_buff_size is 4096, get_buf_period = 1024.
4. The pcm_drain() help states: "for playback, wait for all pending frames to be played and then stop the PCM" But, how come the execution duration of this drain() takes longer than the actual sound duration? e.g. pcm_drain() takes 300-400 miliseconds, but the wav size sent to writei() is less than 100ms?
I'm using ASLA lib 1.0.25, on a ARM controller with 440MHz, and no other high prio threads.
participants (1)
-
Sandulescu Bogdan