sound: Simplify unit fetching in dsp_oss_audioinfo()
"i" keeps the value of the current unit, so we do not have to call PCMUNIT() and device_get_unit() to fetch it. In the mixer case, I think it is more correct to do it like this, since mixer and DSP device units have a 1-1 relationship (i.e the mixer unit is always the same as the corresponding DSP device one) and that way we can make it more clear. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44855
This commit is contained in:
@@ -2177,7 +2177,7 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai)
|
|||||||
struct pcm_channel *ch;
|
struct pcm_channel *ch;
|
||||||
struct snddev_info *d;
|
struct snddev_info *d;
|
||||||
uint32_t fmts;
|
uint32_t fmts;
|
||||||
int i, nchan, *rates, minch, maxch;
|
int i, nchan, *rates, minch, maxch, unit;
|
||||||
char *devname, buf[CHN_NAMELEN];
|
char *devname, buf[CHN_NAMELEN];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2197,9 +2197,9 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai)
|
|||||||
* Search for the requested audio device (channel). Start by
|
* Search for the requested audio device (channel). Start by
|
||||||
* iterating over pcm devices.
|
* iterating over pcm devices.
|
||||||
*/
|
*/
|
||||||
for (i = 0; pcm_devclass != NULL &&
|
for (unit = 0; pcm_devclass != NULL &&
|
||||||
i < devclass_get_maxunit(pcm_devclass); i++) {
|
unit < devclass_get_maxunit(pcm_devclass); unit++) {
|
||||||
d = devclass_get_softc(pcm_devclass, i);
|
d = devclass_get_softc(pcm_devclass, unit);
|
||||||
if (!PCM_REGISTERED(d))
|
if (!PCM_REGISTERED(d))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -2324,14 +2324,13 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai)
|
|||||||
* @todo @c port_number - routing information?
|
* @todo @c port_number - routing information?
|
||||||
*/
|
*/
|
||||||
ai->port_number = -1;
|
ai->port_number = -1;
|
||||||
ai->mixer_dev = (d->mixer_dev != NULL) ? PCMUNIT(d->mixer_dev) : -1;
|
ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1;
|
||||||
/**
|
/**
|
||||||
* @note
|
* @note
|
||||||
* @c real_device - OSSv4 docs: "Obsolete."
|
* @c real_device - OSSv4 docs: "Obsolete."
|
||||||
*/
|
*/
|
||||||
ai->real_device = -1;
|
ai->real_device = -1;
|
||||||
snprintf(ai->devnode, sizeof(ai->devnode),
|
snprintf(ai->devnode, sizeof(ai->devnode), "/dev/dsp%d", unit);
|
||||||
"/dev/dsp%d", device_get_unit(d->dev));
|
|
||||||
ai->enabled = device_is_attached(d->dev) ? 1 : 0;
|
ai->enabled = device_is_attached(d->dev) ? 1 : 0;
|
||||||
/**
|
/**
|
||||||
* @note
|
* @note
|
||||||
|
|||||||
Reference in New Issue
Block a user