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!

Audio Programming

General Information

If you read this section carefully you will find about 50 different ioctl calls which permit controlling all aspects of the hardware. However this doesn't mean that there is any need to use more than 3 or 4 of them. OSS is designed to provide optimal default values for all parameters and it's very unlikely that any application can improve anything by changing the defaults.

Absolutely the most common reason to problems with audio programs is that their programmers have made unnecessary operations that make the device to fail. For best results you should start by reading the Audio fundamentals and the Some common types of audio programs sections of this manual.

Audio fundamentals
Supported audio formats
When OSS audio ioctl calls can be made
Myths and urban legends about audio
Audio timing considerations
Audio device capabilities
Using multiple channels with OSS
Using simultaneous audio recording and playback (full duplex)
Audio input and output volumes and routings
Some common types of audio programs

Audio ioctl call list

Below is the full list of audio ioctl calls available in OSS 4.0. It's very important to understand that most of these calls are only necessary in extremely rare cases. Just 3 or 4 of the following calls are actually needed in most applications (SNDCTL_DSP_SETFMT, SNDCTL_DSP_CHANNELS, SNDCTL_DSP_SPEED and sometimes SNDCTL_DSP_SETFRAGMENT or alternatively SNDCTL_DSP_POLICY. The Audio input and output volumes and routings section explains some other ioctl calls that may be usefull in some applications. Most other ioctl calls are provided just for completeness of the API.

SNDCTL_DSP_BIND_CHANNELRoute stereo output to the specified channels (obsolete)
SNDCTL_DSP_CHANNELSSet the number of audio channels
SNDCTL_DSP_COOKEDMODEDisable/enable the "on fly" format conversions made by the OSS software
SNDCTL_DSP_CURRENT_IPTRReturns the current recording position
SNDCTL_DSP_CURRENT_OPTRReturns the current playback position
SNDCTL_DSP_GETBLKSIZEGet the current fragment size (obsolete)
SNDCTL_DSP_GETCAPSReturns the capabilities of an audio device
SNDCTL_DSP_GETCHANNELMASKReturns the bindings supported by the device (obsolete)
SNDCTL_DSP_GET_CHNORDERGet the channel ordering of a multi channel device
SNDCTL_DSP_GETERRORReturns audio device error information
SNDCTL_DSP_GETFMTSReturns a list of natively supported sample formats
SNDCTL_DSP_GETIPEAKSThe peak levels for all recording channels
SNDCTL_DSP_GETIPTRReturns the current recording pointer (obsolete)
SNDCTL_DSP_GETISPACEReturns the amount of recorded data that can be read without blocking.
SNDCTL_DSP_GETODELAYReturns the playback buffering delay
SNDCTL_DSP_GETOPEAKSThe peak levels for all playback channels
SNDCTL_DSP_GETOPTRReturns the current playback pointer (obsolete)
SNDCTL_DSP_GETOSPACEReturns the amount of playback data that can be written without blocking.
SNDCTL_DSP_GET_PLAYTGT_NAMESReturns labels for the currently available output routings
SNDCTL_DSP_GET_PLAYTGTReturns the current output routing
SNDCTL_DSP_GETPLAYVOLReturns the current audio playback volume
SNDCTL_DSP_GET_RECSRC_NAMESReturns labels for the currently available recording sources
SNDCTL_DSP_GET_RECSRCReturns the current recording source
SNDCTL_DSP_GETRECVOLReturns the current audio recording level
SNDCTL_DSP_GETTRIGGERReturns the current trigger bits (obsolete)
SNDCTL_DSP_HALT_INPUTAborts audio recording operation
SNDCTL_DSP_HALT_OUTPUTAborts audio playback operation
SNDCTL_DSP_HALTAborts audio recording and/or playback operation
SNDCTL_DSP_LOW_WATERSets the trigger treshold for select()
SNDCTL_DSP_NONBLOCKForce non-blocking mode
SNDCTL_DSP_POLICYSets the timing policy of an audio device
SNDCTL_DSP_POSTForces audio playback to start (obsolete)
SNDCTL_DSP_READCTLReads the S/PDIF interface status.
SNDCTL_DSP_SAMPLESIZESets the sample size (obsolete)
SNDCTL_DSP_SETDUPLEXTurns on the duplex mode
SNDCTL_DSP_SETFMTSelect the sample format
SNDCTL_DSP_SETFRAGMENTSets the buffer size hint
SNDCTL_DSP_SET_PLAYTGTSets the current output routing
SNDCTL_DSP_SETPLAYVOLChanges the current audio playback volume
SNDCTL_DSP_SET_RECSRCSets the current recording source
SNDCTL_DSP_SETRECVOLChanges the current audio recording level
SNDCTL_DSP_SETSYNCROSlaves the audio device to the /dev/sequencer driver (obsolete)
SNDCTL_DSP_SETTRIGGERStarts audio recording and/or playback in sync
SNDCTL_DSP_SILENCEClears the playback buffer with silence
SNDCTL_DSP_SKIPDiscards all samples in the playback buffer
SNDCTL_DSP_SPEEDSet the sampling rate
SNDCTL_DSP_SUBDIVIDERequests the device to use smaller fragments (obsolete)
SNDCTL_DSP_SYNCGROUPCreates a synchronization group.
SNDCTL_DSP_SYNCSuspend the application until all samples have been played
SNDCTL_DSP_SYNCSTARTStarts all devices added to a synchronization group.
SNDCTL_DSP_WRITECTLAlters the S/PDIF interface setup.

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