sound: Initial mixer cleanup #18

Open
christos wants to merge 12 commits from christos/mixer into main AGit
Member

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Sponsored by: The FreeBSD Foundation MFC after: 1 week
Even though harmless, it is not really useful, as there is essentially
only one allocation with M_MIXER.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This function never succeeds when it is not called from the same process
that has opened the file descriptor (e.g., mixer(8)). The reason is that
the CHN_FOREACH() loop tries to match the pid of each channel with the
pid of the process performing the ioctl, which will not be the same,
unless it's the same process that both opened the channel and performed
the ioctl.

In the case that the same process opens the channels and performs the
ioctl, however, we still do not need to worry, because mixer_ioctl_cmd()
essentially does the same thing anyway. Additionally, this scenario
should be quite rare, given that most applications do not open both
/dev/dsp* and /dev/mixer*, and in fact, it is actively encouraged by the
official OSSv4 specification not to do that.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
In similar fashion to c234740c9d ("snd_uaudio: Do not use
pcm_channel->lock to protect uaudio_chan"), stop this layering
violation, and introduce a snd_uaudio(4)-internal mixer_lock.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
There is no reason to lock snd_mixer->lock here, since the only thing we
are doing with snd_mixer is to call mix_getdevinfo() and mix_get_dev(),
which are one-line getters, which are needed to eventually call
uaudio_get_child_index_by_dev().

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
These functions are called from sound(4) through MIXER_SET() in
mixer_set(), but nothing mixer-related is used or needs to be locked in
these cases.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Instead of caching this when mix_setrecdevs() is called (which many
drivers never call), calculate it when we need it. After all, it is
quite rare that this structure is used by applications.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
I am not sure why this hack was needed, but the size should be
sizeof(struct snd_mixer). Unfortunately, we have to expose snd_mixer,
but it should be better than relying on a hack.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
sound: Update mixer.c LICENSE header
Some checks failed
Checklist / commit (pull_request_target) Has been cancelled
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Has been cancelled
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Has been cancelled
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Has been cancelled
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Has been cancelled
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Has been cancelled
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Has been cancelled
Style Checker / Style Checker (pull_request) Has been cancelled
6baa694064
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Some checks failed
Checklist / commit (pull_request_target) Has been cancelled
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Has been cancelled
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Has been cancelled
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Has been cancelled
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Has been cancelled
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Has been cancelled
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Has been cancelled
Style Checker / Style Checker (pull_request) Has been cancelled
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin +refs/pull/18/head:christos/mixer
git switch christos/mixer
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
FreeBSD/src!18
No description provided.