Changeset View
Changeset View
Standalone View
Standalone View
lib/libmixer/mixer.3
Show All 15 Lines | |||||||||
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | .\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||||
.\" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | .\" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||||
.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | .\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||||
.\" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | .\" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||||||
.\" THE SOFTWARE. | .\" THE SOFTWARE. | ||||||||
.\" | .\" | ||||||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||||||
.\" | .\" | ||||||||
.Dd March 18, 2022 | |||||||||
.Dd September 22, 2021 | |||||||||
.Dt MIXER 3 | .Dt MIXER 3 | ||||||||
.Os | .Os | ||||||||
.Sh NAME | .Sh NAME | ||||||||
.Nm mixer_open , | .Nm mixer_open , | ||||||||
.Nm mixer_close , | .Nm mixer_close , | ||||||||
.Nm mixer_get_dev , | .Nm mixer_get_dev , | ||||||||
.Nm mixer_get_dev_byname , | .Nm mixer_get_dev_byname , | ||||||||
.Nm mixer_add_ctl , | .Nm mixer_add_ctl , | ||||||||
.Nm mixer_add_ctl_s , | .Nm mixer_add_ctl_s , | ||||||||
.Nm mixer_remove_ctl , | .Nm mixer_remove_ctl , | ||||||||
.Nm mixer_get_ctl , | .Nm mixer_get_ctl , | ||||||||
.Nm mixer_get_ctl_byname , | .Nm mixer_get_ctl_byname , | ||||||||
.Nm mixer_set_vol , | .Nm mixer_set_vol , | ||||||||
.Nm mixer_set_mute , | .Nm mixer_set_mute , | ||||||||
.Nm mixer_mod_recsrc , | .Nm mixer_mod_recsrc , | ||||||||
.Nm mixer_get_dunit , | .Nm mixer_get_dunit , | ||||||||
.Nm mixer_set_dunit , | .Nm mixer_set_dunit , | ||||||||
.Nm mixer_get_mode, | .Nm mixer_get_mode , | ||||||||
.Nm mixer_get_nmixers , | .Nm mixer_get_nmixers , | ||||||||
.Nm MIX_ISDEV , | .Nm MIX_ISDEV , | ||||||||
.Nm MIX_ISMUTE , | .Nm MIX_ISMUTE , | ||||||||
.Nm MIX_ISREC , | .Nm MIX_ISREC , | ||||||||
.Nm MIX_ISRECSRC , | .Nm MIX_ISRECSRC , | ||||||||
.Nm MIX_VOLNORM , | .Nm MIX_VOLNORM , | ||||||||
.Nm MIX_VOLDENORM | .Nm MIX_VOLDENORM | ||||||||
.Nd interface to OSS mixers | .Nd interface to OSS mixers | ||||||||
.Sh LIBRARY | .Sh LIBRARY | ||||||||
Mixer library (libmixer, -lmixer) | Mixer library (libmixer, -lmixer) | ||||||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||||||
.In mixer.h | .In mixer.h | ||||||||
.Ft struct mixer * | .Ft struct mixer * | ||||||||
.Fn mixer_open "const char *name" | .Fn mixer_open "const char *name" | ||||||||
.Ft int | .Ft int | ||||||||
.Fn mixer_close "struct mixer *m" | .Fn mixer_close "struct mixer *m" | ||||||||
.Ft struct mix_dev * | .Ft struct mix_dev * | ||||||||
.Fn mixer_get_dev "struct mixer *m" "int devno" | .Fn mixer_get_dev "struct mixer *m" "int devno" | ||||||||
.Ft struct mix_dev * | .Ft struct mix_dev * | ||||||||
.Fn mixer_get_dev_byname "struct mixer *m" "name" | .Fn mixer_get_dev_byname "struct mixer *m" "name" | ||||||||
.Ft int | .Ft int | ||||||||
.Fn mixer_add_ctl "struct mix_dev *parent" "int id" "const char *name" \ | .Fn mixer_add_ctl "struct mix_dev *parent" "int id" "const char *name" \ | ||||||||
"int (*mod)(struct mix_dev *d, void *p)" \ | "int (*mod)(struct mix_dev *d, void *p)" \ | ||||||||
"int (*print)(struct mix_dev *d, void *p) | "int (*print)(struct mix_dev *d, void *p)" | ||||||||
.Ft int | .Ft int | ||||||||
.Fn mixer_add_ctl_s "mix_ctl_t *ctl" | .Fn mixer_add_ctl_s "mix_ctl_t *ctl" | ||||||||
.Ft int | .Ft int | ||||||||
.Fn mixer_remove_ctl "mix_ctl_t *ctl" | .Fn mixer_remove_ctl "mix_ctl_t *ctl" | ||||||||
.Ft mix_ctl_t * | .Ft mix_ctl_t * | ||||||||
.Fn mixer_get_ctl "struct mix_dev *d" "int id" | .Fn mixer_get_ctl "struct mix_dev *d" "int id" | ||||||||
.Ft mix_ctl_t * | .Ft mix_ctl_t * | ||||||||
.Fn mixer_get_ctl_byname "struct mix_dev *d" "const char *name" | .Fn mixer_get_ctl_byname "struct mix_dev *d" "const char *name" | ||||||||
Show All 24 Lines | |||||||||
.Ft int | .Ft int | ||||||||
.Fn MIX_VOLDENORM "float v" | .Fn MIX_VOLDENORM "float v" | ||||||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||||||
The | The | ||||||||
.Nm mixer | .Nm mixer | ||||||||
library allows userspace programs to access and manipulate OSS sound mixers in | library allows userspace programs to access and manipulate OSS sound mixers in | ||||||||
a simple way. | a simple way. | ||||||||
.Ss Mixer | .Ss Mixer | ||||||||
.Pp | |||||||||
A mixer is described by the following structure: | A mixer is described by the following structure: | ||||||||
.Bd -literal | .Bd -literal | ||||||||
struct mixer { | struct mixer { | ||||||||
TAILQ_HEAD(, mix_dev) devs; /* device list */ | TAILQ_HEAD(, mix_dev) devs; /* device list */ | ||||||||
struct mix_dev *dev; /* selected device */ | struct mix_dev *dev; /* selected device */ | ||||||||
oss_mixerinfo mi; /* mixer info */ | oss_mixerinfo mi; /* mixer info */ | ||||||||
oss_card_info ci; /* audio card info */ | oss_card_info ci; /* audio card info */ | ||||||||
char name[NAME_MAX]; /* mixer name (e.g /dev/mixer0) */ | char name[NAME_MAX]; /* mixer name (e.g /dev/mixer0) */ | ||||||||
Show All 19 Lines | |||||||||
}; | }; | ||||||||
.Ed | .Ed | ||||||||
.Pp | .Pp | ||||||||
The fields are follows: | The fields are follows: | ||||||||
.Bl -tag -width "f_default" | .Bl -tag -width "f_default" | ||||||||
.It Fa devs | .It Fa devs | ||||||||
A tail queue structure containing all supported mixer devices. | A tail queue structure containing all supported mixer devices. | ||||||||
.It Fa dev | .It Fa dev | ||||||||
A pointer to the currently selected device. The device is one of the elements in | A pointer to the currently selected device. | ||||||||
The device is one of the elements in | |||||||||
.Ar devs . | .Ar devs . | ||||||||
.It Fa mi | .It Fa mi | ||||||||
OSS information about the mixer. Look at the definition of the | OSS information about the mixer. | ||||||||
Look at the definition of the | |||||||||
.Ft oss_mixerinfo | .Ft oss_mixerinfo | ||||||||
structure in | structure in | ||||||||
.In sys/soundcard.h | .In sys/soundcard.h | ||||||||
to see its fields. | to see its fields. | ||||||||
.It Fa ci | .It Fa ci | ||||||||
OSS audio card information. This structure is also defined in | OSS audio card information. | ||||||||
This structure is also defined in | |||||||||
.In sys/soundcard.h . | .In sys/soundcard.h . | ||||||||
.It Fa name | .It Fa name | ||||||||
Path to the mixer (e.g /dev/mixer0). | Path to the mixer (e.g /dev/mixer0). | ||||||||
.It Fa fd | .It Fa fd | ||||||||
File descriptor returned when the mixer is opened in | File descriptor returned when the mixer is opened in | ||||||||
.Fn mixer_open . | .Fn mixer_open . | ||||||||
.It Fa unit | .It Fa unit | ||||||||
Audio card unit. Since each mixer device maps to a pcmX device, | Audio card unit. | ||||||||
Since each mixer device maps to a pcmX device, | |||||||||
.Ar unit | .Ar unit | ||||||||
is always equal to the number of that pcmX device. For example, if the audio | is always equal to the number of that pcmX device. | ||||||||
device's number is 0 (i.e pcm0), then | For example, if the audio device's number is 0 (i.e pcm0), then | ||||||||
0mpUnsubmitted Done Inline Actions
0mp: | |||||||||
.Ar unit | .Ar unit | ||||||||
is 0 as well. This number is useful when checking if the mixer's audio | is 0 as well. | ||||||||
card is the default one. | This number is useful when checking if the mixer's audio card is the default one. | ||||||||
.It Fa ndev | .It Fa ndev | ||||||||
Number of devices in | Number of devices in | ||||||||
.Ar devs . | .Ar devs . | ||||||||
.It Fa devmask | .It Fa devmask | ||||||||
Bit mask containing all supported devices for the mixer. For example | Bit mask containing all supported devices for the mixer. | ||||||||
if device 10 is supported, then the 10th bit in the mask will be set. By default, | For example, if device 10 is supported, then the 10th bit in the mask will be set. | ||||||||
By default, | |||||||||
.Fn mixer_open | .Fn mixer_open | ||||||||
stores only the supported devices in devs, so it's very unlikely this mask will | stores only the supported devices in devs, so it's very unlikely this mask will | ||||||||
be needed. | be needed. | ||||||||
.It Fa mutemask | .It Fa mutemask | ||||||||
Bit mask containing all muted devices. The logic is the same as with | Bit mask containing all muted devices. | ||||||||
The logic is the same as with | |||||||||
.Ar devmask . | .Ar devmask . | ||||||||
.It Fa recmask | .It Fa recmask | ||||||||
Bit mask containing all recording devices. Again, same logic as with the | Bit mask containing all recording devices. | ||||||||
other masks. | Again, same logic as with the other masks. | ||||||||
.It Fa recsrc | .It Fa recsrc | ||||||||
Bit mask containing all recording sources. Yes, same logic again. | Bit mask containing all recording sources. | ||||||||
Yes, same logic again. | |||||||||
.It Fa mode | .It Fa mode | ||||||||
Bit mask containing the supported modes for this audio device. It holds the value | Bit mask containing the supported modes for this audio device. | ||||||||
of the | It holds the value of the | ||||||||
.Ar dev.pcm.X.mode | .Ar dev.pcm.X.mode | ||||||||
sysctl. | sysctl. | ||||||||
.It Fa f_default | .It Fa f_default | ||||||||
Flag which tells whether the mixer's audio card is the default one. | Flag which tells whether the mixer's audio card is the default one. | ||||||||
.El | .El | ||||||||
.Ss Mixer device | .Ss Mixer device | ||||||||
.Pp | |||||||||
Each mixer device stored in a mixer is described as follows: | Each mixer device stored in a mixer is described as follows: | ||||||||
.Bd -literal | .Bd -literal | ||||||||
struct mix_dev { | struct mix_dev { | ||||||||
struct mixer *parent_mixer; /* parent mixer */ | struct mixer *parent_mixer; /* parent mixer */ | ||||||||
char name[NAME_MAX]; /* device name (e.g "vol") */ | char name[NAME_MAX]; /* device name (e.g "vol") */ | ||||||||
int devno; /* device number */ | int devno; /* device number */ | ||||||||
struct mix_volume { | struct mix_volume { | ||||||||
#define MIX_VOLMIN 0.0f | #define MIX_VOLMIN 0.0f | ||||||||
Show All 9 Lines | |||||||||
}; | }; | ||||||||
.Ed | .Ed | ||||||||
.Pp | .Pp | ||||||||
The fields are follows: | The fields are follows: | ||||||||
.Bl -tag -width "parent_mixer" | .Bl -tag -width "parent_mixer" | ||||||||
.It Fa parent_mixer | .It Fa parent_mixer | ||||||||
Pointer to the mixer the device is attached to. | Pointer to the mixer the device is attached to. | ||||||||
.It Fa name | .It Fa name | ||||||||
Device name given by the OSS API. Devices can have one of the following names: | Device name given by the OSS API. | ||||||||
Devices can have one of the following names: | |||||||||
.Bd -ragged | .Bd -ragged | ||||||||
vol, bass, treble, synth, pcm, speaker, line, mic, cd, mix, | vol, bass, treble, synth, pcm, speaker, line, mic, cd, mix, | ||||||||
pcm2, rec, igain, ogain, line1, line2, line3, dig1, dig2, dig3, | pcm2, rec, igain, ogain, line1, line2, line3, dig1, dig2, dig3, | ||||||||
phin, phout, video, radio, and monitor. | phin, phout, video, radio, and monitor. | ||||||||
.Ed | .Ed | ||||||||
.It Fa devno | .It Fa devno | ||||||||
Device's index in the SOUND_MIXER_NRDEVICES macro defined in | Device's index in the SOUND_MIXER_NRDEVICES macro defined in | ||||||||
.In sys/soundcard.h . | .In sys/soundcard.h . | ||||||||
This number is used to check against the masks defined in the | This number is used to check against the masks defined in the | ||||||||
.Ar mixer | .Ar mixer | ||||||||
structure. | structure. | ||||||||
.It Fa left, right | .It Fa left right | ||||||||
Left and right-ear volumes. Although the OSS API stores volumes in integers from | Left and right-ear volumes. | ||||||||
0-100, we normalize them to 32-bit floating point numbers. However, the volumes | Although the OSS API stores volumes in integers from 0-100, \ | ||||||||
can be denormalized using the | we normalize them to 32-bit floating point numbers. | ||||||||
However, the volumes can be denormalized using the | |||||||||
.Ar MIX_VOLDENORM | .Ar MIX_VOLDENORM | ||||||||
macro if needed. | macro if needed. | ||||||||
.It Fa nctl | .It Fa nctl | ||||||||
Number of user-defined mixer controls associated with the device. | Number of user-defined mixer controls associated with the device. | ||||||||
.It Fa ctls | .It Fa ctls | ||||||||
A tail queue containing user-defined mixer controls. | A tail queue containing user-defined mixer controls. | ||||||||
.El | .El | ||||||||
.Ss User-defined mixer controls | .Ss User-defined mixer controls | ||||||||
.Pp | Each mixer device can have user-defined controls. | ||||||||
Each mixer device can have user-defined controls. The control structure | The control structure is defined as follows: | ||||||||
is defined as follows: | |||||||||
.Bd -literal | .Bd -literal | ||||||||
struct mix_ctl { | struct mix_ctl { | ||||||||
struct mix_dev *parent_dev; /* parent device */ | struct mix_dev *parent_dev; /* parent device */ | ||||||||
int id; /* control id */ | int id; /* control id */ | ||||||||
char name[NAME_MAX]; /* control name */ | char name[NAME_MAX]; /* control name */ | ||||||||
int (*mod)(struct mix_dev *, void *); /* modify control values */ | int (*mod)(struct mix_dev *, void *); /* modify control values */ | ||||||||
int (*print)(struct mix_dev *, void *); /* print control */ | int (*print)(struct mix_dev *, void *); /* print control */ | ||||||||
TAILQ_ENTRY(mix_ctl) ctls; | TAILQ_ENTRY(mix_ctl) ctls; | ||||||||
}; | }; | ||||||||
.Ed | .Ed | ||||||||
.Pp | .Pp | ||||||||
The fields are follows: | The fields are follows: | ||||||||
.Bl -tag -width "parent_dev" | .Bl -tag -width "parent_dev" | ||||||||
.It Fa parent_dev | .It Fa parent_dev | ||||||||
Pointer to the device the control is attached to. | Pointer to the device the control is attached to. | ||||||||
.It Fa id | .It Fa id | ||||||||
Control ID assigned by the caller. Even though the library will | Control ID assigned by the caller. | ||||||||
report it, care has to be taken to not give a control the same ID in case | Even though the library will report it, care has to be taken to not give \ | ||||||||
the caller has to choose controls using their ID. | a control the same ID in case the caller has to choose controls using their ID. | ||||||||
.It Fa name | .It Fa name | ||||||||
Control name. As with | Control name. | ||||||||
As with | |||||||||
.Ar id , | .Ar id , | ||||||||
the caller has to make sure the same name is not used more than once. | the caller has to make sure the same name is not used more than once. | ||||||||
.It Fa mod | .It Fa mod | ||||||||
Function pointer to a control modification function. As in | Function pointer to a control modification function. | ||||||||
As in | |||||||||
.Xr mixer 8 , | .Xr mixer 8 , | ||||||||
each mixer control's values can be modified. For example, if we have a | each mixer control's values can be modified. | ||||||||
volume control, the | For example, if we have a volume control, the | ||||||||
.Ar mod | .Ar mod | ||||||||
function will be responsible for handling volume changes. | function will be responsible for handling volume changes. | ||||||||
.It Fa print | .It Fa print | ||||||||
Function pointer to a control print function. | Function pointer to a control print function. | ||||||||
.El | .El | ||||||||
.Ss Opening and closing the mixer | .Ss Opening and closing the mixer | ||||||||
.Pp | |||||||||
The application must first call the | The application must first call the | ||||||||
.Fn mixer_open | .Fn mixer_open | ||||||||
function to obtain a handle to the device, which is used as an argument | function to obtain a handle to the device, which is used as an argument \ | ||||||||
in most other functions and macros. The parameter | in most other functions and macros. | ||||||||
The parameter | |||||||||
.Ar name | .Ar name | ||||||||
specifies the path to the mixer. OSS mixers are stored under | specifies the path to the mixer. | ||||||||
OSS mixers are stored under | |||||||||
.Ar /dev/mixerN | .Ar /dev/mixerN | ||||||||
where | where | ||||||||
.Ar N | .Ar N | ||||||||
is the number of the mixer device. Each device maps to an actual | is the number of the mixer device. | ||||||||
Each device maps to an actual | |||||||||
.Ar pcm | .Ar pcm | ||||||||
audio card, so | audio card, so | ||||||||
.Ar /dev/mixer0 | .Ar /dev/mixer0 | ||||||||
is the mixer for | is the mixer for | ||||||||
.Ar pcm0 , | .Ar pcm0 , | ||||||||
and so on. If | and so on. | ||||||||
If | |||||||||
.Ar name | .Ar name | ||||||||
is | is | ||||||||
.Ar NULL | .Ar NULL | ||||||||
or | or | ||||||||
.Ar /dev/mixer , | .Ar /dev/mixer , | ||||||||
.Fn mixer_open | .Fn mixer_open | ||||||||
opens the default mixer (hw.snd.defaul_unit). | opens the default mixer (hw.snd.defaul_unit). | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_close | .Fn mixer_close | ||||||||
function frees resources and closes the mixer device. It's a good practice to | function frees resources and closes the mixer device. | ||||||||
always call it when the application is done using the mixer. | It's a good practice to always call it when the application is done using the mixer. | ||||||||
.Ss Manipulating the mixer | .Ss Manipulating the mixer | ||||||||
.Pp | |||||||||
The | The | ||||||||
.Fn mixer_get_dev | .Fn mixer_get_dev | ||||||||
and | and | ||||||||
.Fn mixer_get_dev_byname | .Fn mixer_get_dev_byname | ||||||||
functions select a mixer device, either by its number or by its name | functions select a mixer device, either by its number or by its name respectively. | ||||||||
respectively. The mixer structure keeps a list of all the devices, but only | The mixer structure keeps a list of all the devices, but only \ | ||||||||
one can be manipulated at a time. Each time a new device is to be manipulated, | one can be manipulated at a time. | ||||||||
one of the two functions has to be called. | Each time a new device is to be manipulated, one of the two functions has to be called. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_set_vol | .Fn mixer_set_vol | ||||||||
function changes the volume of the selected mixer device. The | function changes the volume of the selected mixer device. | ||||||||
The | |||||||||
.Ar vol | .Ar vol | ||||||||
parameter is a structure that stores the left and right volumes of a given | parameter is a structure that stores the left and right volumes of a given device. | ||||||||
device. The allowed volume values are between MIX_VOLMIN (0.0) and | The allowed volume values are between MIX_VOLMIN (0.0) and MIX_VOLMAX (1.0). | ||||||||
MIX_VOLMAX (1.0). | |||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_set_mute | .Fn mixer_set_mute | ||||||||
function modifies the mute of a selected device. The | function modifies the mute of a selected device. | ||||||||
The | |||||||||
.Ar opt | .Ar opt | ||||||||
parameter has to be one of the following options: | parameter has to be one of the following options: | ||||||||
.Bl -tag -width MIX_TOGGLEMUTE -offset indent | .Bl -tag -width MIX_TOGGLEMUTE -offset indent | ||||||||
.It Dv MIX_MUTE | .It Dv MIX_MUTE | ||||||||
Mute the device. | Mute the device. | ||||||||
.It Dv MIX_UNMUTE | .It Dv MIX_UNMUTE | ||||||||
Unmute the device. | Unmute the device. | ||||||||
.It Dv MIX_TOGGLEMUTE | .It Dv MIX_TOGGLEMUTE | ||||||||
Toggle the device's mute (e.g mute if unmuted and unmute if muted). | Toggle the device's mute (e.g mute if unmuted and unmute if muted). | ||||||||
.El | .El | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_mod_recsrc | .Fn mixer_mod_recsrc | ||||||||
function modifies a recording device. The selected device has to be | function modifies a recording device. | ||||||||
a recording device, otherwise the function will fail. The | The selected device has to be a recording device, otherwise the function will fail. | ||||||||
The | |||||||||
.Ar opt | .Ar opt | ||||||||
parameter has to be one of the following options: | parameter has to be one of the following options: | ||||||||
.Bl -tag -width MIX_REMOVERECSRC -offset indent | .Bl -tag -width MIX_REMOVERECSRC -offset indent | ||||||||
.It Dv MIX_ADDRECSRC | .It Dv MIX_ADDRECSRC | ||||||||
Add device to the recording sources. | Add device to the recording sources. | ||||||||
.It Dv MIX_REMOVERECSRC | .It Dv MIX_REMOVERECSRC | ||||||||
Remove device from the recording sources. | Remove device from the recording sources. | ||||||||
.It Dv MIX_SETRECSRC | .It Dv MIX_SETRECSRC | ||||||||
Set device as the only recording source. | Set device as the only recording source. | ||||||||
.It Dv MIX_TOGGLERECSRC | .It Dv MIX_TOGGLERECSRC | ||||||||
Toggle device from the recording sources. | Toggle device from the recording sources. | ||||||||
.El | .El | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_get_dunit | .Fn mixer_get_dunit | ||||||||
and | and | ||||||||
.Fn mixer_set_dunit | .Fn mixer_set_dunit | ||||||||
functions get and set the default audio card in the system. Although this is | functions get and set the default audio card in the system. | ||||||||
not really a mixer feature, it's useful to have instead of having to use | Although this is not really a mixer feature, it's useful to have instead of \ | ||||||||
the | having to use the | ||||||||
.Xr sysctl 3 | .Xr sysctl 3 | ||||||||
controls. | controls. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_get_mode | .Fn mixer_get_mode | ||||||||
function returns the playback/recording mode of the audio device the mixer | function returns the playback/recording mode of the audio device the mixer \ | ||||||||
belongs to. The available values are the following: | belongs to. | ||||||||
The available values are the following: | |||||||||
.Bl -tag -width "MIX_STATUS_PLAY | MIX_STATUS_REC" -offset indent | .Bl -tag -width "MIX_STATUS_PLAY | MIX_STATUS_REC" -offset indent | ||||||||
.It Dv MIX_STATUS_NONE | .It Dv MIX_STATUS_NONE | ||||||||
Neither playback nor recording. | Neither playback nor recording. | ||||||||
.It Dv MIX_STATUS_PLAY | .It Dv MIX_STATUS_PLAY | ||||||||
Playback. | Playback. | ||||||||
.It Dv MIX_STATUS_REC | .It Dv MIX_STATUS_REC | ||||||||
Recording. | Recording. | ||||||||
.It Dv MIX_STATUS_PLAY | MIX_STATUS_REC | .It Dv MIX_STATUS_PLAY | MIX_STATUS_REC | ||||||||
Playback and recording. | Playback and recording. | ||||||||
.El | .El | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_get_nmixers | .Fn mixer_get_nmixers | ||||||||
function returns the total number of mixer devices in the system. | function returns the total number of mixer devices in the system. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn MIX_ISDEV | .Fn MIX_ISDEV | ||||||||
macro checks if a device is actually a valid device for a given mixer. It's very | macro checks if a device is actually a valid device for a given mixer. | ||||||||
unlikely that this macro will ever be needed since the library stores only | It's very unlikely that this macro will ever be needed since the library \ | ||||||||
valid devices by default. | stores only valid devices by default. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn MIX_ISMUTE | .Fn MIX_ISMUTE | ||||||||
macro checks if a device is muted. | macro checks if a device is muted. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn MIX_ISREC | .Fn MIX_ISREC | ||||||||
macro checks if a device is a recording device. | macro checks if a device is a recording device. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn MIX_ISRECSRC | .Fn MIX_ISRECSRC | ||||||||
macro checks if a device is a recording source. | macro checks if a device is a recording source. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn MIX_VOLNORM | .Fn MIX_VOLNORM | ||||||||
macro normalizes a value to 32-bit floating point number. It's used | macro normalizes a value to 32-bit floating point number. | ||||||||
to normalize the volumes read from the OSS API. | It's used to normalize the volumes read from the OSS API. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn MIX_VOLDENORM | .Fn MIX_VOLDENORM | ||||||||
macro denormalizes the left and right volumes stores in the | macro denormalizes the left and right volumes stores in the | ||||||||
.Ft mix_dev | .Ft mix_dev | ||||||||
structure. | structure. | ||||||||
.Ss Defining and using mixer controls | .Ss Defining and using mixer controls | ||||||||
.Pp | |||||||||
The | The | ||||||||
.Fn mix_add_ctl | .Fn mix_add_ctl | ||||||||
function creates a control and attaches it to the device specified in the | function creates a control and attaches it to the device specified in the | ||||||||
.Ar parent | .Ar parent | ||||||||
argument. | argument. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mix_add_ctl_s | .Fn mix_add_ctl_s | ||||||||
function does the same thing as with | function does the same thing as with | ||||||||
.Fn mix_add_ctl | .Fn mix_add_ctl | ||||||||
but the caller passes a | but the caller passes a | ||||||||
.Ft mix_ctl_t * | .Ft mix_ctl_t * | ||||||||
structure instead of each field as a seperate argument. | structure instead of each field as a seperate argument. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_remove_ctl | .Fn mixer_remove_ctl | ||||||||
functions removes a control from the device its attached to. | functions removes a control from the device its attached to. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_get_ctl | .Fn mixer_get_ctl | ||||||||
function searches for a control in the device specified in the | function searches for a control in the device specified in the | ||||||||
.Ar d | .Ar d | ||||||||
argument and returns a pointer to it. The search is done using the control's ID. | argument and returns a pointer to it. | ||||||||
The search is done using the control's ID. | |||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_get_ctl_byname | .Fn mixer_get_ctl_byname | ||||||||
function is the same as with | function is the same as with | ||||||||
.Fn mixer_get_ctl | .Fn mixer_get_ctl | ||||||||
but the search is done using the control's name. | but the search is done using the control's name. | ||||||||
.Sh RETURN VALUES | .Sh RETURN VALUES | ||||||||
.Pp | |||||||||
The | The | ||||||||
.Fn mixer_open | .Fn mixer_open | ||||||||
function returns the newly created handle on success and NULL on failure. | function returns the newly created handle on success and NULL on failure. | ||||||||
.Pp | .Pp | ||||||||
The | The | ||||||||
.Fn mixer_close , | .Fn mixer_close , | ||||||||
.Fn mixer_set_vol , | .Fn mixer_set_vol , | ||||||||
.Fn mixer_set_mute , | .Fn mixer_set_mute , | ||||||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(dp, &m->devs, devs) { | ||||||||
if (M_ISRECSRC(m, dp->devno)) | if (M_ISRECSRC(m, dp->devno)) | ||||||||
printf("%s\\t%.2f:%.2f\\n", | printf("%s\\t%.2f:%.2f\\n", | ||||||||
dp->name, dp->vol.left, dp->vol.right); | dp->name, dp->vol.left, dp->vol.right); | ||||||||
} | } | ||||||||
(void)mixer_close(m); | (void)mixer_close(m); | ||||||||
.Ed | .Ed | ||||||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||||||
.Xr mixer 8 , | .Xr queue 3 , | ||||||||
.Xr sound 4 , | |||||||||
.Xr sysctl 3 , | .Xr sysctl 3 , | ||||||||
.Xr queue 3 | .Xr sound 4 , | ||||||||
.Xr mixer 8 | |||||||||
and | and | ||||||||
.Xr errno 2 | .Xr errno 2 | ||||||||
.Sh AUTHORS | .Sh AUTHORS | ||||||||
.An Christos Margiolis Aq Mt christos@FreeBSD.org | .An Christos Margiolis Aq Mt christos@FreeBSD.org |