yktoo / indicator-sound-switcher

Sound input/output selector indicator for Linux
https://yktoo.com/en/software/sound-switcher-indicator/
GNU General Public License v3.0
373 stars 29 forks source link

Output to both outputs when selecting headphones #85

Open JoeJoeTV opened 4 years ago

JoeJoeTV commented 4 years ago

My motherboard has onboard sound and I want to switch between the speakers, I plugged in the back and the headphones, which are plugged into the front panel. When I switch to the speaker output, only the speakers output audio but when I switch to headphones(with Auto-Mute disabled in alsamixer), both the speakers and the headphones output audio. While searching on the internet I found a script that disables Auto Mute and switches to the speakers and enables it again when switching to the headphones. I know this is more of a pulseaudio(or ALSA) issue, but on my loooong journey of solving this problem, I only found one solution that works. But to make it work I'd have to change some files that are managed by the package manager and get removed when updating.

Is it in anyway possible for you to impliment this or are there other solutions(I tried remapping sinks/channels to seperate them, custom pulse profiles, but none worked)?

If this issue doesn't fit at all, tell me and I will delete it.

yktoo commented 4 years ago

I'm not sure what exactly the problem is, I also never heard of Auto Mute.

Is it that the speakers are active when you expect them to be muted because you plugged in the headphones?

And indeed, the indicator only sends commands to the PulseAudio server so I don't expect it's feasible to fix there.

Also, by

to make it work I'd have to change some files that are managed by the package manager and get removed when updating

what exactly files do you mean?

JoeJoeTV commented 4 years ago

I mean, that I want to switch between my speakers and headphones via software while both are plugged in (they show as one device with multiple ports).

And the files are /usr/share/pulseaudio/alsa-mixer/paths/analog-output-lineout.conf and /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf. I found this solution somewhere on github. I think you just force them both to show as plugged in.

leobasilio commented 4 years ago

I have a similar if not the same the problem. I'm no expert in audio, but let me try to clarify that. On some systems, when you plug in the headphones, sound is played simultaneously at both speakers and headphones. People say you should enable "Auto mute" using alsamixer, so that the speakers are muted once the headphones are plugged in. It doesn't work for me. I guess it's because I have an AC97 front audio panel, which lacks the jack sensing pin, so the system has no way to detect the headphones. Hence my interest in this project. Since there's no auto detection, we have to change the audio output manually, but still the speakers won't go mute. The next solution we find is editing some pulseaudio config files. I don't really understand all the architecture involved here, but inside the analog-output-headphones.conf file, we have this "Element Front" entry, which seems to map to the speakers. Here's the default setting:

[Element Front]
switch = mute
volume = zero

As far as I understand, the speakers should go mute, even though they're still enabled. Well, it doesn't seem to have any effect. It only works when we turn it off completely.

[Element Front]
switch = off
volume = off

Problem solved, except... whenever there's an update on the package that manages this file, the file gets overwritten and the change is lost. It's a minor issue, but if that setting could also be controlled by software, there would be no need edit config files anymore. On the other hand, I don't know how this would affect other systems. If it were to be implemented, maybe it should be an opt-in feature.

JoeJoeTV commented 4 years ago

@leobasilio actually, I don't want the behaviour of the headphones muting and the speakers unmuting and vice versa. That's how it's currently. When I disable Auto-Mute, then it kinda works, but as described, then it doesn't get muted properly, so I have to use this fix(I searched for a long time and didn't find anything really useful).

leobasilio commented 4 years ago

I think you should show this fix you're talking about, because it's not clear what it does, but I understand now that you want it the other way around. You do want speakers and headphones to play simultaneously, as opposed to what I want. Either way both our solutions seem to go through accordingly editing these files.

yktoo commented 4 years ago

whenever there's an update on the package that manages this file, the file gets overwritten and the change is lost. It's a minor issue, but if that setting could also be controlled by software, there would be no need edit config files anymore.

Unfortunately this goes beyond my knowledge of PulseAudio's workings. However, as a possible alternative, there is a number of options for apt that can prevent overwriting the changes made manually:

--force-confold: do not modify the current configuration file, the new version is installed with a .dpkg-dist suffix. With this option alone, even configuration files that you have not modified are left untouched. You need to combine it with --force-confdef to let dpkg overwrite configuration files that you have not modified. --force-confnew: always install the new version of the configuration file, the current version is kept in a file with the .dpkg-old suffix. --force-confdef: ask dpkg to decide alone when it can and prompt otherwise. This is the default behavior of dpkg and this option is mainly useful in combination with --force-confold. --force-confmiss: ask dpkg to install the configuration file if it’s currently missing (for example because you have removed the file by mistake).

JoeJoeTV commented 4 years ago

I think you should show this fix you're talking about, because it's not clear what it does, but I understand now that you want it the other way around. You do want speakers and headphones to play simultaneously, as opposed to what I want. Either way both our solutions seem to go through accordingly editing these files.

No, I don't want them to play simultaneously, I want to be able to switch between my speakers OR my headphones with the other one respectively muted, so Speakers + No Headphones or no Speakers + Headphones. I just want them both to be plugged in at the same time and switch via software.

yktoo commented 4 years ago

@JoeJoeTV So far can't really make much of this information. I guess we indeed need to see what config changes you're talking about.

Otherwise, switching audio ports is exactly what SSI does so I expect that to simply work. Additionally, you also have the "always available" option for each port that overrules the availability reported by PulseAudio.

JoeJoeTV commented 4 years ago

I'm using this Script (minus the installation of your indicator) everytime pulseaudio updates to set the config. (It says all the changes on the linked article, so mute Speakers when Headphones are plugged in, set Headphones to be plugged in and separate the Line Out volume slider from Master).