1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter 12. DVB Audio Device</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="dvbapi.html" title="Part II. LINUX DVB API"><link rel="prev" href="video_function_calls.html" title="Video Function Calls"><link rel="next" href="audio_function_calls.html" title="Audio Function Calls"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 12. DVB Audio Device</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="video_function_calls.html">Prev</a> </td><th width="60%" align="center">Part II. LINUX DVB API</th><td width="20%" align="right"> <a accesskey="n" href="audio_function_calls.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="dvb_audio"></a>Chapter 12. DVB Audio Device</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="dvb_audio.html#audio_data_types">Audio Data Types</a></span></dt><dd><dl><dt><span class="section"><a href="dvb_audio.html#audio-stream-source-t">audio_stream_source_t</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-play-state-t">audio_play_state_t</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-channel-select-t">audio_channel_select_t</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-status">struct audio_status</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-mixer">struct audio_mixer</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio_encodings">audio encodings</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-karaoke">struct audio_karaoke</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-attributes-t">audio attributes</a></span></dt></dl></dd><dt><span class="section"><a href="audio_function_calls.html">Audio Function Calls</a></span></dt><dd><dl><dt><span class="section"><a href="audio_function_calls.html#audio_fopen">open()</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#audio_fclose">close()</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#audio_fwrite">write()</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_STOP">AUDIO_STOP</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_PLAY">AUDIO_PLAY</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_PAUSE">AUDIO_PAUSE</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_CONTINUE">AUDIO_CONTINUE</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SELECT_SOURCE">AUDIO_SELECT_SOURCE</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_MUTE">AUDIO_SET_MUTE</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_AV_SYNC">AUDIO_SET_AV_SYNC</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_BYPASS_MODE">AUDIO_SET_BYPASS_MODE</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_CHANNEL_SELECT">AUDIO_CHANNEL_SELECT</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_BILINGUAL_CHANNEL_SELECT">AUDIO_BILINGUAL_CHANNEL_SELECT</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_GET_PTS">AUDIO_GET_PTS</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_GET_STATUS">AUDIO_GET_STATUS</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_GET_CAPABILITIES">AUDIO_GET_CAPABILITIES</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_CLEAR_BUFFER">AUDIO_CLEAR_BUFFER</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_ID">AUDIO_SET_ID</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_MIXER">AUDIO_SET_MIXER</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_STREAMTYPE">AUDIO_SET_STREAMTYPE</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_EXT_ID">AUDIO_SET_EXT_ID</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_ATTRIBUTES">AUDIO_SET_ATTRIBUTES</a></span></dt><dt><span class="section"><a href="audio_function_calls.html#AUDIO_SET_KARAOKE">AUDIO_SET_KARAOKE</a></span></dt></dl></dd></dl></div><p>The DVB audio device controls the MPEG2 audio decoder of the DVB hardware. It 2can be accessed through <span class="tt">/dev/dvb/adapter0/audio0</span>. Data types and and 3ioctl definitions can be accessed by including <span class="tt">linux/dvb/audio.h</span> in your 4application. 5</p><p>Please note that some DVB cards don’t have their own MPEG decoder, which results in 6the omission of the audio and video device. 7</p><p> 8These ioctls were also used by V4L2 to control MPEG decoders implemented in V4L2. The use 9of these ioctls for that purpose has been made obsolete and proper V4L2 ioctls or controls 10have been created to replace that functionality.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="audio_data_types"></a>Audio Data Types</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="dvb_audio.html#audio-stream-source-t">audio_stream_source_t</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-play-state-t">audio_play_state_t</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-channel-select-t">audio_channel_select_t</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-status">struct audio_status</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-mixer">struct audio_mixer</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio_encodings">audio encodings</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-karaoke">struct audio_karaoke</a></span></dt><dt><span class="section"><a href="dvb_audio.html#audio-attributes-t">audio attributes</a></span></dt></dl></div><p>This section describes the structures, data types and defines used when talking to the 11audio device. 12</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-stream-source-t"></a>audio_stream_source_t</h3></div></div></div><p>The audio stream source is set through the AUDIO_SELECT_SOURCE call and can take 13the following values, depending on whether we are replaying from an internal (demux) or 14external (user write) source. 15</p><pre class="programlisting"> 16typedef enum { 17 AUDIO_SOURCE_DEMUX, 18 AUDIO_SOURCE_MEMORY 19} audio_stream_source_t; 20</pre><p>AUDIO_SOURCE_DEMUX selects the demultiplexer (fed either by the frontend or the 21DVR device) as the source of the video stream. If AUDIO_SOURCE_MEMORY 22is selected the stream comes from the application through the <span class="tt">write()</span> system 23call. 24</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-play-state-t"></a>audio_play_state_t</h3></div></div></div><p>The following values can be returned by the AUDIO_GET_STATUS call representing the 25state of audio playback. 26</p><pre class="programlisting"> 27typedef enum { 28 AUDIO_STOPPED, 29 AUDIO_PLAYING, 30 AUDIO_PAUSED 31} audio_play_state_t; 32</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-channel-select-t"></a>audio_channel_select_t</h3></div></div></div><p>The audio channel selected via AUDIO_CHANNEL_SELECT is determined by the 33following values. 34</p><pre class="programlisting"> 35typedef enum { 36 AUDIO_STEREO, 37 AUDIO_MONO_LEFT, 38 AUDIO_MONO_RIGHT, 39 AUDIO_MONO, 40 AUDIO_STEREO_SWAPPED 41} audio_channel_select_t; 42</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-status"></a>struct audio_status</h3></div></div></div><p>The AUDIO_GET_STATUS call returns the following structure informing about various 43states of the playback operation. 44</p><pre class="programlisting"> 45typedef struct audio_status { 46 boolean AV_sync_state; 47 boolean mute_state; 48 audio_play_state_t play_state; 49 audio_stream_source_t stream_source; 50 audio_channel_select_t channel_select; 51 boolean bypass_mode; 52 audio_mixer_t mixer_state; 53} audio_status_t; 54</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-mixer"></a>struct audio_mixer</h3></div></div></div><p>The following structure is used by the AUDIO_SET_MIXER call to set the audio 55volume. 56</p><pre class="programlisting"> 57typedef struct audio_mixer { 58 unsigned int volume_left; 59 unsigned int volume_right; 60} audio_mixer_t; 61</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio_encodings"></a>audio encodings</h3></div></div></div><p>A call to AUDIO_GET_CAPABILITIES returns an unsigned integer with the following 62bits set according to the hardwares capabilities. 63</p><pre class="programlisting"> 64 #define AUDIO_CAP_DTS 1 65 #define AUDIO_CAP_LPCM 2 66 #define AUDIO_CAP_MP1 4 67 #define AUDIO_CAP_MP2 8 68 #define AUDIO_CAP_MP3 16 69 #define AUDIO_CAP_AAC 32 70 #define AUDIO_CAP_OGG 64 71 #define AUDIO_CAP_SDDS 128 72 #define AUDIO_CAP_AC3 256 73</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-karaoke"></a>struct audio_karaoke</h3></div></div></div><p>The ioctl AUDIO_SET_KARAOKE uses the following format: 74</p><pre class="programlisting"> 75typedef 76struct audio_karaoke { 77 int vocal1; 78 int vocal2; 79 int melody; 80} audio_karaoke_t; 81</pre><p>If Vocal1 or Vocal2 are non-zero, they get mixed into left and right t at 70% each. If both, 82Vocal1 and Vocal2 are non-zero, Vocal1 gets mixed into the left channel and Vocal2 into the 83right channel at 100% each. Ff Melody is non-zero, the melody channel gets mixed into left 84and right. 85</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="audio-attributes-t"></a>audio attributes</h3></div></div></div><p>The following attributes can be set by a call to AUDIO_SET_ATTRIBUTES: 86</p><pre class="programlisting"> 87 typedef uint16_t audio_attributes_t; 88 /⋆ bits: descr. ⋆/ 89 /⋆ 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, ⋆/ 90 /⋆ 12 multichannel extension ⋆/ 91 /⋆ 11-10 audio type (0=not spec, 1=language included) ⋆/ 92 /⋆ 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) ⋆/ 93 /⋆ 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, ⋆/ 94 /⋆ 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) ⋆/ 95 /⋆ 2- 0 number of audio channels (n+1 channels) ⋆/ 96</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="video_function_calls.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dvbapi.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="audio_function_calls.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Video Function Calls </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Audio Function Calls</td></tr></table></div></body></html> 97