HomeFreeBSD

sound: Use unr(9) to produce unique channel unit numbers

Description

sound: Use unr(9) to produce unique channel unit numbers

Currently it is possible to assign a unit number that already exists.
Suppose the following channel list:

[vp2]

If we create 3 channels, we'll end up with the following list:

[vp0, vp1, vp2, vp2]

This happens because chn_init() does not check if the unit number we are
assigning already exists. While fixing this is trivial when the channel
list is sorted in ascending order, it is way more involved when sorted
in descending order. Even though sorting the list in descending order
would require deliberately modifying pcm_chn_add(), and is most likely
not going to happen, make the mechanism more robust by using a unr(9)
allocator for each channel type.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D46680

Details

Provenance
christosAuthored on Fri, Oct 18, 8:39 AM
Reviewer
dev_submerge.ch
Differential Revision
D46680: sound: Use unr(9) to produce unique channel unit numbers
Parents
rG142aca25b07c: sound: Sort channels by unit number as well
Branches
Unknown
Tags
Unknown