Page MenuHomeFreeBSD

sound: Make dev.pcm.X.mode dynamic
ClosedPublic

Authored by christos on Feb 15 2025, 2:29 PM.
Tags
None
Referenced Files
F147387289: D49024.id152117.diff
Tue, Mar 10, 1:37 PM
F147387274: D49024.id152117.diff
Tue, Mar 10, 1:37 PM
Unknown Object (File)
Fri, Mar 6, 8:23 PM
Unknown Object (File)
Fri, Mar 6, 4:04 AM
Unknown Object (File)
Fri, Feb 27, 4:28 PM
Unknown Object (File)
Feb 9 2026, 1:30 AM
Unknown Object (File)
Feb 5 2026, 12:31 PM
Unknown Object (File)
Jan 22 2026, 2:32 PM
Subscribers

Details

Summary

Currently dev.pcm.X.mode is calculated only once in pcm_sysinit(), which
is called by pcm_register() during attach, but this can result in
inconsistencies.

For some context, what pcm_mode_init() does is, it checks if "playcount"
is positive, in which case we assume the device supports playback. The
same is done for "reccount" for recording, and if "mixer_dev" is not
NULL, we know the device has a mixer.

The "playcount" and "reccount" variables correspond to the number of
_primary_ playback/recording channels, so we can assume that the primary
channels have been created before reaching pcm_mode_init(). However, for
the mixer that's not always the case. If the mixer is created _after_
pcm_register(), as is the case for snd_dummy(4) for example,
pcm_mode_init() will see that "mixer_dev" is NULL, and report that the
device does not have a mixer, whereas in reality we just created it
afterwards.

While this could be fixed by simply creating the mixers always before
pcm_register(), it is better to be robust and calculate the mode
dynamically.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

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