View previous topic :: View next topic |
Author |
Message |
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Tue May 07, 2024 6:43 am Post subject: pipewire/wireplumber mutes headphones on boot |
|
|
Hi all,
On each boot I need to go to alsamixer and unmute and set volume for the headphones. Once done that, I save the state with Code: | /etc/init.d/alsasound save | , but on next reboot, the headphones will be muted again.
My suspicion is that pipewire/wireplumber are muting the headphones, but I have not been able to identify where in the pipewire.conf
Any ideas?
Thanks _________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
netfab Veteran
Joined: 03 Mar 2005 Posts: 1960 Location: 127.0.0.1
|
Posted: Tue May 07, 2024 7:55 am Post subject: |
|
|
Hi,
Please post the output of :
|
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Tue May 07, 2024 8:15 am Post subject: |
|
|
netfab wrote: | Hi,
Please post the output of :
|
Code: | rc-update
acpid | boot
alsasound | default
binfmt | boot
bootmisc | boot
cgroups | sysinit
dbus | default
dcron | default
devfs | sysinit
display-manager | default
dmesg | sysinit
elogind | boot
fancontrol | default
fsck | boot
hostname | boot
hwclock | boot
iptables | boot
keymaps | boot
killprocs | shutdown
kmod-static-nodes | sysinit
lm_sensors | default
local | default nonetwork
localmount | boot
loopback | boot
modules | boot
mount-ro | shutdown
mpd | default
mtab | boot
net.eno1 | default
net.lo | boot
procfs | boot
root | boot
save-keymaps | boot
save-termencoding | boot
savecache | shutdown
seedrng | boot
swap | boot
sysctl | boot
sysfs | sysinit
syslog-ng | default
systemd-tmpfiles-setup | boot
systemd-tmpfiles-setup-dev | sysinit
termencoding | boot
udev | sysinit
udev-trigger | sysinit
zram-init | boot |
Code: | groups
disk lp wheel cron audio cdrom video games docker kvm libvirt usb transmission vboxusers plugdev lpadmin seat pipewire vmware i2c hammett crypt shutdown |
_________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
netfab Veteran
Joined: 03 Mar 2005 Posts: 1960 Location: 127.0.0.1
|
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Tue May 07, 2024 9:11 am Post subject: |
|
|
I moved the alsasound to boot and removed myself from the audio group, but the problem persists. _________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Tue May 07, 2024 6:12 pm Post subject: |
|
|
Well, the plot thickens....
I confirmed that is pipewire who is muting the headphones. If I restart pipewire with gentoo-pipewire-launcher restart &, then heaphone is muted and at 0% volume.
So I thought that I can automatically unmute it with amixer on my .xprofile: Code: | [hammett][/home/hammett]$ cat .xprofile
gentoo-pipewire-launcher &
dwmblocks &
unmute_headphone & |
Code: | [hammett][/home/hammett]$ cat /usr/local/bin/unmute_headphone
#!/bin/bash
amixer -c 0 set Headphone 60% unmute |
Well, even with that, the headphone volume is muted.
If I manually run the unmute_headphone script, then the headphones start to sound again...
WTF?? _________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
Jimmy Jazz Guru
Joined: 04 Oct 2004 Posts: 333 Location: Strasbourg
|
Posted: Tue May 07, 2024 10:55 pm Post subject: |
|
|
Hammett wrote: | Well, the plot thickens....
I confirmed that is pipewire who is muting the headphones. If I restart pipewire with gentoo-pipewire-launcher restart &, then heaphone is muted and at 0% volume.
So I thought that I can automatically unmute it with amixer on my .xprofile: Code: | [hammett][/home/hammett]$ cat .xprofile
gentoo-pipewire-launcher &
dwmblocks &
unmute_headphone & |
Code: | [hammett][/home/hammett]$ cat /usr/local/bin/unmute_headphone
#!/bin/bash
amixer -c 0 set Headphone 60% unmute |
Well, even with that, the headphone volume is muted.
If I manually run the unmute_headphone script, then the headphones start to sound again...
WTF?? |
certainly unmute_headphone is launched before gentoo-pipewire-launcher commande. The shell '&' is not equivalent to ' ;' _________________ « La seule condition au triomphe du mal, c'est l'inaction des gens de bien » E.Burke
Code: |
+----+----+----+
| |::::| |
| |::::| |
+----+----+----+ |
motto: WeLCRO
WritE Less Code, Repeat Often |
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Wed May 08, 2024 2:24 pm Post subject: |
|
|
Jimmy Jazz wrote: | Hammett wrote: | Well, the plot thickens....
I confirmed that is pipewire who is muting the headphones. If I restart pipewire with gentoo-pipewire-launcher restart &, then heaphone is muted and at 0% volume.
So I thought that I can automatically unmute it with amixer on my .xprofile: Code: | [hammett][/home/hammett]$ cat .xprofile
gentoo-pipewire-launcher &
dwmblocks &
unmute_headphone & |
Code: | [hammett][/home/hammett]$ cat /usr/local/bin/unmute_headphone
#!/bin/bash
amixer -c 0 set Headphone 60% unmute |
Well, even with that, the headphone volume is muted.
If I manually run the unmute_headphone script, then the headphones start to sound again...
WTF?? |
certainly unmute_headphone is launched before gentoo-pipewire-launcher commande. The shell '&' is not equivalent to ' ;' |
I understand the use of & in the .xprofile, but one would expect that this file is sourced top to bottom, so this behaviour *should* not happen.
I can try to bundle the gentoo-pipewire-launcer and the unmute_headphone in a single script and see if that helps _________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22915
|
Posted: Wed May 08, 2024 3:32 pm Post subject: |
|
|
The file is read top-to-bottom, yes, but think about exactly what you are telling it to do:- Create gentoo-pipewire-launcher in the background. Do not wait for it to finish. Hope that the kernel schedules it in a timely manner, and that it finishes all its work quickly.
- Create dwmblocks in the background.
- Create unmute_headphone in the background.
Suppose that the logic of gentoo-pipewire-launcher is:- Run some step that takes 3 seconds.
- Mute headphones
- Do other things
If your unmute_headphone can run to completion in less than 3 seconds, then you unmute before pipewire-launcher can mute it, so your unmute is overwritten seconds later, since mute status is just on/off, not a count of how many mute requests versus unmute requests the system has received. I think you need to find exactly why pipewire is muting your headphones, and either make it not do that, or find how to hook into it so that it runs your unmute script after it has finished muting your headphones. Merely adding a delay before unmute will seem to work until the pipewire launcher takes longer than the delay, at which point it won't work. |
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Wed May 08, 2024 3:51 pm Post subject: |
|
|
Hu wrote: | . I think you need to find exactly why pipewire is muting your headphones, and either make it not do that, |
Indeed this is what I try to do, but for the love of me I cannot find *anywhere* how to do this.
If anyone is able to let me know where I can update the default values of the card profile (Duplex), please let me know
Hu wrote: | Create gentoo-pipewire-launcher in the background. Do not wait for it to finish. Hope that the kernel schedules it in a timely manner, and that it finishes all its work quickly.
Create dwmblocks in the background.
Create unmute_headphone in the background. |
If I add a double "&" after the gentoo-pipewire-launcher, it will wait to run the next line until this command finishes, right? _________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22915
|
Posted: Wed May 08, 2024 4:16 pm Post subject: |
|
|
I do not know how to make Pipewire behave as you desire. Perhaps someone else will have advice on that point.
I would just remove the & and let the shell run the launcher synchronously. Using && will also make it synchronous, and will only run the next command if the launcher exits with a success status code. Note that in both cases, running it synchronously assumes it will exit quickly, which may or may not be the case. I haven't looked at that launcher to know whether it blocks until Pipewire exits at the end of your session, or exits promptly on Pipewire confirming that it can start and background itself. |
|
Back to top |
|
|
Jimmy Jazz Guru
Joined: 04 Oct 2004 Posts: 333 Location: Strasbourg
|
Posted: Wed May 08, 2024 5:01 pm Post subject: |
|
|
in my case .xprofile is sourced so should be yours. If it is not the last one it explain the behaviour.
why not do something like that ?
_________________ « La seule condition au triomphe du mal, c'est l'inaction des gens de bien » E.Burke
Code: |
+----+----+----+
| |::::| |
| |::::| |
+----+----+----+ |
motto: WeLCRO
WritE Less Code, Repeat Often |
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Thu May 09, 2024 7:42 am Post subject: |
|
|
Hu wrote: | I haven't looked at that launcher to know whether it blocks until Pipewire exits at the end of your session, or exits promptly on Pipewire confirming that it can start and background itself. |
I have located the script, and by the looks of it, it would seem it sends pipewire to the background, but not wireplumber
Here's the relevant part: Code: | # The core daemon which by itself does probably nothing.
echo "[$(/bin/date ${DATE_FORMAT})] Starting PipeWire." 1>>"${GENTOO_PIPEWIRE_LOG}"
/usr/bin/pipewire 1>>"${GENTOO_PIPEWIRE_LOG}" 2>&1 &
# The so called pipewire-pulse daemon used for PulseAudio compatibility.
# Commenting this out will stop the PA proxying daemon from starting,
# however ALSA (with pipewire-alsa), JACK (with jack-sdk) and PW API using
# clients will still have access to audio and may end up clashing with
# non-PW apps over HW control (most notably, /usr/bin/pulseaudio daemon).
echo "[$(/bin/date ${DATE_FORMAT})] Starting PipeWire-Pulse." 1>>"${GENTOO_PIPEWIRE_PULSE_LOG}"
/usr/bin/pipewire -c pipewire-pulse.conf 1>>"${GENTOO_PIPEWIRE_PULSE_LOG}" 2>&1 &
# Hack for bug #822498
sleep 1
# Finally a session manager is required for PipeWire to do anything.
echo "[$(/bin/date ${DATE_FORMAT})] Starting WirePlumber." 1>>"${GENTOO_WIREPLUMBER_LOG}"
exec /usr/bin/wireplumber 1>>"${GENTOO_WIREPLUMBER_LOG}" 2>&1 |
I think adding an "&" on the last line will make it run and send it to the background, otherwise would only finish on shutdown.
That "sleep 1" would also explain why the unmute_headphone script is run before Pipewire end its execution. Perhaps adding a sleep to the unmute_headphone would be easier/wiser?
Code: | #!/bin/bash
sleep 2
amixer -c 0 set Headphone 60% unmute |
_________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22915
|
Posted: Thu May 09, 2024 1:54 pm Post subject: |
|
|
Sleeping for 2 seconds would usually result in it running after /usr/bin/pipewire and /usr/bin/wireplumber are started. However, since gentoo-pipewire-launcher is in the background and asynchronous, it's possible (although unlikely) that the kernel would delay the execution of the entire shown script by an arbitrary amount of time, and not delay your hook script at all, rendering your sleep 2 insufficient. You're welcome to try it, and it may even work usually, but arbitrary sleeps are always the wrong solution for this type of sequencing problem. |
|
Back to top |
|
|
Hammett Apprentice
Joined: 26 Jan 2005 Posts: 242 Location: Barcelona, Catalonia
|
Posted: Thu May 09, 2024 2:17 pm Post subject: |
|
|
Hu wrote: | Sleeping for 2 seconds would usually result in it running after /usr/bin/pipewire and /usr/bin/wireplumber are started. However, since gentoo-pipewire-launcher is in the background and asynchronous, it's possible (although unlikely) that the kernel would delay the execution of the entire shown script by an arbitrary amount of time, and not delay your hook script at all, rendering your sleep 2 insufficient. You're welcome to try it, and it may even work usually, but arbitrary sleeps are always the wrong solution for this type of sequencing problem. |
Thanks for the feedback. I do agree that this is not a solution. The solution would be to change de defaults of the sound card profile, but since I am unable to find where those are stored, a workaround needs to be found.
Again, not ideal solution, but I will try and see....
In the meantime, I will continue to investigate where to change the card defaults, if it is even possible. _________________ I don't fear the people. I fear the demon inside them. |
|
Back to top |
|
|
Jimmy Jazz Guru
Joined: 04 Oct 2004 Posts: 333 Location: Strasbourg
|
Posted: Thu May 09, 2024 3:53 pm Post subject: |
|
|
sleeping is not robust enough. The commande sleep is more useful to ease the ability to interrupt the program
waiting the pid file won't work either if it is create to early.
but if the program returns something after the audio initialisation has been done, scan the output
Code: |
set -x
: > /tmp/outp
tail -F /tmp/outp |
while read -t 5; do
echo $REPLY | grep 'Im waiting for that line' && echo unmute now || echo nothing found
done &
(echo Im not waiting for that line >/tmp/outp)&
sleep 3
(echo Im waiting for that line >>/tmp/outp)&
|
_________________ « La seule condition au triomphe du mal, c'est l'inaction des gens de bien » E.Burke
Code: |
+----+----+----+
| |::::| |
| |::::| |
+----+----+----+ |
motto: WeLCRO
WritE Less Code, Repeat Often |
|
Back to top |
|
|
|