You are not logged in.

#1 2014-08-22 21:36:02

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

[SOLVED] Leave headphones plugged in, switch output in software

Normally, when I plug in my headphones sound stops playing from speakers. I would prefer leaving them plugged in, but being able to switch between speakers and headphones using some software switch.

In pavucontrol, I do have separate Line Out and Headphones ports, but when headphones are plugged in they both control headphone output. Is this possible to do?

Last edited by silverhammermba (2014-08-23 05:17:39)

Offline

#2 2014-08-22 22:22:10

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] Leave headphones plugged in, switch output in software

If I recall correctly unloading and disabling 'module-switch-on-connect' disables the automatic switching feature. For the manual switching maybe you could use profiles:
https://wiki.archlinux.org/index.php/Pu … ot_working
https://wiki.archlinux.org/index.php/Pu … 2F_devices
http://www.freedesktop.org/wiki/Softwar … /Profiles/

Using shortcuts for changing the profiles should be also possible.

Edit: I think you could accomplish this also using the remap module and using shortcuts to change the appropriate volumes.

Last edited by emeres (2014-08-22 22:26:33)

Offline

#3 2014-08-22 23:30:14

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: [SOLVED] Leave headphones plugged in, switch output in software

I'm not sure that that will work. That's for outputting to multiple sinks, but I need multiple ports of the same sink.

Offline

#4 2014-08-22 23:39:18

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] Leave headphones plugged in, switch output in software

Show your 'aplay -lL', you can test if you have hardware distinction between speakers and headphones using speaker-test.

Offline

#5 2014-08-23 00:36:32

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: [SOLVED] Leave headphones plugged in, switch output in software

$ aplay -IL
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
default
    Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=PCH
    HDA Intel PCH, ALC889 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    Front speakers
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
    HDA Intel PCH, ALC889 Digital
    IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=NVidia,DEV=0
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
    HDA NVidia, HDMI 0
    HDMI Audio Output
**** List of PLAYBACK Hardware Devices ****
card 2: PCH [HDA Intel PCH], device 0: ALC889 Analog [ALC889 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: PCH [HDA Intel PCH], device 1: ALC889 Digital [ALC889 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 7: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 8: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 9: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The only things that make noise are sysdefault and front, and those are both headphones/speakers. It doesn't look like there's a distinction.

Last edited by silverhammermba (2014-08-23 00:53:41)

Offline

#6 2014-08-23 00:43:46

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] Leave headphones plugged in, switch output in software

That is a l as in laboratory, not an I as in imaginary. So:

aplay -lL;
speaker-test -c 2 -p 4 -t wav -D plug:"dmix:{CARD PCH DEV 0}"
speaker-test -c 2 -p 4 -t wav -D plug:"dmix:{CARD PCH DEV 2}"
speaker-test -c 2 -p 4 -t wav -D plug:"dmix:{CARD NVidia DEV 0}"
speaker-test -c 2 -p 4 -t wav -D plug:"dmix:{CARD NVidia DEV 3}"
amixer -c PCH;

Is this a laptop?

Last edited by emeres (2014-08-23 00:45:21)

Offline

#7 2014-08-23 00:55:37

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: [SOLVED] Leave headphones plugged in, switch output in software

Oops. I edited the output of my last post. It's not a laptop. Again, I only get sound from PCH device 0, and that's headphones/speakers depending on what's plugged in.

Offline

#8 2014-08-23 00:58:22

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] Leave headphones plugged in, switch output in software

