sound: Fix oss_sysinfo->numcards

According to the OSS manual, oss_sysinfo->numcards holds the number of
detected audio devices in the system, while the current ncards variable,
whose value is assigned to oss_sysinfo->numcards, holds the number of
currently registered devices only.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D45136

(cherry picked from commit 59d98edae3e1a6fffd292e4393c49862d624f25f)
(cherry picked from commit 2b36982887)

Approved by:	re (cperciva)
This commit is contained in:
Christos Margiolis 2024-05-09 21:08:01 +02:00
parent a4a473104e
commit a0ff4e0f3e

View file

@ -1107,9 +1107,7 @@ sound_oss_sysinfo(oss_sysinfo *si)
struct snddev_info *d;
struct pcm_channel *c;
int i, j, ncards;
ncards = 0;
int i, j;
strlcpy(si->product, si_product, sizeof(si->product));
strlcpy(si->version, si_version, sizeof(si->version));
@ -1118,7 +1116,7 @@ sound_oss_sysinfo(oss_sysinfo *si)
/*
* Iterate over PCM devices and their channels, gathering up data
* for the numaudios, ncards, and openedaudio fields.
* for the numaudios and openedaudio fields.
*/
si->numaudios = 0;
bzero((void *)&si->openedaudio, sizeof(si->openedaudio));
@ -1138,7 +1136,6 @@ sound_oss_sysinfo(oss_sysinfo *si)
PCM_LOCK(d);
si->numaudios += d->devcount;
++ncards;
CHN_FOREACH(c, d, channels.pcm) {
CHN_UNLOCKASSERT(c);
@ -1169,7 +1166,7 @@ sound_oss_sysinfo(oss_sysinfo *si)
si->nummidis = 0;
si->numtimers = 0;
si->nummixers = mixer_count;
si->numcards = ncards;
si->numcards = devclass_get_maxunit(pcm_devclass);
/* OSSv4 docs: Intended only for test apps; API doesn't
really have much of a concept of cards. Shouldn't be
used by applications. */