||04-25-2007 02:08 PM
Why is ALSA giving me xruns?
I am new to Linux and I am new to ALSA. I am working on an embedded Linux system with Kernel 126.96.36.199 (PPC arch). I am using ALSA 1.0.9a. I am trying to route audio from usb to a TLV codec. I figured the easiest way to do this for demo purposes was to just pipe arecord's output to aplay (e.g. arecord -D hw:1,0 -f dat | aplay). This works except for the audio pausing frequently and printing "underrun!!! (at least 120.315 ms long)" with a different value for the time in ms every time. I have played with the value of every parameter in arecord's options and all it does is change the value of time in ms (not linearly) and usually making the pausing worse. I thought this could be a clock drift problem so I tried just using arecord and I still get overruns. I have used multiple audio sources over usb and I have also used audio from a mic which uses a completely different driver so I don't think it has to do with my codec driver and I am using the generic snd-usb-audio driver from linux which seems to be working fine for what it needs to be doing. This leads me to believe that there is something wrong with arecord. When I studied the aplay.c source file from the alsa-utils package I found that whether I am using capture or playback (overrun or underrun) it is getting to the same snd_pcm_state which is xrun. Can anyone explain to me why it is getting in this xrun state and what I can possibly do to prevent this? Any insight would be useful, thanks.