Technical data
SunOS 5.5 Ioctl Requests audio(7I)
AUDIO_SETINFO
The argument is a pointer to an audio_info structure. This command may be
issued for either the /dev/audio or the /dev/audioctl device with some restric-
tions. This command configures the audio device according to the structure sup-
plied and overwrites the structure with the new state of the device. Note: The
play.samples, record.samples, play.error, record.error, and play.eof fields are modified
to reflect the state of the device when the AUDIO_SETINFO was issued. This
allows programs to automatically modify these fields while retrievingthe previ-
ous value.
Certain fields in the information structure, such as the pause flags are treated as
read-only when /dev/audio is not open with the corresponding access permis-
sion. Other fields, such as the gain levels and encoding information, may have a
restricted set of acceptable values. Applications that attempt to modify such
fields should check the returned values to be sure that the corresponding change
took effect. The sample_rate, channels, precision, and encoding fields treated as
read-only for /dev/audioctl, so that applications can be guaranteed that the exist-
ing audio format will stay in place until they relinquish the audio device.
AUDIO_SETINFO will return EINVAL when the desired configuration is not pos-
sible, or EBUSY when another process has control of the audio device.
Once set, the following values persist through subsequent open() and close()
calls of the device: play.gain, record.gain, play.balance, record.balance, output_muted,
monitor_gain, play.port, and record.port. However, an automatic device driver
unload will reset these parameters to their default values on the next load. All
other state is reset when the corresponding I/O stream of /dev/audio is closed.
The audio_info structure may be initializedthrough the use of the
AUDIO_INITINFO macro. This macro sets all fields in the structure to values that
are ignored by theAUDIO_SETINFO command. For instance, the following code
switches the output port from the built-in speaker to the headphone jack without
modifying any other audio parameters:
audio_info_tinfo;
AUDIO_INITINFO(&info);
info.play.port = AUDIO_HEADPHONE;
err = ioctl(audio_fd, AUDIO_SETINFO, &info);
This technique eliminates problems associated with using a sequence of
AUDIO_GETINFO followed by AUDIO_SETINFO.
ERRORS An open() will fail if:
EBUSY The requested play or record access is busy and either the O_NDELAY or
O_NONBLOCK flag was set in the open() request.
EINTR The requested play or record access is busy and a signal interrupted the
open() request.
modified 21 Mar 1995 7I-31










