xref: /netbsd-src/share/man/man4/audio.4 (revision 82d56013d7b633d116a93943de88e08335357a7c)
1.\"	$NetBSD: audio.4,v 1.104 2020/12/09 05:48:56 isaki Exp $
2.\"
3.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by John T. Kohl.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd March 28, 2020
31.Dt AUDIO 4
32.Os
33.Sh NAME
34.Nm audio
35.Nd device-independent audio driver layer
36.Sh SYNOPSIS
37.In sys/audioio.h
38.Sh DESCRIPTION
39The
40.Nm
41driver provides support for various audio peripherals.
42It provides a uniform programming interface layer above different
43underlying audio hardware drivers.
44The audio layer provides full-duplex operation if the
45underlying hardware configuration supports it.
46.Pp
47There are four device files available for audio operation:
48.Pa /dev/audio ,
49.Pa /dev/sound ,
50.Pa /dev/audioctl ,
51and
52.Pa /dev/mixer .
53.Pp
54.Pa /dev/audio
55and
56.Pa /dev/sound
57are used for recording or playback of digital samples.
58.Pp
59.Pa /dev/mixer
60is used to manipulate volume, recording source, or other audio mixer
61functions.
62.Pp
63.Pa /dev/audioctl
64accepts the same
65.Xr ioctl 2
66operations as
67.Pa /dev/sound ,
68but no other operations.
69It can be opened at any time and can be used to manipulate the
70audio device while it is in use.
71.Sh SAMPLING DEVICES
72When
73.Pa /dev/audio
74is opened, it automatically sets the track to manipulate
75monaural 8-bit mu-law 8000Hz.
76When
77.Pa /dev/sound
78is opened, it maintains the audio format and pause/unpause
79state of the most recently opened track.
80In all other respects
81.Pa /dev/audio
82and
83.Pa /dev/sound
84are identical.
85.Pp
86On a full-duplex device, reads and writes may operate concurrently
87without interference.
88.Pp
89On a half-duplex device, if there are any recording descriptors already,
90opening with write mode will fail.
91Similarly, if there are any playback descriptors already,
92opening with read mode will fail.
93If both playback and recording are requested on a half-duplex device,
94it will be treated as playback mode.
95.Pp
96On either type of device, opening with write mode will start in playback mode,
97opening with read mode will start in recording mode.
98.Pp
99If the playback mode is paused then silence is
100played instead of the provided samples, and if recording is paused then
101the process blocks in
102.Xr read 2
103until recording is unpaused.
104.Pp
105If a writing process does not call
106.Xr write 2
107frequently enough to provide samples at the pace the hardware
108consumes them silence is inserted.
109If a reading process does not call
110.Xr read 2
111frequently enough, it will simply miss samples.
112.Pp
113The audio driver supports track multiplexing.
114All sampling devices can be opened at any time without interference.
115For playback, all tracks opened simultaneously are mixed,
116even if their specified format is different.
117For recording, recorded data is distributed to all opened tracks,
118even if their specified format is different.
119To achieve this, the audio driver has a small efficient encoding converter,
120a channel mixer, and a frequency converter.
121The frequency conversion adapts the simplest way
122(interpolation method for upward, and simple thinning method for downward)
123due to restriction in kernel resources and processing time.
124It will work well in most case but don't expect excessive quality.
125.Pp
126The audio device is normally accessed with
127.Xr read 2
128or
129.Xr write 2
130calls, but it can also be mapped into user memory with
131.Xr mmap 2 .
132Once the device has been mapped it can no longer be accessed
133by read or write; all access is by reading and writing to
134the mapped memory.
135The mmap'ped buffer appears as a block of memory of size
136.Va buffersize
137(as available via
138.Dv AUDIO_GETINFO
139or
140.Dv AUDIO_GETBUFINFO ) .
141The audio driver will continuously move data from this buffer
142from/to the mixing buffer, wrapping around at the end of the buffer.
143To find out where the hardware is currently accessing data in the buffer the
144.Dv AUDIO_GETIOFFS
145and
146.Dv AUDIO_GETOOFFS
147calls can be used.
148Note that
149.Xr mmap 2
150no longer maps hardware buffers directly.
151Now it is achieved by emulation so don't expect any improvements excessively
152rather than normal
153.Xr write 2 .
154For historical reasons, only encodings that are not set
155.Dv AUDIO_ENCODINGFLAG_EMULATED
156are able to
157.Xr mmap 2 .
158.Pp
159The audio device, like most devices, can be used in
160.Xr select 2 ,
161can be set in non-blocking mode and can be set (with a
162.Dv FIOASYNC
163ioctl) to send a
164.Dv SIGIO
165when I/O is possible.
166The mixer device can be set to generate a
167.Dv SIGIO
168whenever a mixer value is changed.
169.Pp
170The following
171.Xr ioctl 2
172commands are supported on the sample devices:
173.Bl -tag -width indent
174.It Dv AUDIO_FLUSH
175This command stops all playback and recording, clears all queued
176buffers, resets error counters on this track,
177and restarts recording and playback as
178appropriate for the current sampling mode.
179.It Dv AUDIO_PERROR (int)
180.It Dv AUDIO_RERROR (int)
181This command fetches the count of dropped output (input)
182bytes into its integer argument.
183There is no information regarding when in the sample stream
184they were dropped.
185.It Dv AUDIO_WSEEK (u_long)
186This command fetches the count of bytes that are queued ahead of the
187first sample in the most recent sample block written into its integer argument.
188.It Dv AUDIO_DRAIN
189This command suspends the calling process until all queued playback
190samples have been played.
191.It Dv AUDIO_GETDEV (audio_device_t)
192This command fetches the current hardware device information into the
193.Vt audio_device_t
194argument.
195.Bd -literal
196typedef struct audio_device {
197        char name[MAX_AUDIO_DEV_LEN];
198        char version[MAX_AUDIO_DEV_LEN];
199        char config[MAX_AUDIO_DEV_LEN];
200} audio_device_t;
201.Ed
202.It Dv AUDIO_GETENC (audio_encoding_t)
203This command is used iteratively to fetch sample encoding names and
204format ids into the input/output audio_encoding_t argument.
205The encoding returned by the command is user accessible encoding and
206is not hardware supported encoding.
207.Bd -literal
208typedef struct audio_encoding {
209	int index;      /* input: nth encoding */
210	char name[MAX_AUDIO_DEV_LEN]; /* name of encoding */
211	int encoding;   /* value for encoding parameter */
212	int precision;  /* value for precision parameter */
213	int flags;
214#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
215} audio_encoding_t;
216.Ed
217.Pp
218To query
219all the supported encodings, start with an index field of 0 and
220continue with successive encodings (1, 2, ...) until the command returns
221an error.
222.It Dv AUDIO_GETFD (int)
223This command is obsolete.
224.It Dv AUDIO_SETFD (int)
225This command is obsolete.
226.It Dv AUDIO_GETPROPS (int)
227This command gets a bit set of hardware properties.
228If the hardware
229has a certain property the corresponding bit is set, otherwise it is not.
230The properties can have the following values:
231.Pp
232.Bl -tag -width AUDIO_PROP_INDEPENDENT -compact
233.It Dv AUDIO_PROP_FULLDUPLEX
234the device admits full duplex operation.
235.It Dv AUDIO_PROP_MMAP
236the device can be used with
237.Xr mmap 2 .
238.It Dv AUDIO_PROP_INDEPENDENT
239the device can set the playing and recording encoding parameters
240independently.
241.It Dv AUDIO_PROP_PLAYBACK
242the device is capable of audio playback.
243.It Dv AUDIO_PROP_CAPTURE
244the device is capable of audio capture.
245.El
246.It Dv AUDIO_GETIOFFS (audio_offset_t)
247.It Dv AUDIO_GETOOFFS (audio_offset_t)
248This command fetches the current offset in the input(output) buffer where
249the track mixer will be putting(getting) data.
250It mostly useful when the device
251buffer is available in user space via the
252.Xr mmap 2
253call.
254The information is returned in the
255.Vt audio_offset_t
256structure.
257.Bd -literal
258typedef struct audio_offset {
259	u_int	samples;   /* Total number of bytes transferred */
260	u_int	deltablks; /* Blocks transferred since last checked */
261	u_int	offset;    /* Physical transfer offset in buffer */
262} audio_offset_t;
263.Ed
264.It Dv AUDIO_GETINFO (audio_info_t)
265.It Dv AUDIO_GETBUFINFO (audio_info_t)
266.It Dv AUDIO_SETINFO (audio_info_t)
267Get or set audio information as encoded in the audio_info structure.
268For historical reasons, the audio_info structure has three different
269layer's parameters: track, track mixer and hardware rich mixer.
270.Bd -literal
271typedef struct audio_info {
272	struct	audio_prinfo play;   /* info for play (output) side */
273	struct	audio_prinfo record; /* info for record (input) side */
274        u_int	monitor_gain;			/* input to output mix [HWmixer] */
275	/* BSD extensions */
276	u_int	blocksize;	/* read/write block size [track] */
277	u_int	hiwat;		/* output high water mark [track] */
278	u_int	lowat;		/* output low water mark [track] */
279	u_int	_ispare1;
280	u_int	mode;		/* current operation mode [track] */
281#define AUMODE_PLAY	0x01
282#define AUMODE_RECORD	0x02
283#define AUMODE_PLAY_ALL 0x04	/* Not used anymore */
284} audio_info_t;
285.Ed
286.Pp
287When setting the current state with
288.Dv AUDIO_SETINFO ,
289the audio_info structure should first be initialized with
290.Li AUDIO_INITINFO(&info)
291and then the particular values to be changed should be set.
292This allows the audio driver to only set those things that you wish
293to change and eliminates the need to query the device with
294.Dv AUDIO_GETINFO
295or
296.Dv AUDIO_GETBUFINFO
297first.
298.Pp
299The
300.Va mode
301field indicates current operation mode, either one of
302.Dv AUMODE_PLAY
303or
304.Dv AUMODE_RECORD .
305These two flags can not be changed once this descriptor is opened.
306For playback mode, the obsolete
307.Dv AUMODE_PLAY_ALL
308flag can be set but has no effect.
309.Pp
310.Va hiwat
311and
312.Va lowat
313are used to control write behavior.
314Writes to the audio devices will queue up blocks until the high-water
315mark is reached, at which point any more write calls will block
316until the queue is drained to the low-water mark.
317.Va hiwat
318and
319.Va lowat
320set those high- and low-water marks (in audio blocks).
321The default for
322.Va hiwat
323is the maximum value and for
324.Va lowat
32575% of
326.Va hiwat .
327.Pp
328.Va blocksize
329sets the current audio blocksize.
330The generic audio driver layer and the hardware driver have the
331opportunity to adjust this block size to get it within
332implementation-required limits.
333Normally the
334.Va blocksize
335is calculated to correspond to the value of the
336.Em hw.audioX.blk_ms
337sysctl and is recalculated when the encoding parameters change.
338If the descriptor is opened for read only,
339.Va blocksize
340indicates the blocksize for the recording track.
341Otherwise,
342.Va blocksize
343indicates the blocksize for the playback track.
344.Bd -literal
345struct audio_prinfo {
346	u_int	sample_rate;	/* sample rate in samples/s [track] */
347	u_int	channels;	/* number of channels, usually 1 or 2 [track] */
348	u_int	precision;	/* number of bits/sample [track] */
349	u_int	encoding;	/* data encoding (AUDIO_ENCODING_* below) [track] */
350	u_int	gain;		/* volume level [HWmixer] */
351	u_int	port;		/* selected I/O port [HWmixer] */
352	u_long	seek;		/* BSD extension [track] */
353	u_int	avail_ports;	/* available I/O ports [HWmixer] */
354	u_int	buffer_size;	/* total size audio buffer [track] */
355	u_int	_ispare[1];
356	u_int	samples;	/* number of samples [track] */
357	u_int	eof;		/* End Of File (zero-size writes) counter [track] */
358	u_char	pause;		/* non-zero if paused, zero to resume [track] */
359	u_char	error;		/* non-zero if underflow/overflow occurred [track] */
360	u_char	waiting;	/* non-zero if another process hangs in open [track] */
361	u_char	balance;	/* stereo channel balance [HWmixer] */
362	u_char	cspare[2];
363	u_char	open;		/* non-zero if currently open [trackmixer] */
364	u_char	active;		/* non-zero if I/O is currently active [trackmixer] */
365};
366.Ed
367.Pp
368Note: many hardware audio drivers require identical playback and
369recording sample rates, sample encodings, and channel counts.
370The playing information is always set last and will prevail on such hardware.
371If the hardware can handle different settings the
372.Dv AUDIO_PROP_INDEPENDENT
373property is set.
374.Pp
375The encoding parameter can have the following values:
376.Pp
377.Bl -tag -width AUDIO_ENCODING_SLINEAR_BE -compact
378.It Dv AUDIO_ENCODING_ULAW
379mu-law encoding, 8 bits/sample
380.It Dv AUDIO_ENCODING_ALAW
381A-law encoding, 8 bits/sample
382.It Dv AUDIO_ENCODING_SLINEAR
383two's complement signed linear encoding with the platform byte order
384.It Dv AUDIO_ENCODING_ULINEAR
385unsigned linear encoding
386with the platform byte order
387.It Dv AUDIO_ENCODING_ADPCM
388ADPCM encoding, 8 bits/sample
389.It Dv AUDIO_ENCODING_SLINEAR_LE
390two's complement signed linear encoding with little endian byte order
391.It Dv AUDIO_ENCODING_SLINEAR_BE
392two's complement signed linear encoding with big endian byte order
393.It Dv AUDIO_ENCODING_ULINEAR_LE
394unsigned linear encoding with little endian byte order
395.It Dv AUDIO_ENCODING_ULINEAR_BE
396unsigned linear encoding with big endian byte order
397.It Dv AUDIO_ENCODING_AC3
398Dolby Digital AC3
399.El
400.Pp
401The
402.Nm
403driver accepts the following formats.
404.Va encoding
405and
406.Va precision
407are one of the values obtained by
408.Dv AUDIO_GETENC ,
409regardless of formats supported by underlying driver.
410.Va frequency
411ranges from 1000Hz to 192000Hz,
412regardless of frequency (ranges) supported by underlying driver.
413.Va channels
414depends your underlying driver.
415If the underlying driver only supports monaural (1channel)
416or stereo (2channels), you can specify 1 or 2 regardless of
417number of channels supported by underlying driver.
418If the underlying driver supports three or more channels, you can specify
419the number of channels supported by the underlying driver or less.
420.Pp
421The
422.Va gain ,
423.Va port
424and
425.Va balance
426settings provide simple shortcuts to the richer mixer
427interface described below and are not obtained by
428.Dv AUDIO_GETBUFINFO .
429The gain should be in the range
430.Bq Dv AUDIO_MIN_GAIN , Dv AUDIO_MAX_GAIN
431and the balance in the range
432.Bq Dv AUDIO_LEFT_BALANCE , Dv AUDIO_RIGHT_BALANCE
433with the normal setting at
434.Dv AUDIO_MID_BALANCE .
435.Pp
436The input port should be a combination of:
437.Pp
438.Bl -tag -width AUDIO_MICROPHONE -compact
439.It Dv AUDIO_MICROPHONE
440to select microphone input.
441.It Dv AUDIO_LINE_IN
442to select line input.
443.It Dv AUDIO_CD
444to select CD input.
445.El
446.Pp
447The output port should be a combination of:
448.Pp
449.Bl -tag -width AUDIO_HEADPHONE -compact
450.It Dv AUDIO_SPEAKER
451to select speaker output.
452.It Dv AUDIO_HEADPHONE
453to select headphone output.
454.It Dv AUDIO_LINE_OUT
455to select line output.
456.El
457.Pp
458The available ports can be found in
459.Va avail_ports
460.Dv ( AUDIO_GETBUFINFO
461only).
462.Pp
463.Va buffer_size
464is the total size of the audio buffer.
465The buffer size divided by the
466.Va blocksize
467gives the maximum value for
468.Va hiwat .
469Currently the
470.Va buffer_size
471can only be read and not set.
472.Pp
473The
474.Va seek
475and
476.Va samples
477fields are only used by
478.Dv AUDIO_GETINFO
479and
480.Dv AUDIO_GETBUFINFO .
481.Va seek
482represents the count of
483bytes pending;
484.Va samples
485represents the total number of bytes recorded or played, less those
486that were dropped due to inadequate consumption/production rates.
487.Pp
488.Va pause
489returns the current pause/unpause state for recording or playback.
490For
491.Dv AUDIO_SETINFO ,
492if the pause value is specified it will either pause
493or unpause the particular direction.
494.It Dv AUDIO_QUERYFORMAT (audio_format_query_t)
495This command enumerates formats supported by the hardware.
496Similarly to
497.Dv AUDIO_GETENC ,
498to query all the supported formats,
499start with an index field of 0 and continue with successive formats
500(1, 2, ...) until the command returns an error.
501.Bd -literal
502typedef struct audio_format_query {
503	u_int	index;
504	struct audio_format fmt;
505} audio_format_query_t;
506.Ed
507.It Dv AUDIO_GETFORMAT (audio_info_t)
508This command fetches the current hardware format.
509Only the following members in audio_info_t are used.
510Members which are not listed here or belong in invalid direction are
511filled by \-1.
512.Bl -bullet
513.It
514mode
515.It
516play.encoding
517.It
518play.precision
519.It
520play.channels
521.It
522play.sample_rate
523.It
524record.encoding
525.It
526record.precision
527.It
528record.channels
529.It
530record.sample_rate
531.El
532.Pp
533.Va mode
534indicates which direction is valid.
535.It Dv AUDIO_SETFORMAT (audio_info_t)
536This command sets the hardware format.
537It will fail if there are any opened descriptors.
538So obviously, it must be issued on
539.Pa /dev/audioctl .
540Similarly to
541.Dv AUDIO_GETFORMAT ,
542only above members in audio_info_t are used.
543Members which is not listed or belong in invalid direction are ignored.
544The parameters can be chosen from the choices obtained by
545.Dv AUDIO_QUERYFORMAT .
546.It Dv AUDIO_GETCHAN (int)
547This command is obsolete.
548.It Dv AUDIO_SETCHAN (int)
549This command is obsolete.
550.El
551.Sh MIXER DEVICE
552The mixer device,
553.Pa /dev/mixer ,
554may be manipulated with
555.Xr ioctl 2
556but does not support
557.Xr read 2
558or
559.Xr write 2 .
560It supports the following
561.Xr ioctl 2
562commands:
563.Bl -tag -width indent
564.It Dv AUDIO_GETDEV (audio_device_t)
565This command is the same as described above for the sampling devices.
566.It Dv AUDIO_MIXER_READ (mixer_ctrl_t)
567.It Dv AUDIO_MIXER_WRITE (mixer_ctrl_t)
568These commands read the current mixer state or set new mixer state for
569the specified device
570.Va dev .
571.Va type
572identifies which type of value is supplied in the
573.Vt mixer_ctrl_t
574argument.
575.Bd -literal
576#define AUDIO_MIXER_CLASS  0
577#define AUDIO_MIXER_ENUM   1
578#define AUDIO_MIXER_SET    2
579#define AUDIO_MIXER_VALUE  3
580typedef struct mixer_ctrl {
581	int dev;			/* input: nth device */
582	int type;
583	union {
584		int ord;		/* enum */
585		int mask;		/* set */
586		mixer_level_t value;	/* value */
587	} un;
588} mixer_ctrl_t;
589
590#define AUDIO_MIN_GAIN  0
591#define AUDIO_MAX_GAIN  255
592typedef struct mixer_level {
593        int num_channels;
594        u_char level[8];               /* [num_channels] */
595} mixer_level_t;
596#define AUDIO_MIXER_LEVEL_MONO  0
597#define AUDIO_MIXER_LEVEL_LEFT  0
598#define AUDIO_MIXER_LEVEL_RIGHT 1
599.Ed
600.Pp
601For a mixer value, the
602.Va value
603field specifies both the number of channels and the values for each
604channel.
605If the channel count does not match the current channel count, the
606attempt to change the setting may fail (depending on the hardware
607device driver implementation).
608For an enumeration value, the
609.Va ord
610field should be set to one of the possible values as returned by a prior
611.Dv AUDIO_MIXER_DEVINFO
612command.
613The type
614.Dv AUDIO_MIXER_CLASS
615is only used for classifying particular mixer device
616types and is not used for
617.Dv AUDIO_MIXER_READ
618or
619.Dv AUDIO_MIXER_WRITE .
620.It Dv AUDIO_MIXER_DEVINFO (mixer_devinfo_t)
621This command is used iteratively to fetch audio mixer device information
622into the input/output
623.Vt mixer_devinfo_t
624argument.
625To query all the supported devices, start with an index field of
6260 and continue with successive devices (1, 2, ...) until the
627command returns an error.
628.Bd -literal
629typedef struct mixer_devinfo {
630	int index;		/* input: nth mixer device */
631	audio_mixer_name_t label;
632	int type;
633	int mixer_class;
634	int next, prev;
635#define AUDIO_MIXER_LAST	-1
636	union {
637		struct audio_mixer_enum {
638			int num_mem;
639			struct {
640				audio_mixer_name_t label;
641				int ord;
642			} member[32];
643		} e;
644		struct audio_mixer_set {
645			int num_mem;
646			struct {
647				audio_mixer_name_t label;
648				int mask;
649			} member[32];
650		} s;
651		struct audio_mixer_value {
652			audio_mixer_name_t units;
653			int num_channels;
654			int delta;
655		} v;
656	} un;
657} mixer_devinfo_t;
658.Ed
659.Pp
660The
661.Va label
662field identifies the name of this particular mixer control.
663The
664.Va index
665field may be used as the
666.Va dev
667field in
668.Dv AUDIO_MIXER_READ
669and
670.Dv AUDIO_MIXER_WRITE
671commands.
672The
673.Va type
674field identifies the type of this mixer control.
675Enumeration types are typically used for on/off style controls (e.g. a
676mute control) or for input/output device selection (e.g. select
677recording input source from CD, line in, or microphone).
678Set types are similar to enumeration types but any combination
679of the mask bits can be used.
680.Pp
681The
682.Va mixer_class
683field identifies what class of control this is.
684The
685.Pq arbitrary
686value set by the hardware driver may be determined by examining the
687.Va mixer_class
688field of the class itself,
689a mixer of type
690.Dv AUDIO_MIXER_CLASS .
691For example, a mixer controlling the input gain on the line in circuit
692would have a
693.Va mixer_class
694that matches an input class device with the name
695.Dq inputs
696.Dv ( AudioCinputs ) ,
697and would have a
698.Va label
699of
700.Dq line
701.Dv ( AudioNline ) .
702Mixer controls which control audio circuitry for a particular audio
703source (e.g. line-in, CD in, DAC output) are collected under the input class,
704while those which control all audio sources (e.g. master volume,
705equalization controls) are under the output class.
706Hardware devices capable of recording typically also have a record class,
707for controls that only affect recording,
708and also a monitor class.
709.Pp
710The
711.Va next
712and
713.Va prev
714may be used by the hardware device driver to provide hints for the next
715and previous devices in a related set (for example, the line in level
716control would have the line in mute as its
717.Dq next
718value).
719If there is no relevant next or previous value,
720.Dv AUDIO_MIXER_LAST
721is specified.
722.Pp
723For
724.Dv AUDIO_MIXER_ENUM
725mixer control types,
726the enumeration values and their corresponding names are filled in.
727For example, a mute control would return appropriate values paired with
728.Dv AudioNon
729and
730.Dv AudioNoff .
731For
732.Dv AUDIO_MIXER_VALUE
733and
734.Dv AUDIO_MIXER_SET
735mixer control types, the channel count is
736returned; the units name specifies what the level controls (typical
737values are
738.Dv AudioNvolume ,
739.Dv AudioNtreble ,
740.Dv AudioNbass ) .
741.\" For AUDIO_MIXER_SET mixer control types, what is what?
742.El
743.Pp
744By convention, all the mixer devices can be distinguished from other
745mixer controls because they use a name from one of the
746.Dv AudioC*
747string values.
748.Sh FILES
749.Bl -tag -width /dev/audioctl -compact
750.It Pa /dev/audio
751.It Pa /dev/audioctl
752.It Pa /dev/sound
753.It Pa /dev/mixer
754.El
755.Sh SEE ALSO
756.Xr audiocfg 1 ,
757.Xr audioctl 1 ,
758.Xr audioplay 1 ,
759.Xr audiorecord 1 ,
760.Xr mixerctl 1 ,
761.Xr ioctl 2 ,
762.Xr ossaudio 3 ,
763.Xr acorn32/vidcaudio 4 ,
764.\" .Xr amiga/aucc 4 ,
765.\" .Xr amiga/melody 4 ,
766.Xr arcofi 4 ,
767.Xr aria 4 ,
768.Xr auacer 4 ,
769.Xr audiocs 4 ,
770.Xr auich 4 ,
771.Xr auixp 4 ,
772.\" .Xr ausoc 4 ,
773.Xr autri 4 ,
774.Xr auvia 4 ,
775.Xr bba 4 ,
776.Xr btsco 4 ,
777.Xr clcs 4 ,
778.Xr clct 4 ,
779.Xr cmpci 4 ,
780.Xr dreamcast/aica 4 ,
781.Xr eap 4 ,
782.Xr emuxki 4 ,
783.Xr esa 4 ,
784.Xr esm 4 ,
785.Xr eso 4 ,
786.Xr ess 4 ,
787.\" .Xr evbarm/aaci 4 ,
788.\" .Xr evbarm/digfilt 4 ,
789.\" .Xr evbarm/pxaacu 4 ,
790.\" .Xr evbarm/udassio 4 ,
791.Xr fms 4 ,
792.Xr gcscaudio 4 ,
793.Xr gus 4 ,
794.Xr guspnp 4 ,
795.Xr hdafg 4 ,
796.Xr hdaudio 4 ,
797.Xr hppa/harmony 4 ,
798.Xr macppc/awacs 4 ,
799.Xr macppc/snapper 4 ,
800.Xr midi 4 ,
801.Xr neo 4 ,
802.Xr pad 4 ,
803.Xr pas 4 ,
804.\" .Xr paud 4 ,
805.Xr radio 4 ,
806.\" .Xr repluse 4 ,
807.Xr sb 4 ,
808.Xr sgimips/haltwo 4 ,
809.Xr sgimips/mavb 4 ,
810.Xr sparc/audioamd 4 ,
811.Xr sparc/dbri 4 ,
812.Xr sv 4 ,
813.\" .Xr toccata 4 ,
814.Xr uaudio 4 ,
815.\" .Xr vaudio 4 ,
816.\" .Xr vcaudio 4 ,
817.\" .Xr vraiu 4 ,
818.\" .Xr vsaudio 4 ,
819.Xr wss 4 ,
820.Xr x68k/vs 4 ,
821.Xr yds 4 ,
822.Xr ym 4
823.\" .Xr zaudio 4
824.Sh HISTORY
825Support for virtual channels and mixing first appeared in
826.Nx 8.0 .
827.Sh BUGS
828If the device is used in
829.Xr mmap 2
830it is currently always mapped for writing (playing) due to VM system weirdness.
831