Page MenuHomeFreeBSD

sound(4): mixer: implement (un)muting
ClosedPublic

Authored by christos on Jul 10 2021, 11:07 AM.

Details

Summary

Re-implemented the SOUND_MIXER_WRITE_MUTE and SOUND_MIXER_READ_MUTE
ioctls. These two ioctls were not part of the current version of OSS and were considered
obsolete. However, their behaviour is not the same as their old one, so this implementation
is not backwards compatible.

Older OSS versions had the MUTE ioctls take/return an integer with a value of 0 or 1,
which meant that the _whole_ mixer is unmuted or muted respectively. In my
implementation, the ioctl takes/returns a bitmask that tells us which devices are muted.
This allows us to (un)mute only the devices we want, instead of the whole mixer. The
bitmask works the same way as in DEVMASK, RECMASK and RECSRC.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

christos created this revision.
sys/dev/sound/pcm/mixer.c
381

Can you explain what the += is doing?

Possibly you want:

if (mixer_set(mixer, i, v))
ret = XXX;

sys/dev/sound/pcm/mixer.c
381

Can you explain what the += is doing?

It collects the return values of mixer_set. Without any errors they should
all be zero, so we'll return a non-zero value only in case of an error. I did it so
we go through all devices and not return from mixer_setmute the first
time mixer_set fails.

Possibly you want:

if (mixer_set(mixer, i, v))
ret = XXX;

That's a good idea as well.

sys/dev/sound/pcm/mixer.c
356

Have you checked if this function needs any serialization?

750

The mixer object is allocated using M_ZERO, so you can remove this "= 0" I think.

761

Ditto.

christos added inline comments.
sys/dev/sound/pcm/mixer.c
356

Have you checked if this function needs any serialization?

356

Have you checked if this function needs any serialization?

Not really. Can you elaborate more on this?

christos marked an inline comment as not done.Jul 11 2021, 12:24 PM
This revision is now accepted and ready to land.Jul 21 2021, 8:38 AM