Home | History | Annotate | Download | only in spec
      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
      2 <HTML
      3 ><HEAD
      4 ><TITLE
      5 >Audio Inputs and Outputs</TITLE
      6 ><META
      7 NAME="GENERATOR"
      8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
      9 REL="HOME"
     10 TITLE="Video for Linux Two API Specification"
     11 HREF="book1.htm"><LINK
     12 REL="UP"
     13 TITLE="Common API Elements"
     14 HREF="c174.htm"><LINK
     15 REL="PREVIOUS"
     16 TITLE="Video Inputs and Outputs"
     17 HREF="x309.htm"><LINK
     18 REL="NEXT"
     19 TITLE="Tuners and Modulators"
     20 HREF="x394.htm"></HEAD
     21 ><BODY
     22 CLASS="SECTION"
     23 BGCOLOR="#FFFFFF"
     24 TEXT="#000000"
     25 LINK="#0000FF"
     26 VLINK="#840084"
     27 ALINK="#0000FF"
     28 ><DIV
     29 CLASS="NAVHEADER"
     30 ><TABLE
     31 SUMMARY="Header navigation table"
     32 WIDTH="100%"
     33 BORDER="0"
     34 CELLPADDING="0"
     35 CELLSPACING="0"
     36 ><TR
     37 ><TH
     38 COLSPAN="3"
     39 ALIGN="center"
     40 >Video for Linux Two API Specification: Revision 0.24</TH
     41 ></TR
     42 ><TR
     43 ><TD
     44 WIDTH="10%"
     45 ALIGN="left"
     46 VALIGN="bottom"
     47 ><A
     48 HREF="x309.htm"
     49 ACCESSKEY="P"
     50 >Prev</A
     51 ></TD
     52 ><TD
     53 WIDTH="80%"
     54 ALIGN="center"
     55 VALIGN="bottom"
     56 >Chapter 1. Common API Elements</TD
     57 ><TD
     58 WIDTH="10%"
     59 ALIGN="right"
     60 VALIGN="bottom"
     61 ><A
     62 HREF="x394.htm"
     63 ACCESSKEY="N"
     64 >Next</A
     65 ></TD
     66 ></TR
     67 ></TABLE
     68 ><HR
     69 ALIGN="LEFT"
     70 WIDTH="100%"></DIV
     71 ><DIV
     72 CLASS="SECTION"
     73 ><H1
     74 CLASS="SECTION"
     75 ><A
     76 NAME="AUDIO"
     77 >1.5. Audio Inputs and Outputs</A
     78 ></H1
     79 ><P
     80 >Audio inputs and outputs are physical connectors of a
     81 device. Video capture devices have inputs, output devices have
     82 outputs, zero or more each. Radio devices have no audio inputs or
     83 outputs. They have exactly one tuner which in fact
     84 <SPAN
     85 CLASS="emphasis"
     86 ><I
     87 CLASS="EMPHASIS"
     88 >is</I
     89 ></SPAN
     90 > an audio source, but this API associates
     91 tuners with video inputs or outputs only, and radio devices have
     92 none of these.<A
     93 NAME="AEN345"
     94 HREF="x341.htm#FTN.AEN345"
     95 ><SPAN
     96 CLASS="footnote"
     97 >[1]</SPAN
     98 ></A
     99 > A connector on a TV card to loop back the received
    100 audio signal to a sound card is not considered an audio output.</P
    101 ><P
    102 >Audio and video inputs and outputs are associated. Selecting
    103 a video source also selects an audio source. This is most evident when
    104 the video and audio source is a tuner. Further audio connectors can
    105 combine with more than one video input or output. Assumed two
    106 composite video inputs and two audio inputs exist, there may be up to
    107 four valid combinations. The relation of video and audio connectors
    108 is defined in the <CODE
    109 CLASS="STRUCTFIELD"
    110 >audioset</CODE
    111 > field of the
    112 respective struct&nbsp;<A
    113 HREF="r8936.htm#V4L2-INPUT"
    114 >v4l2_input</A
    115 > or struct&nbsp;<A
    116 HREF="r9149.htm#V4L2-OUTPUT"
    117 >v4l2_output</A
    118 >, where each bit represents
    119 the index number, starting at zero, of one audio input or output.</P
    120 ><P
    121 >To learn about the number and attributes of the
    122 available inputs and outputs applications can enumerate them with the
    123 <A
    124 HREF="r8242.htm"
    125 ><CODE
    126 CLASS="CONSTANT"
    127 >VIDIOC_ENUMAUDIO</CODE
    128 ></A
    129 > and <A
    130 HREF="r8304.htm"
    131 ><CODE
    132 CLASS="CONSTANT"
    133 >VIDIOC_ENUMAUDOUT</CODE
    134 ></A
    135 > ioctl, respectively. The
    136 struct&nbsp;<A
    137 HREF="r9539.htm#V4L2-AUDIO"
    138 >v4l2_audio</A
    139 > returned by the <CODE
    140 CLASS="CONSTANT"
    141 >VIDIOC_ENUMAUDIO</CODE
    142 > ioctl
    143 also contains signal status information applicable when the current
    144 audio input is queried.</P
    145 ><P
    146 >The <A
    147 HREF="r9539.htm"
    148 ><CODE
    149 CLASS="CONSTANT"
    150 >VIDIOC_G_AUDIO</CODE
    151 ></A
    152 > and <A
    153 HREF="r9688.htm"
    154 ><CODE
    155 CLASS="CONSTANT"
    156 >VIDIOC_G_AUDOUT</CODE
    157 ></A
    158 > ioctl report
    159 the current audio input and output, respectively. Note that, unlike
    160 <A
    161 HREF="r11217.htm"
    162 ><CODE
    163 CLASS="CONSTANT"
    164 >VIDIOC_G_INPUT</CODE
    165 ></A
    166 > and <A
    167 HREF="r11612.htm"
    168 ><CODE
    169 CLASS="CONSTANT"
    170 >VIDIOC_G_OUTPUT</CODE
    171 ></A
    172 > these ioctls return a structure
    173 as <CODE
    174 CLASS="CONSTANT"
    175 >VIDIOC_ENUMAUDIO</CODE
    176 > and
    177 <CODE
    178 CLASS="CONSTANT"
    179 >VIDIOC_ENUMAUDOUT</CODE
    180 > do, not just an index.</P
    181 ><P
    182 >To select an audio input and change its properties
    183 applications call the <A
    184 HREF="r9539.htm"
    185 ><CODE
    186 CLASS="CONSTANT"
    187 >VIDIOC_S_AUDIO</CODE
    188 ></A
    189 > ioctl. To select an audio
    190 output (which presently has no changeable properties) applications
    191 call the <A
    192 HREF="r9688.htm"
    193 ><CODE
    194 CLASS="CONSTANT"
    195 >VIDIOC_S_AUDOUT</CODE
    196 ></A
    197 > ioctl.</P
    198 ><P
    199 >Drivers must implement all input ioctls when the device
    200 has one or more inputs, all output ioctls when the device has one
    201 or more outputs. When the device has any audio inputs or outputs the
    202 driver must set the <CODE
    203 CLASS="CONSTANT"
    204 >V4L2_CAP_AUDIO</CODE
    205 > flag in the
    206 struct&nbsp;<A
    207 HREF="r13105.htm#V4L2-CAPABILITY"
    208 >v4l2_capability</A
    209 > returned by the <A
    210 HREF="r13105.htm"
    211 ><CODE
    212 CLASS="CONSTANT"
    213 >VIDIOC_QUERYCAP</CODE
    214 ></A
    215 > ioctl.</P
    216 ><DIV
    217 CLASS="EXAMPLE"
    218 ><A
    219 NAME="AEN382"
    220 ></A
    221 ><P
    222 ><B
    223 >Example 1-3. Information about the current audio input</B
    224 ></P
    225 ><PRE
    226 CLASS="PROGRAMLISTING"
    227 >struct&nbsp;<A
    228 HREF="r9539.htm#V4L2-AUDIO"
    229 >v4l2_audio</A
    230 > audio;
    231 
    232 memset (&amp;audio, 0, sizeof (audio));
    233 
    234 if (-1 == ioctl (fd, <A
    235 HREF="r9539.htm"
    236 ><CODE
    237 CLASS="CONSTANT"
    238 >VIDIOC_G_AUDIO</CODE
    239 ></A
    240 >, &amp;audio)) {
    241         perror ("VIDIOC_G_AUDIO");
    242         exit (EXIT_FAILURE);
    243 }
    244 
    245 printf ("Current input: %s\n", audio.name);
    246       </PRE
    247 ></DIV
    248 ><DIV
    249 CLASS="EXAMPLE"
    250 ><A
    251 NAME="AEN388"
    252 ></A
    253 ><P
    254 ><B
    255 >Example 1-4. Switching to the first audio input</B
    256 ></P
    257 ><PRE
    258 CLASS="PROGRAMLISTING"
    259 >struct&nbsp;<A
    260 HREF="r9539.htm#V4L2-AUDIO"
    261 >v4l2_audio</A
    262 > audio;
    263 
    264 memset (&amp;audio, 0, sizeof (audio)); /* clear audio.mode, audio.reserved */
    265 
    266 audio.index = 0;
    267 
    268 if (-1 == ioctl (fd, <A
    269 HREF="r9539.htm"
    270 ><CODE
    271 CLASS="CONSTANT"
    272 >VIDIOC_S_AUDIO</CODE
    273 ></A
    274 >, &amp;audio)) {
    275         perror ("VIDIOC_S_AUDIO");
    276         exit (EXIT_FAILURE);
    277 }
    278       </PRE
    279 ></DIV
    280 ></DIV
    281 ><H3
    282 CLASS="FOOTNOTES"
    283 >Notes</H3
    284 ><TABLE
    285 BORDER="0"
    286 CLASS="FOOTNOTES"
    287 WIDTH="100%"
    288 ><TR
    289 ><TD
    290 ALIGN="LEFT"
    291 VALIGN="TOP"
    292 WIDTH="5%"
    293 ><A
    294 NAME="FTN.AEN345"
    295 HREF="x341.htm#AEN345"
    296 ><SPAN
    297 CLASS="footnote"
    298 >[1]</SPAN
    299 ></A
    300 ></TD
    301 ><TD
    302 ALIGN="LEFT"
    303 VALIGN="TOP"
    304 WIDTH="95%"
    305 ><P
    306 >Actually struct&nbsp;<A
    307 HREF="r9539.htm#V4L2-AUDIO"
    308 >v4l2_audio</A
    309 > ought to have a
    310 <CODE
    311 CLASS="STRUCTFIELD"
    312 >tuner</CODE
    313 > field like struct&nbsp;<A
    314 HREF="r8936.htm#V4L2-INPUT"
    315 >v4l2_input</A
    316 >, not only
    317 making the API more consistent but also permitting radio devices with
    318 multiple tuners.</P
    319 ></TD
    320 ></TR
    321 ></TABLE
    322 ><DIV
    323 CLASS="NAVFOOTER"
    324 ><HR
    325 ALIGN="LEFT"
    326 WIDTH="100%"><TABLE
    327 SUMMARY="Footer navigation table"
    328 WIDTH="100%"
    329 BORDER="0"
    330 CELLPADDING="0"
    331 CELLSPACING="0"
    332 ><TR
    333 ><TD
    334 WIDTH="33%"
    335 ALIGN="left"
    336 VALIGN="top"
    337 ><A
    338 HREF="x309.htm"
    339 ACCESSKEY="P"
    340 >Prev</A
    341 ></TD
    342 ><TD
    343 WIDTH="34%"
    344 ALIGN="center"
    345 VALIGN="top"
    346 ><A
    347 HREF="book1.htm"
    348 ACCESSKEY="H"
    349 >Home</A
    350 ></TD
    351 ><TD
    352 WIDTH="33%"
    353 ALIGN="right"
    354 VALIGN="top"
    355 ><A
    356 HREF="x394.htm"
    357 ACCESSKEY="N"
    358 >Next</A
    359 ></TD
    360 ></TR
    361 ><TR
    362 ><TD
    363 WIDTH="33%"
    364 ALIGN="left"
    365 VALIGN="top"
    366 >Video Inputs and Outputs</TD
    367 ><TD
    368 WIDTH="34%"
    369 ALIGN="center"
    370 VALIGN="top"
    371 ><A
    372 HREF="c174.htm"
    373 ACCESSKEY="U"
    374 >Up</A
    375 ></TD
    376 ><TD
    377 WIDTH="33%"
    378 ALIGN="right"
    379 VALIGN="top"
    380 >Tuners and Modulators</TD
    381 ></TR
    382 ></TABLE
    383 ></DIV
    384 ></BODY
    385 ></HTML
    386 >
    387