[alsa-devel] snd_pcm_writei returns -EAGAIN after poll

Ivan Sorokin sorokin at rain.ifmo.ru
Sun Mar 20 03:21:17 CET 2011


Hello!

I use slightly modified test/pcm.c in write_and_poll mode.

My program looks like this:

snd_pcm_open with SND_PCM_NONBLOCK
snd_pcm_set_params

infinite loop
    poll for snd_pcm_poll_descriptors
    snd_pcm_poll_descriptors_revents
    if POLLOUT flag is set
       snd_pcm_writei

Everything works, but snd_pcm_writei sometimes returns -EAGAIN. The 
probability of when snd_pcm_writei returns -EAGAIN depends on buffer 
size that I pass to it. ExperimentallyI found out that when I call 
snd_pcm_writei with 940 bytes buffers (maybe something related to period 
size?) it never returns -EAGAIN.

Why poll returns when there is no place for new data? Is it ok to ignore 
EAGAIN and just start another poll? Is there any recommended buffer size 
for snd_pcm_writei?

My test program: 
https://github.com/sorokin/asoundpp/blob/master/sine_async.cpp (94 LOC)


More information about the Alsa-devel mailing list