5.2. Audio Function Calls

5.2.1. open()

DESCRIPTION

This system call opens a named audio device (e.g. /dev/dvb/adapter0/audio0) for subsequent use. When an open() call has succeeded, the device will be ready for use. The significance of blocking or non-blocking mode is described in the documentation for functions where there is a difference. It does not affect the semantics of the open() call itself. A device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call. This is a standard system call, documented in the Linux manual page for fcntl. Only one user can open the Audio Device in O_RDWR mode. All other attempts to open the device in this mode will fail, and an error code will be returned. If the Audio Device is opened in O_RDONLY mode, the only ioctl call that can be used is AUDIO_GET_STATUS. All other call will return with an error code.

SYNOPSIS

int open(const char ⋆deviceName, int flags);

PARAMETERS

const char *deviceName

Name of specific audio device.

int flags

A bit-wise OR of the following flags:

O_RDONLY read-only access

O_RDWR read/write access

O_NONBLOCK open in non-blocking mode

(blocking mode is the default)

ERRORS

ENODEV

Device driver not loaded/available.

EINTERNAL

Internal error.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.

5.2.2. close()

DESCRIPTION

This system call closes a previously opened audio device.

SYNOPSIS

int close(int fd);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

ERRORS

EBADF

fd is not a valid open file descriptor.

5.2.3. write()

DESCRIPTION

This system call can only be used if AUDIO_SOURCE_MEMORY is selected in the ioctl call AUDIO_SELECT_SOURCE. The data provided shall be in PES format. If O_NONBLOCK is not specified the function will block until buffer space is available. The amount of data to be transferred is implied by count.

SYNOPSIS

size_t write(int fd, const void ⋆buf, size_t count);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

void *buf

Pointer to the buffer containing the PES data.

size_t count

Size of buf.

ERRORS

EPERM

Mode AUDIO_SOURCE_MEMORY not selected.

ENOMEM

Attempted to write more data than the internal buffer can hold.

EBADF

fd is not a valid open file descriptor.

5.2.4. AUDIO_STOP

DESCRIPTION

This ioctl call asks the Audio Device to stop playing the current stream.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_STOP);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_STOP for this command.

ERRORS

EBADF

fd is not a valid open file descriptor

EINTERNAL

Internal error.

5.2.5. AUDIO_PLAY

DESCRIPTION

This ioctl call asks the Audio Device to start playing an audio stream from the selected source.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_PLAY);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_PLAY for this command.

ERRORS

EBADF

fd is not a valid open file descriptor

EINTERNAL

Internal error.

5.2.6. AUDIO_PAUSE

DESCRIPTION

This ioctl call suspends the audio stream being played. Decoding and playing are paused. It is then possible to restart again decoding and playing process of the audio stream using AUDIO_CONTINUE command.

If AUDIO_SOURCE_MEMORY is selected in the ioctl call AUDIO_SELECT_SOURCE, the DVB-subsystem will not decode (consume) any more data until the ioctl call AUDIO_CONTINUE or AUDIO_PLAY is performed.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_PAUSE);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_PAUSE for this command.

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

5.2.7. AUDIO_SELECT_SOURCE

DESCRIPTION

This ioctl call informs the audio device which source shall be used for the input data. The possible sources are demux or memory. If AUDIO_SOURCE_MEMORY is selected, the data is fed to the Audio Device through the write command.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_SELECT_SOURCE, audio_stream_source_t source);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SELECT_SOURCE for this command.

audio_stream_source_t source

Indicates the source that shall be used for the Audio stream.

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EINVAL

Illegal input parameter.

5.2.8. AUDIO_SET_MUTE

DESCRIPTION

This ioctl call asks the audio device to mute the stream that is currently being played.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_SET_MUTE, boolean state);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_MUTE for this command.

boolean state

Indicates if audio device shall mute or not.

TRUE Audio Mute

FALSE Audio Un-mute

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EINVAL

Illegal input parameter.

5.2.9. AUDIO_SET_AV_SYNC

DESCRIPTION

This ioctl call asks the Audio Device to turn ON or OFF A/V synchronization.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_SET_AV_SYNC, boolean state);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_AV_SYNC for this command.

boolean state

Tells the DVB subsystem if A/V synchronization shall be ON or OFF.

TRUE AV-sync ON

FALSE AV-sync OFF

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EINVAL

Illegal input parameter.

5.2.10. AUDIO_SET_BYPASS_MODE

DESCRIPTION

This ioctl call asks the Audio Device to bypass the Audio decoder and forward the stream without decoding. This mode shall be used if streams that can’t be handled by the DVB system shall be decoded. Dolby DigitalTM streams are automatically forwarded by the DVB subsystem if the hardware can handle it.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_SET_BYPASS_MODE, boolean mode);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_BYPASS_MODE for this command.

