Page MenuHomeFreeBSD

sound: Simplify how snd_mixer is fetched and how the cdev is created
ClosedPublic

Authored by christos on Aug 21 2026, 12:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 10, 12:29 PM
Unknown Object (File)
Sat, Oct 10, 12:28 PM
Unknown Object (File)
Mon, Oct 5, 1:13 AM
Unknown Object (File)
Sun, Oct 4, 2:34 PM
Unknown Object (File)
Sun, Oct 4, 2:34 PM
Unknown Object (File)
Sun, Oct 4, 2:13 AM
Unknown Object (File)
Sat, Oct 3, 12:18 AM
Unknown Object (File)
Fri, Oct 2, 11:58 PM
Subscribers

Details

Summary

The primary snd_mixer was reached by accessing the mixer cdev's si_drv1.
This is tedious and ugly, so store the mixer in snddev_info->mixer and
access it directly.

Additionally, create the cdev in a new mixer_make_dev() function (in
similar fashion to dsp_make_dev()) in pcm_register(), when everything is
initialized, instead of risking potential races because mixer_init()
(called before pcm_register()) used to create the cdev.

Also add some NULL checks in pcm_register(), to avoid creating a mixer
cdev when the driver (e.g., fdt/audio_soc.c) does not create a mixer in
the first place, and similarly in pcm_unregister().

Sponsored by: The FreeBSD Foundation
MFC after: 1 month

Diff Detail

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