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!


Returns the capabilities of an audio device


int caps;
ioctl(fd, SNDCTL_DSP_GETCAPS, &caps);

The above code fragment lacks all error checks for clarity. Real world applications must always check for the errors and handle them as described below. Also most OSS ioctl calls will return information in the argument variable and it's usually necessary to check it too.


This ioctl call returns the capability mask of an audio device. The same information will be returned in the caps field of the SNDCTL_AUDIOINFO call. See the Audio device capabilities section for the detailed description of various device capabilities.

Compatibility issues

This ioctl call is supported by all OSS versions since about 3.8 (1995). If this call for any reason returns errno=EINVAL the application should assume that no capabilities were reported. The latest OSS versions know more capabilities than the earlier ones. However this doesn't cause any compatibility problems because the older drivers will not indicate capabilities they are not aware of.

OSS ioctl return values

The return value from the OSS ioctl calls will be -1 if a fatal error occurred. Other values mean that the ioctl call was more or less successful. However in most cases the application must check the value returned in the argument to see what was the accepted value.

Please see the Possible error codes (errno) returned by OSS calls section for more info about the error codes returned by OSS.

Sample programs

osstest.cThe osstest program shipped with OSS
fulldup.cFull duplex sample program using the single device approach.
mmap_test.cA sample program for using mmap()

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