On Fri, May 30, 2008 at 5:01 PM, Paul Adolph <padolph@xxxxxxxxx> wrote: > For playback I am using the ALSA callback to wake up a thread that > then feeds the ALSA ring buffer with a period-worth of samples using > snd_pcm_writei(). I've set snd_pcm_sw_params_set_avail_min() to one > period. The problem is that most of the time when my thread wakes up > and tries to write the data, snd_pcm_writei() fails with -EAGAIN, and > I must retry until it works. > > Presumably this write failure is because there is not enough space in > the ring buffer, but then why did the ALSA callback fire in the first > place? As it stands my retries are eating needless amounts of CPU. > What does snd_pcm_avail_update return if you call it before snd_pcm_writei in your callback? What period and buffer sizes do you use? FYI, you should seriously consider using poll() rather than the async/callback interface. It's more efficient than signals and more compatible with various IO plugins like pulseaudio. Lee ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Alsa-user mailing list Alsa-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-user