freebsd-src/lib
Christos Margiolis 5d980fadf7 sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer
devices in the system. To do this, it loops from 0 to
mixer_get_nmixers(), and tries to open "/dev/mixer%d". However, this
approach doesn't work when there are disabled/unregistered mixers in the
system, or when an audio device simply doesn't have a mixer.

mixer_get_nmixers() calls SNDCTL_SYSINFO and returns
oss_sysinfo->nummixers, whose value is the number of currently _enabled_
mixers only. Taking the bug report mentioned below (277615) as an
example, suppose a system with 8 mixer devices total, but 3 of them are
either disabled or non-existent, which means they will not show up under
/dev, meaning we have 5 enabled mixer devices, which is also what the
value of oss_sysinfo->nummixers will be. What mixer(8) will do is loop
from 0 to 5 (instead of 8), and start calling mixer_open() on
/dev/mixer0, up to /dev/mixer4, and as is expected, the first call will
fail right away, hence the error shown in the bug report.

To fix this, modify oss_sysinfo->nummixers to hold the value of the
maximum unit in the system, which, although not necessarily "correct",
is more intuitive for applications that will want to use this value to
loop through all mixer devices.

Additionally, notify applications that a device is
unavailable/unregistered instead of skipping it. The current
implementations of SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO and
SNDCTL_CARDINFO break applications that expect to get information about
a device that is skipped. Related discussion can be found here:
https://reviews.freebsd.org/D45135#1029526

It has to be noted, that other applications, apart from mixer(8), suffer
from this.

