mixer.3 (5d980fadf73df64a1e0eda40a93170ed76ce6f14) mixer.3 (67c89b21b95601c01bafe5a0c518d320a39111c0)
1.\"-
2.\" Copyright (c) 2021-2022 Christos Margiolis <christos@FreeBSD.org>
3.\"
4.\" Permission is hereby granted, free of charge, to any person obtaining a copy
5.\" of this software and associated documentation files (the "Software"), to deal
6.\" in the Software without restriction, including without limitation the rights
7.\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8.\" copies of the Software, and to permit persons to whom the Software is

--- 26 unchanged lines hidden (view full) ---

35.Nm mixer_get_ctl_byname ,
36.Nm mixer_set_vol ,
37.Nm mixer_set_mute ,
38.Nm mixer_mod_recsrc ,
39.Nm mixer_get_dunit ,
40.Nm mixer_set_dunit ,
41.Nm mixer_get_mode ,
42.Nm mixer_get_nmixers ,
1.\"-
2.\" Copyright (c) 2021-2022 Christos Margiolis <christos@FreeBSD.org>
3.\"
4.\" Permission is hereby granted, free of charge, to any person obtaining a copy
5.\" of this software and associated documentation files (the "Software"), to deal
6.\" in the Software without restriction, including without limitation the rights
7.\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8.\" copies of the Software, and to permit persons to whom the Software is

--- 26 unchanged lines hidden (view full) ---

35.Nm mixer_get_ctl_byname ,
36.Nm mixer_set_vol ,
37.Nm mixer_set_mute ,
38.Nm mixer_mod_recsrc ,
39.Nm mixer_get_dunit ,
40.Nm mixer_set_dunit ,
41.Nm mixer_get_mode ,
42.Nm mixer_get_nmixers ,
43.Nm mixer_get_path ,
43.Nm MIX_ISDEV ,
44.Nm MIX_ISMUTE ,
45.Nm MIX_ISREC ,
46.Nm MIX_ISRECSRC ,
47.Nm MIX_VOLNORM ,
48.Nm MIX_VOLDENORM
49.Nd interface to OSS mixers
50.Sh LIBRARY

--- 30 unchanged lines hidden (view full) ---

81.Fn mixer_get_dunit "void"
82.Ft int
83.Fn mixer_set_dunit "struct mixer *m" "int unit"
84.Ft int
85.Fn mixer_get_mode "int unit"
86.Ft int
87.Fn mixer_get_nmixers "void"
88.Ft int
44.Nm MIX_ISDEV ,
45.Nm MIX_ISMUTE ,
46.Nm MIX_ISREC ,
47.Nm MIX_ISRECSRC ,
48.Nm MIX_VOLNORM ,
49.Nm MIX_VOLDENORM
50.Nd interface to OSS mixers
51.Sh LIBRARY

--- 30 unchanged lines hidden (view full) ---

82.Fn mixer_get_dunit "void"
83.Ft int
84.Fn mixer_set_dunit "struct mixer *m" "int unit"
85.Ft int
86.Fn mixer_get_mode "int unit"
87.Ft int
88.Fn mixer_get_nmixers "void"
89.Ft int
90.Fn mixer_get_path "char * buf" "size_t size" "int unit"
91.Ft int
89.Fn MIX_ISDEV "struct mixer *m" "int devno"
90.Ft int
91.Fn MIX_ISMUTE "struct mixer *m" "int devno"
92.Ft int
93.Fn MIX_ISREC "struct mixer *m" "int devno"
94.Ft int
95.Fn MIX_ISRECSRC "struct mixer *m" "int devno"
96.Ft float

--- 296 unchanged lines hidden (view full) ---

393Playback and recording.
394.El
395.Pp
396The
397.Fn mixer_get_nmixers
398function returns the maximum mixer unit number.
399Although this might sound as incorrect behavior, given that one would expect
400"nmixers" to refer to the total number of active mixers, it is more intuitive
92.Fn MIX_ISDEV "struct mixer *m" "int devno"
93.Ft int
94.Fn MIX_ISMUTE "struct mixer *m" "int devno"
95.Ft int
96.Fn MIX_ISREC "struct mixer *m" "int devno"
97.Ft int
98.Fn MIX_ISRECSRC "struct mixer *m" "int devno"
99.Ft float

--- 296 unchanged lines hidden (view full) ---

