Google
 

Open Sound System
OSS 4.x Programmer's Guide

Do you have problems with sound/audio application development? Don't panic! Click here for help!

The read() system call

All OSS system calls follow the familiar Posix/Unix semantics. Please look at the standard manual page (man read) for more informtion. This section will only explain some OSS related details. The error codes returned by OSS as well as their meaning will be described in the Possible error codes (errno) returned by OSS calls section.

There is one special case where OSS behaves in different way than standard Posix/Unix read. It's the /dev/midi device. By default it will wait only for the first MIDI byte. After that it will return immediately with just the bytes that were received up to that moment. Applications using /dev/midi should not interpret this as an EOF condition.

OSS supports non-blocking I/O on audio devices. Programmers who use this feature should be familiar with the strange behaviour of read in this mode.

If the application doesn't want to block then it's better to use The select() and poll() system calls together with the device specific ioctl calls instead of using non-blocking mode. This is much easier way to do the same job.

In most cases the best approach is to let reads to block. There is no need to avoid blocking unless it makes the application unresponsive. In particular non-blockiong I/O must not be used if it results in use of nasty wait methods. Blocking reads and writes will do the same automatically with superior performance and without any unnecessary problems.



Copyright (C) 4Front Technologies, 2007. All rights reserved.
Back to index OSS web site