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 close() system call

All OSS system calls follow the familiar Posix/Unix semantics. Please look at the standard manual page (man close) 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.

The close system call closes the device. It works exactly like with any other device or file. The only thing that is different is that the close call blocks until all data written to the device has actually been played. This doesn't usually take longer than couple of seconds and it's usually what the customer expects. However when the application was killed by a signal there is no wait (the playback will be aborted automatically).

This wait feature may cause troubles with MIDI and sequencer devices when the timing feature is used. The close call will wait until all the events have been played. This may take several minutes or even longer depending on the timing of the sequence. For this reason it may be a good idea to abort the device before close if the user decided to exit the application in the middle of playback.

There is no need to call any sync or reset routines before calling close in normal situations. The close system call will do this automatically. Calling reset will cut the last second(s) of the playback which is probably not what the end user wants. Calling sync may cause some kind of extra click in output.

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