Christopher Monty Montgomery wrote: > On 10/9/06, Clemens Ladisch <[EMAIL PROTECTED]> wrote: > > Christopher Monty Montgomery wrote: > > > If it uses dummy data, it never reports the xrun. > > > > In that case, it cannot report the xrun immediately because returning an > > error code from snd_pcm_write() (or write()) would mean something > > different. > > > > You can detect an xrun by checking whether the return value of > > snd_pcm_delay() is negative. > > Hrm. that's non-atomic and as such involves a race and is not > reliable. Or am I missing something in the API? Does the xrun staus > persist until read?
The delay gets smaller when the device reads data out of the buffer, and gets larger when the application writes data to the buffer. In an underrun situation, the delay remains negative until you have written some data (some part of which won't actually be played because it was written too late). > Why could the write/read not return an error code? It would indicate a failure of the write/read call, but the while point of the xrun-ignoring mode is to make xruns a non-failure condition. > Again, there's EINTR and EAGAIN for precedent, which are similar ways > of giving feedback in a blocking call. Error codes like these indicate that the call was not able to do its job, but in an xrun condition, writing/reading is still possible. > EPIPE also already reports non-permanent errors (in the sense that you > can re-prepare and start the stream back up). EPIPE is a permanent error in the sense that you cannot simply call write()/read() again. (And re-preparing might fail for other reasons, such as insufficient memory.) I think you want the ALSA API to behave like your implementation of usb_submit_urb(), but this just isn't the way it was designed. :-) Regards, Clemens ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel