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!

SNDCTL_DSP_HALT_INPUT

Aborts audio recording operation

Usage

ioctl(fd, SNDCTL_DSP_HALT_INPUT, NULL);

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.

Description

This ioctl call can be used to abort ongoing recording operation on an audio device. There is no need to use this call after opening the device. In the earlier OSS versions this ioctl call was called as SNDCTL_DSP_RESET_INPUT. This name is still valid but for clarity reasons it is not recommended in new programs (designed for OSS 4.x or later). The only situation where this call is really necessary is when the sample rate or sample format needs to be changed after recording has already been started. Some applications use it also before closing the audio device but this is normally not necessary (it prevents the last 0.1 to 1.0 seconds of the audio file from playing). There is no need to call SNDCTL_DSP_HALT_INPUT after opening the audio device. The open operation automatically initializes the device. The initialization being done by this call is minimal. Only the steps required to stop the recording and initialize the device for a new start will be done. When full device initialization is needed then it's recommended to close and re-open the device.

Related ioctl calls

Compatibility issues

This call is only supported by OSS 4.0 compatible drivers. The backup strategy is using the SNDCTL_DSP_RESET call instead. You need to use the latest soundcard.h version to compile programs that use SNDCTL_DSP_HALT_INPUT. This call will return EINVAL when executed under older OSS versions. }

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

ossplay.cSources for the ossplay audio player and for the ossrecord


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