Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
pipewire/wireplumber mutes headphones on boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Tue May 07, 2024 6:43 am    Post subject: pipewire/wireplumber mutes headphones on boot Reply with quote

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
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1902
Location: 127.0.0.1

PostPosted: Tue May 07, 2024 7:55 am    Post subject: Reply with quote

Hi,

Please post the output of :
Code:

# rc-update

Code:

$ groups
Back to top
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Tue May 07, 2024 8:15 am    Post subject: Reply with quote

netfab wrote:
Hi,

Please post the output of :
Code:

# rc-update

Code:

$ groups


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
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1902
Location: 127.0.0.1

PostPosted: Tue May 07, 2024 8:23 am    Post subject: Reply with quote

You should set the alsasound init script to the boot runlevel.
You must remove your user from the audio group.
Back to top
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Tue May 07, 2024 9:11 am    Post subject: Reply with quote

netfab wrote:
You should set the alsasound init script to the boot runlevel.
You must remove your user from the audio group.


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
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Tue May 07, 2024 6:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jimmy Jazz
Guru
Guru


Joined: 04 Oct 2004
Posts: 331
Location: Strasbourg

PostPosted: Tue May 07, 2024 10:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Wed May 08, 2024 2:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21756

PostPosted: Wed May 08, 2024 3:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Wed May 08, 2024 3:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21756

PostPosted: Wed May 08, 2024 4:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jimmy Jazz
Guru
Guru


Joined: 04 Oct 2004
Posts: 331
Location: Strasbourg

PostPosted: Wed May 08, 2024 5:01 pm    Post subject: Reply with quote

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 ?

Code:

(A; B) &
C&
etc.

_________________
« 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
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Thu May 09, 2024 7:42 am    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21756

PostPosted: Thu May 09, 2024 1:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hammett
Apprentice
Apprentice


Joined: 26 Jan 2005
Posts: 231
Location: Barcelona, Catalonia

PostPosted: Thu May 09, 2024 2:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jimmy Jazz
Guru
Guru


Joined: 04 Oct 2004
Posts: 331
Location: Strasbourg

PostPosted: Thu May 09, 2024 3:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum