| AUDIO(4) | AerieBSD 1.0 Refernce Manual | AUDIO(4) |
typedef struct audio_device {
char name[MAX_AUDIO_DEV_LEN];
char version[MAX_AUDIO_DEV_LEN];
char config[MAX_AUDIO_DEV_LEN];
} audio_device_t;
typedef struct audio_encoding {
int index; /* input: nth encoding */
char name[MAX_AUDIO_DEV_LEN]; /* name of encoding */
int encoding; /* value for encoding parameter */
int precision; /* value for precision parameter */
int flags;
#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
} audio_encoding_t;
To query all the supported encodings, start with an index field of 0 and continue with successive encodings (1, 2, ...) until the command returns an error.
typedef struct audio_offset {
u_int samples; /* Total number of bytes transferred */
u_int deltablks; /* Blocks transferred since last checked */
u_int offset; /* Physical transfer offset in buffer */
} audio_offset_t;
typedef struct audio_bufinfo {
u_int blksize; /* block size */
u_int hiwat; /* high water mark */
u_int lowat; /* low water mark */
u_int seek; /* current position */
} audio_bufinfo_t;
This information is mostly useful in input or output loops to determine how much data to read or write, respectively. Note, these ioctls were added to aid in porting third party applications and libraries, and should not be used in new code.
typedef struct audio_info {
struct audio_prinfo play; /* info for play (output) side */
struct audio_prinfo record; /* info for record (input) side */
u_int monitor_gain; /* input to output mix */
/* BSD extensions */
u_int blocksize; /* H/W read/write block size */
u_int hiwat; /* output high water mark */
u_int lowat; /* output low water mark */
u_char output_muted; /* toggle play mute */
u_char cspare[3];
u_int mode; /* current device mode */
#define AUMODE_PLAY 0x01
#define AUMODE_RECORD 0x02
#define AUMODE_PLAY_ALL 0x04 /* do not do real-time correction */
} audio_info_t;
When setting the current state with AUDIO_SETINFO, the audio_info structure should first be initialized with "AUDIO_INITINFO(&info);" and then the particular values to be changed should be set. This allows the audio driver to only set those things that you wish to change and eliminates the need to query the device with AUDIO_GETINFO first. The mode field should be set to AUMODE_PLAY, AUMODE_RECORD, AUMODE_PLAY_ALL, or a bitwise OR combination of the three. Only full-duplex audio devices support simultaneous record and playback. blocksize is used to attempt to set both play and record block sizes to the same value, it is left for compatibility only and its use is discouraged. hiwat and lowat are used to control write behavior. Writes to the audio devices will queue up blocks until the high-water mark is reached, at which point any more write calls will block until the queue is drained to the low-water mark. hiwat and lowat set those high- and low-water marks (in audio blocks). The default for hiwat is the maximum value and for lowat 75% of hiwat.
struct audio_prinfo {
u_int sample_rate; /* sample rate in samples/s */
u_int channels; /* number of channels, usually 1 or 2 */
u_int precision; /* number of bits/sample */
u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */
u_int gain; /* volume level */
u_int port; /* selected I/O port */
u_int seek; /* BSD extension */
u_int avail_ports; /* available I/O ports */
u_int buffer_size; /* total size audio buffer */
u_int _ispare[1];
/* Current state of device: */
u_int samples; /* number of samples */
u_int eof; /* End Of File (zero-size writes) counter */
u_char pause; /* non-zero if paused, zero to resume */
u_char error; /* non-zero if underflow/overflow occurred */
u_char waiting; /* non-zero if another process hangs in open */
u_char balance; /* stereo channel balance */
u_char cspare[2];
u_char open; /* non-zero if currently open */
u_char active; /* non-zero if I/O is currently active */
};
Note: many hardware audio drivers require identical playback and recording sample rates, sample encodings, and channel counts. The playing information is always set last and will prevail on such hardware. If the hardware can handle different settings the AUDIO_PROP_INDEPENDENT property is set. The encoding parameter can have the following values:
#define AUDIO_MIXER_CLASS 0
#define AUDIO_MIXER_ENUM 1
#define AUDIO_MIXER_SET 2
#define AUDIO_MIXER_VALUE 3
typedef struct mixer_ctrl {
int dev; /* input: nth device */
int type;
union {
int ord; /* enum */
int mask; /* set */
mixer_level_t value; /* value */
} un;
} mixer_ctrl_t;
#define AUDIO_MIN_GAIN 0
#define AUDIO_MAX_GAIN 255
typedef struct mixer_level {
int num_channels;
u_char level[8]; /* [num_channels] */
} mixer_level_t;
#define AUDIO_MIXER_LEVEL_MONO 0
#define AUDIO_MIXER_LEVEL_LEFT 0
#define AUDIO_MIXER_LEVEL_RIGHT 1
For a mixer value, the value field specifies both the number of channels and the values for each channel. If the channel count does not match the current channel count, the attempt to change the setting may fail (depending on the hardware device driver implementation). For an enumeration value, the ord field should be set to one of the possible values as returned by a prior AUDIO_MIXER_DEVINFO command. The type AUDIO_MIXER_CLASS is only used for classifying particular mixer device types and is not used for AUDIO_MIXER_READ or AUDIO_MIXER_WRITE.
typedef struct mixer_devinfo {
int index; /* input: nth mixer device */
audio_mixer_name_t label;
int type;
int mixer_class;
int next, prev;
#define AUDIO_MIXER_LAST -1
union {
struct audio_mixer_enum {
int num_mem;
struct {
audio_mixer_name_t label;
int ord;
} member[32];
} e;
struct audio_mixer_set {
int num_mem;
struct {
audio_mixer_name_t label;
int mask;
} member[32];
} s;
struct audio_mixer_value {
audio_mixer_name_t units;
int num_channels;
int delta;
} v;
} un;
} mixer_devinfo_t;
The label field identifies the name of this particular mixer control. The index field may be used as the dev field in AUDIO_MIXER_READ and AUDIO_MIXER_WRITE commands. The type field identifies the type of this mixer control. Enumeration types are typically used for on/off style controls (e.g., a mute control) or for input/output device selection (e.g., select recording input source from CD, line in, or microphone). Set types are similar to enumeration types but any combination of the mask bits can be used. The mixer_class field identifies what class of control this is. This value is set to the index value used to query the class itself. The (arbitrary) value set by the hardware driver may be determined by examining the mixer_class field of the class itself, a mixer of type AUDIO_MIXER_CLASS. For example, a mixer level controlling the input gain on the line in circuit would have a mixer_class that matches an input class device with the name inputs (AudioCinputs) and would have a label of line (AudioNline). Mixer controls which control audio circuitry for a particular audio source (e.g., line-in, CD in, DAC output) are collected under the input class, while those which control all audio sources (e.g., master volume, equalization controls) are under the output class. Hardware devices capable of recording typically also have a record class, for controls that only affect recording, and also a monitor class. The next and prev may be used by the hardware device driver to provide hints for the next and previous devices in a related set (for example, the line in level control would have the line in mute as its next value). If there is no relevant next or previous value, AUDIO_MIXER_LAST is specified. For AUDIO_MIXER_ENUM mixer control types, the enumeration values and their corresponding names are filled in. For example, a mute control would return appropriate values paired with AudioNon and AudioNoff. For the AUDIO_MIXER_VALUE and AUDIO_MIXER_SET mixer control types, the channel count is returned; the units name specifies what the level controls (typical values are AudioNvolume, AudioNtreble, and AudioNbass)).
| AerieBSD 1.0 Reference Manual | December 26 2008 | AUDIO(4) |