[Bug 277615] /usr/sbin/mixer -a does not display all mixer devices if /dev/mixer0 happens to not exist.
Date: Sat, 25 May 2024 19:32:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277615 --- Comment #3 from commit-hook@FreeBSD.org --- A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=ab7c89415462567665c36628137375847fbff590 commit ab7c89415462567665c36628137375847fbff590 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-05-23 00:57:17 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-05-25 19:30:40 +0000 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 (cherry picked from commit 5d980fadf73df64a1e0eda40a93170ed76ce6f14) lib/libmixer/mixer.3 | 7 +- sys/dev/sound/pcm/dsp.c | 23 +++++- sys/dev/sound/pcm/mixer.c | 201 ++++++++++++++++++++++++---------------------- sys/dev/sound/pcm/mixer.h | 2 - sys/dev/sound/pcm/sound.c | 41 ++++++---- 5 files changed, 155 insertions(+), 119 deletions(-) -- You are receiving this mail because: You are the assignee for the bug.