The unit.* code is largely obsolete and imposes limits that are no
longer needed nowadays.
- Capping the maximum allowed soundcards in a given machine. By default,
the limit is 512 (snd_max_u() in unit.c), and the maximum possible is
2048 (SND_UNIT_UMAX in unit.h). It can also be tuned through the
hw.snd.maxunit loader(8) tunable. Even though these limits are large
enough that they should never cause problems, there is no need for
this limit to exist in the first place.
- Capping the available device/channel types. By default, this is 32
(snd_max_d() in unit.c). However, these types are pre-defined in
pcm/sound.h (see SND_DEV_*), so the cap is unnecessary when we know
that their number is constant.
- Capping the number of channels per-device. By default, the limit 1024
(snd_max_c() in unit.c). This is probably the most problematic of the
limits mentioned, because this limit can never be reached, as the
maximum is hard-capped at either hw.snd.maxautovchans (16 by default),
or SND_MAXHWCHAN and SND_MAXVCHANS.
TheThese limtits mentioned above are encoded in a bitfield of the formare encoded in masks (see SND_U_MASK, SND_D_MASK,
[dsp_SND_C_MASK in unit, type, channel_unit] in snd_mkunit() and assigned to.h) and are used to construct a bitfield of the form
pcm_channel->unit.[dsp_unit, type, This patch makes a slightly different use of thechannel_unit] in snd_mkunit() which is assigned to
"unit" field to only contain the channelpcm_channel->unit.
This patch gets rid of everything unit number. The device type is.*-related and makes a slightly
stored in a new pcm_channel->typedifferent use of the "unit" field, and the DSP unit number need to only contain the channel unit
not benumber. The channel type is stored at allin a new pcm_channel->type field, since we can fetch it fromand
device_get_the DSP unit(pcm_channel->parentsnddev->dev). number need not be stored at all, This change has thesince we can fetch it
effect that we no longer need to impose caps on DSP devices numbers,from device_get_unit(pcm_channel->parentsnddev->dev). This change has
device/channel types or per-device channels. As a resultthe effect that we no longer need to impose caps on the code isnumber of
soundcards, device/channel types and per-device channels. As a result
the code is noticeably simplified and more readable.
Apart from the fact that the hw.snd.maxunit loader(8) tunable is retiredalso
retired as a side-effect of this patch, sound(4)'s behavior remains the
same.
Sponsored by: The FreeBSD Foundation
MFC after: 1 month