boolean mode

Enables or disables the decoding of the current Audio stream in the DVB subsystem.

TRUE Bypass is disabled

FALSE Bypass is enabled

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EINVAL

Illegal input parameter.

5.2.11. AUDIO_CHANNEL_SELECT

DESCRIPTION

This ioctl call asks the Audio Device to select the requested channel if possible.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_CHANNEL_SELECT, audio_channel_select_t);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_CHANNEL_SELECT for this command.

audio_channel_select_t ch

Select the output format of the audio (mono left/right, stereo).

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EINVAL

Illegal input parameter ch.

5.2.12. AUDIO_GET_STATUS

DESCRIPTION

This ioctl call asks the Audio Device to return the current state of the Audio Device.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_GET_STATUS, struct audio_status ⋆status);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_GET_STATUS for this command.

struct audio_status *status

Returns the current state of Audio Device.

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EFAULT

status points to invalid address.

5.2.13. AUDIO_GET_CAPABILITIES

DESCRIPTION

This ioctl call asks the Audio Device to tell us about the decoding capabilities of the audio hardware.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_GET_CAPABILITIES, unsigned int ⋆cap);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_GET_CAPABILITIES for this command.

unsigned int *cap

Returns a bit array of supported sound formats.

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EFAULT

cap points to an invalid address.

5.2.14. AUDIO_CLEAR_BUFFER

DESCRIPTION

This ioctl call asks the Audio Device to clear all software and hardware buffers of the audio decoder device.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_CLEAR_BUFFER);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_CLEAR_BUFFER for this command.

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

5.2.15. AUDIO_SET_ID

DESCRIPTION

This ioctl selects which sub-stream is to be decoded if a program or system stream is sent to the video device. If no audio stream type is set the id has to be in [0xC0,0xDF] for MPEG sound, in [0x80,0x87] for AC3 and in [0xA0,0xA7] for LPCM. More specifications may follow for other stream types. If the stream type is set the id just specifies the substream id of the audio stream and only the first 5 bits are recognized.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_SET_ID, int id);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_ID for this command.

int id

audio sub-stream id

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EINVAL

Invalid sub-stream id.

5.2.16. AUDIO_SET_MIXER

DESCRIPTION

This ioctl lets you adjust the mixer settings of the audio decoder.

SYNOPSIS

int ioctl(int fd, int request = AUDIO_SET_MIXER, audio_mixer_t ⋆mix);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_ID for this command.

audio_mixer_t *mix

mixer settings.

ERRORS

EBADF

fd is not a valid open file descriptor.

EINTERNAL

Internal error.

EFAULT

mix points to an invalid address.

5.2.17. AUDIO_SET_STREAMTYPE

DESCRIPTION

This ioctl tells the driver which kind of audio stream to expect. This is useful if the stream offers several audio sub-streams like LPCM and AC3.

SYNOPSIS

int ioctl(fd, int request = AUDIO_SET_STREAMTYPE, int type);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_STREAMTYPE for this command.

int type

stream type

ERRORS

EBADF

fd is not a valid open file descriptor

EINVAL

type is not a valid or supported stream type.

5.2.18. AUDIO_SET_EXT_ID

DESCRIPTION

This ioctl can be used to set the extension id for MPEG streams in DVD playback. Only the first 3 bits are recognized.

SYNOPSIS

int ioctl(fd, int request = AUDIO_SET_EXT_ID, int id);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_EXT_ID for this command.

int id

audio sub_stream_id

ERRORS

EBADF

fd is not a valid open file descriptor

EINVAL

id is not a valid id.

5.2.19. AUDIO_SET_ATTRIBUTES

DESCRIPTION

This ioctl is intended for DVD playback and allows you to set certain information about the audio stream.

SYNOPSIS

int ioctl(fd, int request = AUDIO_SET_ATTRIBUTES, audio_attributes_t attr );

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_ATTRIBUTES for this command.

audio_attributes_t attr

audio attributes according to section ??

ERRORS

EBADF

fd is not a valid open file descriptor

EINVAL

attr is not a valid or supported attribute setting.

5.2.20. AUDIO_SET_KARAOKE

DESCRIPTION

This ioctl allows one to set the mixer settings for a karaoke DVD.

SYNOPSIS

int ioctl(fd, int request = AUDIO_SET_STREAMTYPE, audio_karaoke_t ⋆karaoke);

PARAMETERS

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_STREAMTYPE for this command.

audio_karaoke_t *karaoke

karaoke settings according to section ??.

ERRORS

EBADF

fd is not a valid open file descriptor

EINVAL

karaoke is not a valid or supported karaoke setting.