1 .. -*- coding: utf-8; mode: rst -*-
3 .. _audio_function_calls:
18 This system call opens a named audio device (e.g.
19 /dev/dvb/adapter0/audio0) for subsequent use. When an open() call has
20 succeeded, the device will be ready for use. The significance of
21 blocking or non-blocking mode is described in the documentation for
22 functions where there is a difference. It does not affect the semantics
23 of the open() call itself. A device opened in blocking mode can later be
24 put into non-blocking mode (and vice versa) using the F_SETFL command
25 of the fcntl system call. This is a standard system call, documented in
26 the Linux manual page for fcntl. Only one user can open the Audio Device
27 in O_RDWR mode. All other attempts to open the device in this mode will
28 fail, and an error code will be returned. If the Audio Device is opened
29 in O_RDONLY mode, the only ioctl call that can be used is
30 AUDIO_GET_STATUS. All other call will return with an error code.
35 .. c:function:: int open(const char *deviceName, int flags)
49 - const char \*deviceName
51 - Name of specific audio device.
57 - A bit-wise OR of the following flags:
62 - O_RDONLY read-only access
67 - O_RDWR read/write access
72 - O_NONBLOCK open in non-blocking mode
77 - (blocking mode is the default)
94 - Device driver not loaded/available.
100 - Device or resource busy.
118 This system call closes a previously opened audio device.
123 .. c:function:: int close(int fd)
139 - File descriptor returned by a previous call to open().
156 - fd is not a valid open file descriptor.
168 This system call can only be used if AUDIO_SOURCE_MEMORY is selected
169 in the ioctl call AUDIO_SELECT_SOURCE. The data provided shall be in
170 PES format. If O_NONBLOCK is not specified the function will block
171 until buffer space is available. The amount of data to be transferred is
177 .. c:function:: size_t write(int fd, const void *buf, size_t count)
193 - File descriptor returned by a previous call to open().
199 - Pointer to the buffer containing the PES data.
222 - Mode AUDIO_SOURCE_MEMORY not selected.
228 - Attempted to write more data than the internal buffer can hold.
234 - fd is not a valid open file descriptor.
246 This ioctl call asks the Audio Device to stop playing the current
252 .. c:function:: int ioctl(int fd, int request = AUDIO_STOP)
268 - File descriptor returned by a previous call to open().
274 - Equals AUDIO_STOP for this command.
280 On success 0 is returned, on error -1 and the ``errno`` variable is set
281 appropriately. The generic error codes are described at the
282 :ref:`Generic Error Codes <gen-errors>` chapter.
293 This ioctl call asks the Audio Device to start playing an audio stream
294 from the selected source.
299 .. c:function:: int ioctl(int fd, int request = AUDIO_PLAY)
315 - File descriptor returned by a previous call to open().
321 - Equals AUDIO_PLAY for this command.
327 On success 0 is returned, on error -1 and the ``errno`` variable is set
328 appropriately. The generic error codes are described at the
329 :ref:`Generic Error Codes <gen-errors>` chapter.
340 This ioctl call suspends the audio stream being played. Decoding and
341 playing are paused. It is then possible to restart again decoding and
342 playing process of the audio stream using AUDIO_CONTINUE command.
347 .. c:function:: int ioctl(int fd, int request = AUDIO_PAUSE)
363 - File descriptor returned by a previous call to open().
369 - Equals AUDIO_PAUSE for this command.
375 On success 0 is returned, on error -1 and the ``errno`` variable is set
376 appropriately. The generic error codes are described at the
377 :ref:`Generic Error Codes <gen-errors>` chapter.
388 This ioctl restarts the decoding and playing process previously paused
389 with AUDIO_PAUSE command.
394 .. c:function:: int ioctl(int fd, int request = AUDIO_CONTINUE)
410 - File descriptor returned by a previous call to open().
416 - Equals AUDIO_CONTINUE for this command.
422 On success 0 is returned, on error -1 and the ``errno`` variable is set
423 appropriately. The generic error codes are described at the
424 :ref:`Generic Error Codes <gen-errors>` chapter.
427 .. _AUDIO_SELECT_SOURCE:
435 This ioctl call informs the audio device which source shall be used for
436 the input data. The possible sources are demux or memory. If
437 AUDIO_SOURCE_MEMORY is selected, the data is fed to the Audio Device
438 through the write command.
443 .. c:function:: int ioctl(int fd, int request = AUDIO_SELECT_SOURCE, audio_stream_source_t source)
459 - File descriptor returned by a previous call to open().
465 - Equals AUDIO_SELECT_SOURCE for this command.
469 - audio_stream_source_t source
471 - Indicates the source that shall be used for the Audio stream.
477 On success 0 is returned, on error -1 and the ``errno`` variable is set
478 appropriately. The generic error codes are described at the
479 :ref:`Generic Error Codes <gen-errors>` chapter.
490 This ioctl is for DVB devices only. To control a V4L2 decoder use the
491 V4L2 :ref:`VIDIOC_DECODER_CMD` with the
492 ``V4L2_DEC_CMD_START_MUTE_AUDIO`` flag instead.
494 This ioctl call asks the audio device to mute the stream that is
495 currently being played.
500 .. c:function:: int ioctl(int fd, int request = AUDIO_SET_MUTE, boolean state)
516 - File descriptor returned by a previous call to open().
522 - Equals AUDIO_SET_MUTE for this command.
528 - Indicates if audio device shall mute or not.
538 - FALSE Audio Un-mute
544 On success 0 is returned, on error -1 and the ``errno`` variable is set
545 appropriately. The generic error codes are described at the
546 :ref:`Generic Error Codes <gen-errors>` chapter.
549 .. _AUDIO_SET_AV_SYNC:
557 This ioctl call asks the Audio Device to turn ON or OFF A/V
563 .. c:function:: int ioctl(int fd, int request = AUDIO_SET_AV_SYNC, boolean state)
579 - File descriptor returned by a previous call to open().
585 - Equals AUDIO_AV_SYNC for this command.
591 - Tells the DVB subsystem if A/V synchronization shall be ON or OFF.
607 On success 0 is returned, on error -1 and the ``errno`` variable is set
608 appropriately. The generic error codes are described at the
609 :ref:`Generic Error Codes <gen-errors>` chapter.
612 .. _AUDIO_SET_BYPASS_MODE:
614 AUDIO_SET_BYPASS_MODE
615 =====================
620 This ioctl call asks the Audio Device to bypass the Audio decoder and
621 forward the stream without decoding. This mode shall be used if streams
622 that can’t be handled by the DVB system shall be decoded. Dolby
623 DigitalTM streams are automatically forwarded by the DVB subsystem if
624 the hardware can handle it.
629 .. c:function:: int ioctl(int fd, int request = AUDIO_SET_BYPASS_MODE, boolean mode)
645 - File descriptor returned by a previous call to open().
651 - Equals AUDIO_SET_BYPASS_MODE for this command.
657 - Enables or disables the decoding of the current Audio stream in
663 - TRUE Bypass is disabled
668 - FALSE Bypass is enabled
674 On success 0 is returned, on error -1 and the ``errno`` variable is set
675 appropriately. The generic error codes are described at the
676 :ref:`Generic Error Codes <gen-errors>` chapter.
679 .. _AUDIO_CHANNEL_SELECT:
687 This ioctl is for DVB devices only. To control a V4L2 decoder use the
688 V4L2 ``V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK`` control instead.
690 This ioctl call asks the Audio Device to select the requested channel if
696 .. c:function:: int ioctl(int fd, int request = AUDIO_CHANNEL_SELECT, audio_channel_select_t)
712 - File descriptor returned by a previous call to open().
718 - Equals AUDIO_CHANNEL_SELECT for this command.
722 - audio_channel_select_t ch
724 - Select the output format of the audio (mono left/right, stereo).
730 On success 0 is returned, on error -1 and the ``errno`` variable is set
731 appropriately. The generic error codes are described at the
732 :ref:`Generic Error Codes <gen-errors>` chapter.
735 .. _AUDIO_BILINGUAL_CHANNEL_SELECT:
737 AUDIO_BILINGUAL_CHANNEL_SELECT
738 ==============================
743 This ioctl is obsolete. Do not use in new drivers. It has been replaced
744 by the V4L2 ``V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK`` control
745 for MPEG decoders controlled through V4L2.
747 This ioctl call asks the Audio Device to select the requested channel
748 for bilingual streams if possible.
753 .. c:function:: int ioctl(int fd, int request = AUDIO_BILINGUAL_CHANNEL_SELECT, audio_channel_select_t)
769 - File descriptor returned by a previous call to open().
775 - Equals AUDIO_BILINGUAL_CHANNEL_SELECT for this command.
779 - audio_channel_select_t ch
781 - Select the output format of the audio (mono left/right, stereo).
787 On success 0 is returned, on error -1 and the ``errno`` variable is set
788 appropriately. The generic error codes are described at the
789 :ref:`Generic Error Codes <gen-errors>` chapter.
800 This ioctl is obsolete. Do not use in new drivers. If you need this
801 functionality, then please contact the linux-media mailing list
802 (`https://linuxtv.org/lists.php <https://linuxtv.org/lists.php>`__).
804 This ioctl call asks the Audio Device to return the current PTS
810 .. c:function:: int ioctl(int fd, int request = AUDIO_GET_PTS, __u64 *pts)
826 - File descriptor returned by a previous call to open().
832 - Equals AUDIO_GET_PTS for this command.
838 - Returns the 33-bit timestamp as defined in ITU T-REC-H.222.0 /
841 The PTS should belong to the currently played frame if possible,
842 but may also be a value close to it like the PTS of the last
843 decoded frame or the last PTS extracted by the PES parser.
849 On success 0 is returned, on error -1 and the ``errno`` variable is set
850 appropriately. The generic error codes are described at the
851 :ref:`Generic Error Codes <gen-errors>` chapter.
854 .. _AUDIO_GET_STATUS:
862 This ioctl call asks the Audio Device to return the current state of the
868 .. c:function:: int ioctl(int fd, int request = AUDIO_GET_STATUS, struct audio_status *status)
884 - File descriptor returned by a previous call to open().
890 - Equals AUDIO_GET_STATUS for this command.
894 - struct audio_status \*status
896 - Returns the current state of Audio Device.
902 On success 0 is returned, on error -1 and the ``errno`` variable is set
903 appropriately. The generic error codes are described at the
904 :ref:`Generic Error Codes <gen-errors>` chapter.
907 .. _AUDIO_GET_CAPABILITIES:
909 AUDIO_GET_CAPABILITIES
910 ======================
915 This ioctl call asks the Audio Device to tell us about the decoding
916 capabilities of the audio hardware.
921 .. c:function:: int ioctl(int fd, int request = AUDIO_GET_CAPABILITIES, unsigned int *cap)
937 - File descriptor returned by a previous call to open().
943 - Equals AUDIO_GET_CAPABILITIES for this command.
949 - Returns a bit array of supported sound formats.
955 On success 0 is returned, on error -1 and the ``errno`` variable is set
956 appropriately. The generic error codes are described at the
957 :ref:`Generic Error Codes <gen-errors>` chapter.
960 .. _AUDIO_CLEAR_BUFFER:
968 This ioctl call asks the Audio Device to clear all software and hardware
969 buffers of the audio decoder device.
974 .. c:function:: int ioctl(int fd, int request = AUDIO_CLEAR_BUFFER)
990 - File descriptor returned by a previous call to open().
996 - Equals AUDIO_CLEAR_BUFFER for this command.
1002 On success 0 is returned, on error -1 and the ``errno`` variable is set
1003 appropriately. The generic error codes are described at the
1004 :ref:`Generic Error Codes <gen-errors>` chapter.
1015 This ioctl selects which sub-stream is to be decoded if a program or
1016 system stream is sent to the video device. If no audio stream type is
1017 set the id has to be in [0xC0,0xDF] for MPEG sound, in [0x80,0x87] for
1018 AC3 and in [0xA0,0xA7] for LPCM. More specifications may follow for
1019 other stream types. If the stream type is set the id just specifies the
1020 substream id of the audio stream and only the first 5 bits are
1026 .. c:function:: int ioctl(int fd, int request = AUDIO_SET_ID, int id)
1042 - File descriptor returned by a previous call to open().
1048 - Equals AUDIO_SET_ID for this command.
1054 - audio sub-stream id
1060 On success 0 is returned, on error -1 and the ``errno`` variable is set
1061 appropriately. The generic error codes are described at the
1062 :ref:`Generic Error Codes <gen-errors>` chapter.
1065 .. _AUDIO_SET_MIXER:
1073 This ioctl lets you adjust the mixer settings of the audio decoder.
1078 .. c:function:: int ioctl(int fd, int request = AUDIO_SET_MIXER, audio_mixer_t *mix)
1094 - File descriptor returned by a previous call to open().
1100 - Equals AUDIO_SET_ID for this command.
1104 - audio_mixer_t \*mix
1112 On success 0 is returned, on error -1 and the ``errno`` variable is set
1113 appropriately. The generic error codes are described at the
1114 :ref:`Generic Error Codes <gen-errors>` chapter.
1117 .. _AUDIO_SET_STREAMTYPE:
1119 AUDIO_SET_STREAMTYPE
1120 ====================
1125 This ioctl tells the driver which kind of audio stream to expect. This
1126 is useful if the stream offers several audio sub-streams like LPCM and
1132 .. c:function:: int ioctl(fd, int request = AUDIO_SET_STREAMTYPE, int type)
1148 - File descriptor returned by a previous call to open().
1154 - Equals AUDIO_SET_STREAMTYPE for this command.
1166 On success 0 is returned, on error -1 and the ``errno`` variable is set
1167 appropriately. The generic error codes are described at the
1168 :ref:`Generic Error Codes <gen-errors>` chapter.
1181 - type is not a valid or supported stream type.
1185 .. _AUDIO_SET_EXT_ID:
1193 This ioctl can be used to set the extension id for MPEG streams in DVD
1194 playback. Only the first 3 bits are recognized.
1199 .. c:function:: int ioctl(fd, int request = AUDIO_SET_EXT_ID, int id)
1215 - File descriptor returned by a previous call to open().
1221 - Equals AUDIO_SET_EXT_ID for this command.
1227 - audio sub_stream_id
1233 On success 0 is returned, on error -1 and the ``errno`` variable is set
1234 appropriately. The generic error codes are described at the
1235 :ref:`Generic Error Codes <gen-errors>` chapter.
1248 - id is not a valid id.
1252 .. _AUDIO_SET_ATTRIBUTES:
1254 AUDIO_SET_ATTRIBUTES
1255 ====================
1260 This ioctl is intended for DVD playback and allows you to set certain
1261 information about the audio stream.
1266 .. c:function:: int ioctl(fd, int request = AUDIO_SET_ATTRIBUTES, audio_attributes_t attr )
1282 - File descriptor returned by a previous call to open().
1288 - Equals AUDIO_SET_ATTRIBUTES for this command.
1292 - audio_attributes_t attr
1294 - audio attributes according to section ??
1300 On success 0 is returned, on error -1 and the ``errno`` variable is set
1301 appropriately. The generic error codes are described at the
1302 :ref:`Generic Error Codes <gen-errors>` chapter.
1315 - attr is not a valid or supported attribute setting.
1319 .. _AUDIO_SET_KARAOKE:
1327 This ioctl allows one to set the mixer settings for a karaoke DVD.
1332 .. c:function:: int ioctl(fd, int request = AUDIO_SET_KARAOKE, audio_karaoke_t *karaoke)
1348 - File descriptor returned by a previous call to open().
1354 - Equals AUDIO_SET_KARAOKE for this command.
1358 - audio_karaoke_t \*karaoke
1360 - karaoke settings according to section ??.
1366 On success 0 is returned, on error -1 and the ``errno`` variable is set
1367 appropriately. The generic error codes are described at the
1368 :ref:`Generic Error Codes <gen-errors>` chapter.
1381 - karaoke is not a valid or supported karaoke setting.