sound: Get rid of snddev_info->devcount

snddev_info->devcount keeps track of the total number of channels for a
given device. However, it is redundant to have it, since it is only used
in sound_oss_sysinfo() to populate the "numaudios" field, and we also
keep track of the channel counts in the playcount, pvchancount, reccount
and rvchancount fields anyway. We can simply sum those fields together
instead of updating a separate variable upon every channel
addition/deletion.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44852

(cherry picked from commit 4d2be7be3837d66ba242a0a7fd51632c3f89285d)
This commit is contained in:
Christos Margiolis 2024-04-18 22:35:06 +02:00
parent 69707d9f50
commit d27972ec91
2 changed files with 5 additions and 7 deletions

View file

@ -602,8 +602,6 @@ pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch)
break;
}
d->devcount++;
return (0);
}
@ -644,8 +642,6 @@ pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch)
break;
}
d->devcount--;
return (0);
}
@ -974,7 +970,6 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
d->flags |= SD_F_BITPERFECT;
d->devinfo = devinfo;
d->devcount = 0;
d->reccount = 0;
d->playcount = 0;
d->pvchancount = 0;
@ -1137,7 +1132,7 @@ sound_oss_sysinfo(oss_sysinfo *si)
PCM_UNLOCKASSERT(d);
PCM_LOCK(d);
si->numaudios += d->devcount;
si->numaudios += PCM_CHANCOUNT(d);
++ncards;
CHN_FOREACH(c, d, channels.pcm) {

View file

@ -175,6 +175,9 @@ struct snd_mixer;
#define PCM_DETACHING(x) ((x)->flags & SD_F_DETACHING)
#define PCM_CHANCOUNT(d) \
(d->playcount + d->pvchancount + d->reccount + d->rvchancount)
/* many variables should be reduced to a range. Here define a macro */
#define RANGE(var, low, high) (var) = \
(((var)<(low))? (low) : ((var)>(high))? (high) : (var))
@ -367,7 +370,7 @@ struct snddev_info {
} opened;
} pcm;
} channels;
unsigned devcount, playcount, reccount, pvchancount, rvchancount ;
unsigned playcount, reccount, pvchancount, rvchancount;
unsigned flags;
unsigned int bufsz;
void *devinfo;