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