Post also 'amixer -c PCH'. Why are those cards starting at 2? Do you use usb sound devices? Or do you have something in /etc/modprobe.d/*.conf set for the sound modules?

Offline

#9 2014-08-23 01:14:22

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: [SOLVED] Leave headphones plugged in, switch output in software

$ amixer -c PCH
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 64
  Mono: Playback 64 [100%] [0.00dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 64
  Mono:
  Front Left: Playback 62 [97%] [0.00dB] [on]
  Front Right: Playback 62 [97%] [0.00dB] [on]
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 255 [100%] [0.00dB]
  Front Right: Playback 255 [100%] [0.00dB]
Simple mixer control 'Front',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 64
  Mono:
  Front Left: Playback 64 [100%] [2.00dB] [on]
  Front Right: Playback 64 [100%] [2.00dB] [on]
Simple mixer control 'Front Mic',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Front Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Surround',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 64
  Mono:
  Front Left: Playback 62 [97%] [0.00dB] [on]
  Front Right: Playback 62 [97%] [0.00dB] [on]
Simple mixer control 'Center',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 64
  Mono: Playback 62 [97%] [0.00dB] [on]
Simple mixer control 'LFE',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 64
  Mono: Playback 62 [97%] [0.00dB] [on]
Simple mixer control 'Side',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 64
  Mono:
  Front Left: Playback 62 [97%] [0.00dB] [on]
  Front Right: Playback 62 [97%] [0.00dB] [on]
Simple mixer control 'Line',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Line Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958 Default PCM',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 46
  Front Left: Capture 34 [74%] [18.00dB] [on]
  Front Right: Capture 34 [74%] [18.00dB] [on]
Simple mixer control 'Capture',1
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 46
  Front Left: Capture 0 [0%] [-16.00dB] [on]
  Front Right: Capture 0 [0%] [-16.00dB] [on]
Simple mixer control 'Capture',2
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 46
  Front Left: Capture 0 [0%] [-16.00dB] [on]
  Front Right: Capture 0 [0%] [-16.00dB] [on]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Enabled'
Simple mixer control 'Digital',0
  Capabilities: cvolume
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 120
  Front Left: Capture 60 [50%] [0.00dB]
  Front Right: Capture 60 [50%] [0.00dB]
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Front Mic' 'Rear Mic' 'Line'
  Item0: 'Line'
Simple mixer control 'Input Source',1
  Capabilities: cenum
  Items: 'Front Mic' 'Rear Mic' 'Line'
  Item0: 'Front Mic'
Simple mixer control 'Input Source',2
  Capabilities: cenum
  Items: 'Front Mic' 'Rear Mic' 'Line'
  Item0: 'Front Mic'
Simple mixer control 'Rear Mic',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Rear Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]

I'm not sure why they're starting at 2. I have two USB microphones, would that do it? /etc/modprobe.d/alsa-base.conf has

options snd_usb_audio index=-2

which I don't remember creating and no package owns it. Beats me.

Offline

#10 2014-08-23 01:21:41

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] Leave headphones plugged in, switch output in software

silverhammermba wrote:

I'm not sure why they're starting at 2. I have two USB microphones, would that do it?

Yes, that explains it.

So, would that work?

amixer -c PCH sset Front mute Hedphone on

amixer -c PCH sset Front on Hedphone mute

I would go through every other control. PCM probably also affects Headphones, but try it to be sure, Master should affect everything.

Edit: You should also disable Auto-Mute:

amixer -c PCH sset 'Auto-Mute Mode' disabled
#or
amixer -c PCH sset 'Auto-Mute Mode' off
#or
amixer -c PCH sset 'Auto-Mute Mode' 0
#I am not sure

Last edited by emeres (2014-08-23 01:26:08)

Offline

#11 2014-08-23 04:23:19

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: [SOLVED] Leave headphones plugged in, switch output in software

amixer -c PCH sset 'Auto-Mute Mode' Disabled

That made it so plugging in headphones doesn't mute my speakers! Woohoo! Here's the weirdness, though: if I then mute Headphone OR Front, it's mutes everything: Master, Front, and Headphone! And it won't start playing sound again until I unmute all three.

Luckily it doesn't do the same with just volume changes, so instead of muting I can set the volume to 0% and 100% to get the effect I want. Thanks so much for the help! I'm pretty happy with this work around but I must say I find all of this extremely weird.

Offline

#12 2014-08-23 04:34:54

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] Leave headphones plugged in, switch output in software

You would have to take a look into the datasheet for that codec, maybe it is configured in that way. I doubt hdajackretask would be able to change this behaviour, but some hda-verb commands might. Ask on the alsa-user mailing list for further explanation or look at the source code for your sound card vid and pid combination.
You are welcome, since the issue is solved please mark the thread as solved.

Offline

Board footer

Powered by FluxBB