Date: Tue, 24 Feb 2026 22:07:49 -0500 (EST) From: "Sean C. Farley" <scf@FreeBSD.org> To: Christos Margiolis <christos@FreeBSD.org> Cc: freebsd-multimedia@FreeBSD.org Subject: Re: Muting only affects audio that is playing Message-ID: <33ac0089-04d0-1cdf-d9ec-e9eba0be9b72@FreeBSD.org> In-Reply-To: <DFICY1MMK3A4.YSKTYH83NUY4@FreeBSD.org> References: <8028333b-f7c1-7992-1016-4194623fce38@FreeBSD.org> <DEUKE1MYMQJY.JDSTZX83BW19@FreeBSD.org> <598a46dd-3abc-2a72-3f58-a9ca16ab3bb0@FreeBSD.org> <DFE9SJR00WMV.6STGABH2CYSU@FreeBSD.org> <33aa299e-2fef-6920-ba56-4307b3b34f8e@FreeBSD.org> <DFICY1MMK3A4.YSKTYH83NUY4@FreeBSD.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
On Wed, 7 Jan 2026, Christos Margiolis wrote:
> On Sat Jan 3, 2026 at 9:44 PM CET, Sean C. Farley wrote:
>> On Fri, 2 Jan 2026, Christos Margiolis wrote:
>>> That's odd indeed. What is the output of mixer(8) once the sound is
>>> unmuted? Does this happen with other audio devices (if you have any), or
>>> only with this one?
>>
>> If the mixer is in the muted state, then it remains that way even after
>> the sound is being output:
>> vol = 0.50:0.50 pbk mute
>>
>> Apparently, the issue is only with this card. I just enabled the
>> onboard audio device (ALC4080), and it does not exhibit the same
>> problem. This is probably why I wondered if this problem was new as I
>> had switched a few months ago to the sound card. I thought I had just
>> not run into it before now.
>
> But what this *not* a problem with the card in question at some point in
> the past? Or did it appear after some update?
>
>> uaudio0: <Generic USB Audio, class 239/2, rev 2.00/0.03, addr 1> on usbus0
>> ugen0.2: <USB Audio ASUSTek Computer, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)
>>
>> It is probably unrelated, but I did hear a hum just now from my speakers
>> although nothing was playing. Reseating the audio cables fixed it.
>> They are pretty old Altec Lansing speakers but still sound very nice.
>>
>> One more oddity but extremely rare. I have heard music from my speakers
>> when the power for the speakers was off. That was when I was using the
>> onboard sound.
>
> This sound more like a hardware issue, but I'm not entirely sure without
> more information, unfortunately.
OK. With help from a couple of AI chatbots and lots of pulling my hair
out due those AI chatbots, I have a fix for the issue. It took much
longer than I expected, mostly due to my lack of knowledge about the
sound system.
Now, this only fixes what I hear regarding vol.mute. pcm.mute still
exhibits the problem but would have to be fixed elsewhere, probably
within the channel code.
A commit message/description of it:
-------------------
sound: enforce MASTER volume mute during playback
MASTER mute (vol.mute) works while audio is playing. However, if a
stream is stopped and restarted (PCMTRIG_STOP -> PCMTRIG_START), the
audio will resume even though the mixer shows the MASTER volume as
muted. Other streams that are already playing remain silent. New
streams may also start playing audio regardless of the MASTER mute
state.
The volume feeder now considers the MASTER mute when determining whether
a channel should be muted. This ensures MASTER mute is consistently
enforced for all streams and removes the dependency on trigger-driven
state propagation.
Tested with Creative Labs CA0132 card.
-------------------
I am also attaching a patch for dsp.c to use chn_getmute_matrix()
instead of CHN_GETMUTE(), but it is cosmetic.
Sean
--
scf@FreeBSD.org
[-- Attachment #2 --]
diff --git a/sys/dev/sound/pcm/feeder_volume.c b/sys/dev/sound/pcm/feeder_volume.c
index ddcbf29804f3..a40aecf3675e 100644
--- a/sys/dev/sound/pcm/feeder_volume.c
+++ b/sys/dev/sound/pcm/feeder_volume.c
@@ -244,11 +244,14 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
{
int temp_vol[SND_CHN_T_VOL_MAX];
struct feed_volume_info *info;
+ struct snd_mixer *m;
+ struct snddev_info *d;
uint32_t j, align;
int i, *matrix;
uint8_t *dst;
const int16_t *vol;
const int8_t *muted;
+ uint8_t master_muted = 0;
/*
* Fetch filter data operation.
@@ -280,8 +283,15 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
return (FEEDER_FEED(f->source, c, b, count, source));
/* Check if any controls are muted. */
+ d = c->parentsnddev;
+ if (d != NULL && d->mixer_dev != NULL) {
+ m = (struct snd_mixer *)c->parentsnddev->mixer_dev->si_drv1;
+ if (m != NULL)
+ master_muted = (mix_getmutedevs(m) &
+ (1 << SND_VOL_C_MASTER)) != 0;
+ }
for (j = 0; j != SND_CHN_T_VOL_MAX; j++)
- temp_vol[j] = muted[j] ? 0 : vol[j];
+ temp_vol[j] = (muted[j] || master_muted) ? 0 : vol[j];
dst = b;
align = info->bps * info->channels;
[-- Attachment #3 --]
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index fe5576baf017..86ecf981d4e8 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -626,8 +626,9 @@ dsp_ioctl_channel(struct dsp_cdevpriv *priv, struct pcm_channel *ch,
case MIXER_READ(0):
switch (j) {
case SOUND_MIXER_MUTE:
- mute = CHN_GETMUTE(ch, SND_VOL_C_PCM, SND_CHN_T_FL) ||
- CHN_GETMUTE(ch, SND_VOL_C_PCM, SND_CHN_T_FR);
+ mute = chn_getmute_matrix(ch, SND_VOL_C_PCM,
+ SND_CHN_T_FL) ||
+ chn_getmute_matrix(ch, SND_VOL_C_PCM, SND_CHN_T_FR);
if (ch->direction == PCMDIR_REC) {
*(int *)arg = mute << SOUND_MIXER_RECLEV;
} else {
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33ac0089-04d0-1cdf-d9ec-e9eba0be9b72>