396Playback and recording.
397.El
398.Pp
399The
400.Fn mixer_get_nmixers
401function returns the maximum mixer unit number.
402Although this might sound as incorrect behavior, given that one would expect
403"nmixers" to refer to the total number of active mixers, it is more intuitive
401for applications that want to loop through all mixer devices.
404for applications that want to loop through all mixer devices (see the
405.Sx EXAMPLES
406section).
402.Pp
403The
407.Pp
408The
409.Fn mixer_get_path
410function writes the path of the mixer device specified in the
411.Ar unit
412argument to the buffer specified in
413.Ar buf .
414.Ar unit
415can be either -1, in which case
416.Fn mixer_get_path
417will fetch the path of the default mixer, or between 0 and the maximum mixer
418unit.
419.Pp
420The
404.Fn MIX_ISDEV
405macro checks if a device is actually a valid device for a given mixer.
406It is very unlikely that this macro will ever be needed since the library \
407stores only valid devices by default.
408.Pp
409The
410.Fn MIX_ISMUTE
411macro checks if a device is muted.

--- 53 unchanged lines hidden (view full) ---

465function returns the newly created handle on success and NULL on failure.
466.Pp
467The
468.Fn mixer_close ,
469.Fn mixer_set_vol ,
470.Fn mixer_set_mute ,
471.Fn mixer_mod_recsrc ,
472.Fn mixer_get_dunut ,
421.Fn MIX_ISDEV
422macro checks if a device is actually a valid device for a given mixer.
423It is very unlikely that this macro will ever be needed since the library \
424stores only valid devices by default.
425.Pp
426The
427.Fn MIX_ISMUTE
428macro checks if a device is muted.

--- 53 unchanged lines hidden (view full) ---

482function returns the newly created handle on success and NULL on failure.
483.Pp
484The
485.Fn mixer_close ,
486.Fn mixer_set_vol ,
487.Fn mixer_set_mute ,
488.Fn mixer_mod_recsrc ,
489.Fn mixer_get_dunut ,
473.Fn mixer_set_dunit
490.Fn mixer_set_dunit ,
491.Fn mixer_get_nmixers ,
474and
492and
475.Fn mixer_get_nmixers
493.Fn mixer_get_path
476functions return 0 or positive values on success and -1 on failure.
477.Pp
478The
479.Fn mixer_get_dev
480and
481.Fn mixer_get_dev_byname
482functions return the selected device on success and NULL on failure.
483.Pp

--- 53 unchanged lines hidden (view full) ---

537TAILQ_FOREACH(dp, &m->devs, devs) {
538 if (M_ISRECSRC(m, dp->devno))
539 printf("%s\\t%.2f:%.2f\\n",
540 dp->name, dp->vol.left, dp->vol.right);
541}
542
543(void)mixer_close(m);
544.Ed
494functions return 0 or positive values on success and -1 on failure.
495.Pp
496The
497.Fn mixer_get_dev
498and
499.Fn mixer_get_dev_byname
500functions return the selected device on success and NULL on failure.
501.Pp

--- 53 unchanged lines hidden (view full) ---

555TAILQ_FOREACH(dp, &m->devs, devs) {
556 if (M_ISRECSRC(m, dp->devno))
557 printf("%s\\t%.2f:%.2f\\n",
558 dp->name, dp->vol.left, dp->vol.right);
559}
560
561(void)mixer_close(m);
562.Ed
563.Ss Loop through all mixer devices in the system
564.Bd -literal
565struct mixer *m;
566char buf[NAME_MAX];
567int n;
568
569if ((n = mixer_get_nmixers()) < 0)
570 errx(1, "no mixers present in the system");
571for (i = 0; i < n; i++) {
572 (void)mixer_get_path(buf, sizeof(buf), i);
573 if ((m = mixer_open(buf)) == NULL)
574 continue;
575 ...
576 (void)mixer_close(m);
577}
578.Ed
545.Sh SEE ALSO
546.Xr queue 3 ,
547.Xr sysctl 3 ,
548.Xr sound 4 ,
549.Xr mixer 8
550and
551.Xr errno 2
552.Sh AUTHORS
553.An Christos Margiolis Aq Mt christos@FreeBSD.org
579.Sh SEE ALSO
580.Xr queue 3 ,
581.Xr sysctl 3 ,
582.Xr sound 4 ,
583.Xr mixer 8
584and
585.Xr errno 2
586.Sh AUTHORS
587.An Christos Margiolis Aq Mt christos@FreeBSD.org