[alsa-devel] Why does snd_seq_drain_output() need lots of time to execute?
clemens at ladisch.de
Thu Jan 26 23:04:42 CET 2012
Rafał Cieślak wrote:
> The main problem is that although the documentation states that
> snd_seq_drain_output() returns immediately,
| "The function returns immediately after the events are sent to the
| queues ..."
> it turns out that it occasionally needs lots of time (even a second or
> two), and blocks my application, as I call it.
You could enable non-blocking mode to get an error instead of waiting.
Or you could to increase the size of the output buffer.
> And before you ask, I've set the output buffer to some huge amount,
A sequencer client has _two_ output buffers, one in alsa-lib, and one in
the kernel. Events that are scheduled for later stay in the kernel
buffer until they are actually delivered; when this buffer would
overflow, functions that drain the userspace buffer to the kernel buffer
To increase the kernel buffer's size, use the snd_seq_client_pool* and
snd_seq_get/set_client_pool functions. ("pool" is the buffer size, in
events; "room" is the number of free events that causes a blocked
function to wake up.)
More information about the Alsa-devel