Page MenuHomeFreeBSD

sound: Get rid of snddev_info->devcount
ClosedPublic

Authored by christos on Apr 18 2024, 6:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 4 2024, 11:55 PM
Unknown Object (File)
Oct 4 2024, 8:52 PM
Unknown Object (File)
Oct 2 2024, 7:25 AM
Unknown Object (File)
Oct 1 2024, 1:03 AM
Unknown Object (File)
Sep 30 2024, 4:38 PM
Unknown Object (File)
Sep 27 2024, 7:57 AM
Unknown Object (File)
Sep 27 2024, 4:54 AM
Unknown Object (File)
Sep 26 2024, 7:28 AM
Subscribers

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/sound/pcm/sound.h
179

I added this in the header file in case it is useful outside sound.c in the future. We could also have it in sound.c, or just not have it at all and calculate the sum directly in sound_oss_sysinfo(), but I thought it'd be good to have it like this.

sys/dev/sound/pcm/sound.c
605

What if the channel type is not one of the four counted above? Is that possible at all?

sys/dev/sound/pcm/sound.h
373
christos added inline comments.
sys/dev/sound/pcm/sound.c
605

Not really possible, no. We can only have hw channels or vchans. I do not really know what the default case is here for. pcm_chn_add() is always called after pcm_chn_create(), and if pcm_chn_create() fails (one of the reasons being that the channel type is not one of the ones listed above), pcm_chn_add() won't get called in the first place. So I think it's safe to assume that it's not possible to end up with a type other than those.

markj added inline comments.
sys/dev/sound/pcm/sound.c
605

Perhaps we should assert that the default case is never reached? (Add __assert_unreachable() in that case.)

This revision is now accepted and ready to land.Apr 18 2024, 8:29 PM
sys/dev/sound/pcm/sound.c
605

I have to think about whether it to do this or clean up the control flow of these functions in general, so I will leave it as is for now.

This revision was automatically updated to reflect the committed changes.