PR:		277615
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45256
2024-05-23 02:57:17 +02:00
..
atf Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
clang lib/clang: clean out old llvm/clang Sparc target remnants 2024-05-04 19:34:18 +02:00
csu csu: Find the main pointer through the GOT 2024-05-22 08:18:10 +00:00
flua flua: Add hash module 2024-02-15 20:59:23 -07:00
geom glabel.8: Describe cases related to permissions / existing mounts 2024-05-21 15:49:17 -03:00
googletest Fix GoogleTest 1.14.0 import 2023-08-18 19:33:58 -07:00
lib9p dirdeps: Update Makefile.depend* files with empty contents 2023-10-29 17:01:04 -04:00
lib80211 Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
libalias Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libarchive libarchive: fix thread autodetermination for zstd compression format 2024-05-03 15:39:37 +02:00
libauditd package: move OpenBSM auditing into its own package 2024-04-28 22:33:06 -06:00
libbe libbe(3): history: fix 2024-04-09 22:01:10 -06:00
libbearssl bearssl: Make shared library link 2024-02-20 20:31:41 -07:00
libbegemot Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libblacklist Track upstream project rename in contrib/blocklistd 2023-11-03 16:53:04 -04:00
libblocksruntime Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libbluetooth Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
libbsddialog dirdeps: Update Makefile.depend* files with empty contents 2023-10-29 17:01:04 -04:00
libbsdstat libbsdstat: Fix typo in bsdstat.h 2024-02-13 16:53:35 +08:00
libbsm package: move OpenBSM auditing into its own package 2024-04-28 22:33:06 -06:00
libbsnmp Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libbz2 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libc man filesystems: fix xrefs after move to section 4 2024-05-16 10:25:29 -06:00
libc++ Merge llvm-project main llvmorg-18-init-18359-g93248729cfae 2024-04-06 22:13:49 +02:00
libc++experimental Merge llvm-project main llvmorg-18-init-15088-gd14ee76181fb 2024-04-06 22:11:55 +02:00
libc_nonshared Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libcalendar Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libcam lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libcapsicum libcapsicum: document return values 2024-05-16 20:29:18 +02:00
libcasper libcasper: fix cap_rights_init usage 2024-02-14 22:33:24 -05:00
libcbor libcbor: Ignore errors for unknown #pragmas 2024-05-07 11:44:52 -07:00
libclang_rt Merge llvm-project main llvmorg-18-init-15088-gd14ee76181fb 2024-04-06 22:11:55 +02:00
libcom_err Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libcompat libcompat: silence -Wdeprecated-non-prototype 2024-02-06 20:32:46 +01:00
libcompiler_rt libgcc_s: __extendxftf2 and __trunctfxf2 are amd64-only 2024-05-02 18:13:23 +01:00
libcrypt lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libcuse Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
libcxxrt libcxxrt: allow build with gcc13 and --no-undefined-version 2024-05-17 21:50:57 +01:00
libdevctl lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libdevdctl libdevdctl: Fix typo (triple S) 2023-12-27 20:24:30 -07:00
libdevinfo lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libdevstat lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libdiff diff: Nits in tests. 2024-05-20 16:27:50 +02:00
libdl Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libdpv lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libdwarf Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libedit lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
libefivar lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libelf Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libelftc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libevent1 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libexecinfo lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libexpat MFV: expat 2.6.0. 2024-02-17 14:04:14 -08:00
libfdt libfdt: Make an internal FDT library available 2024-03-21 01:05:05 -04:00
libfetch libfetch: parse scheme://domain:/ correctly 2024-03-25 16:11:42 -04:00
libfido2 libfido2: update to 1.14.0 2024-05-04 12:51:08 -04:00
libfigpar lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libgcc_eh libgcc_{eh,s}: restore __*_frame_info symbols post llvm18 2024-04-19 22:56:13 +01:00
libgcc_s libgcc_s: fix nonsense defines 2024-05-17 20:05:36 +01:00
libgeom lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libgpio libgpio: Fix type mismatch for gpio_pin_[gs]et 2023-11-14 18:34:21 -08:00
libgssapi Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libiconv_modules lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libifconfig carp: support VRRPv3 2024-05-08 13:19:03 +02:00
libipsec libipsec: make const-correct 2024-04-22 22:36:34 -06:00
libipt Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libiscsiutil lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libjail libjail: Guard against programmer error in jailparam_export() 2024-02-04 17:52:30 -05:00
libkiconv Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libkvm lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libldns Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
liblua dirdeps: Remove $FreeBSD$ 2023-11-26 15:47:54 -05:00
liblutok Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
liblzma Backport export of lzma_mt_block_size symbol. 2024-04-04 23:39:33 -07:00
libmagic libmagic: Use HOST_CC when compiling hostprog used by build 2024-03-27 19:18:43 -04:00
libmd lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libmemstat lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libmilter Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libmixer sound: Handle unavailable devices in various OSS IOCTLs 2024-05-23 02:57:17 +02:00
libmp Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libmt lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libnetbsd lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libnetgraph lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libnetmap libnetmap: remove interface name validation 2023-12-21 14:43:57 +00:00
libnv lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libnvmf libnvmf: avoid resource leak 2024-05-21 17:41:04 -06:00
libomp arm64: Allow userspace to be built with PAC and BTI 2024-05-22 17:02:26 +00:00
libopenbsd lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libopencsd Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libpam package: move cron into its own package 2024-04-22 22:36:35 -06:00
libpathconv Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libpcap dirdeps: Fix libpcap Makefile.depend.options 2023-11-17 11:34:57 -05:00
libpe Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libpfctl libpfctl: fix file descriptor leak 2024-05-09 14:07:07 +02:00
libpjdlog lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libpmc libpmc: Import AMD Zen 4 PMU events 2024-04-20 11:54:04 -04:00
libpmcstat lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libproc lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libprocstat inpcb: fully retire inp_ppcb pointer 2024-03-29 12:18:32 -07:00
libradius lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libregex dirdeps: Update Makefile.depend* files with empty contents 2023-10-29 17:01:04 -04:00
librpcsec_gss librpcsec_gss: don't export non-existant symbols 2024-04-16 22:14:21 +01:00
librpcsvc lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
librss lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
librt lib{c,rt}: use libsys.h for __sys_* declerations 2024-04-16 17:48:07 +01:00
librtld_db lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libsbuf lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libsdp Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
libsecureboot libsecureboot do not report expected unverified files 2024-02-12 14:35:01 -08:00
libsm Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libsmb Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libsmdb Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libsmutil Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libsqlite3 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libssp Fix the GCC build after _FORTIFY_SOURCE import 2024-05-13 11:21:38 -05:00
libssp_nonshared Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libstats dirdeps: Update Makefile.depend* files with empty contents 2023-10-29 17:01:04 -04:00
libstdbuf Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libstdthreads libstdthreads: destroy mutexattr in mtx_init() 2024-02-04 13:50:56 +02:00
libsys access(2): Discourage use of these system calls. 2024-05-22 00:35:22 +02:00
libsysdecode libsysdecode use MKTABLES_INCLUDEDIR 2024-03-21 11:55:56 -07:00
libtacplus lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libtelnet lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
libthr Add a build knob for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
libthread_db lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libucl Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libufs man filesystems: fix xrefs after move to section 4 2024-05-16 10:25:29 -06:00
libugidfw Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
libulog libulog: Make sure ut_line, ut_user, ut_host are terminated. 2024-04-29 12:11:37 +02:00
libunbound unbound: Vendor import 1.20.0 2024-05-10 14:23:43 -07:00
libusb libusb(3): Fix link in comment 2024-02-13 16:55:54 +08:00
libusbhid lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libutil login_cap.h: Remove LOGIN_DEFPRI 2024-01-29 22:58:10 +01:00
libveriexec lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libvgl lib/libvgl/main.c: remove an extra semicolon 2024-02-02 18:35:01 -07:00
libvmmapi libvmmapi: Conditionalize compilation of some functions 2024-04-10 11:17:56 -04:00
libwrap Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libxo dirdeps: Update Makefile.depend* files with empty contents 2023-10-29 17:01:04 -04:00
liby lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
libypclnt Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libz dirdeps: Update/fix Makefile.depend* for toolchain 2023-11-26 20:50:13 -05:00
libzstd libzstd: Explicitly define ZSTD_DISABLE_ASM 2023-08-22 21:01:03 +01:00
msun pow,powf(3),__ieee754_rem_pio2(f): Avoid negative integer left shift UB 2024-04-23 14:04:07 -06:00
ncurses ncurses: serialize the tinfo build a little bit 2024-01-23 23:00:36 -06:00
nss_tacplus nss_tacplus: Provide dummy setpwent(), getpwent_r(), endpwent(). 2023-08-31 07:49:57 +00:00
ofed Trim various $FreeBSD$ 2023-10-10 10:34:43 -07:00
tests Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile libnvmf: Add internal library to support NVMe over Fabrics 2024-05-02 16:28:16 -07:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00