Pierre Vanhoucke wrote:
- How is it possible to get a "short read" in blocking mode ?
I would think that in blocking mode the control is only returned after the read is completed.
When an error occurs, you get the data that was read successfully before the error. We wouldn't want to throw away this data just because an error happened later. (This behaviour is for consistency with other uses of read(); in the case of audio, throwing away some data wouldn't actually hurt that much.)
- What are the possible causes for a "short read" ?
Buffer overrun, USB device or SPDIF source unplugged, other errors.
- What can be done to avoid a "short read" ?
You cannot prevent the user from unplugging a USB device, or the administrator from suspending your program until the buffer overruns.
- How am I supposed to recover from a "short read"?
Try to read the rest of that data that you wanted to read originally, then you'll get the error code. (Or you'll get some data if the error has vanished, but that is very unlikely.)
Best regards, Clemens