[LAD] interrupt-drive ALSA returning buffers too small

From: Gabriel M. Beddingfield <gabrbedd@email-addr-hidden>
Date: Wed Sep 08 2010 - 17:18:24 EEST

I was going through Paul Davis's excellent tutorial on the
ALSA API:

   http://www.equalarea.com/paul/alsa-audio.html#interruptex

I've set alsa to wake me up every N frames. However, when I
awake, I find that I often have fewer than N frames
available:

   int err;
   uint32_t N = 2048, frames_to_deliver;
   assert( 0 == ((N-1)&N) ); /* power of 2 */

   /*...*/

   snd_pcm_sw_params_set_avail_min (playback_handle, sw_params, N)

   /* ... */
   while(1) {
      err = snd_pcm_wait(playback_handle, 1000);
      assert(err >= 0); /* OK */

      frames_to_deliver = snd_pcm_avail_update(playback_handle);
      assert(frames_to_deliver >= 0); /* OK */

      /* this fails about every other cycle: */
      assert(frames_to_deliver >= N);

   }

E.g. with N = 2048, I'll typically get a stream that looks
like 1996, 2048, 2048, 1990, 2048, 1999, 2048...

Any ideas?

-gabriel
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Wed Sep 8 20:15:01 2010

This archive was generated by hypermail 2.1.8 : Wed Sep 08 2010 - 20:15:02 EEST