You are not logged in.

#1 2016-04-20 15:14:56

tmiddleton
Member
Registered: 2016-03-29
Posts: 28

PulseAudio - default to HDMI, switch to headphones when plugged in?

...is it possible? Plugging and unplugging my headphones makes no difference to any new or existing streams - the default sink stays the same and audio keeps playing on it.

When my headphones are unplugged, I'd like all audio to go to my HDMI monitor. When I plug in my headphones, I'd like all new and existing streams to go to my headphones. Basically I'd like pulseaudio to do the same thing as Windows, OSX, and Android.

Can this be done?

Offline

#2 2016-04-20 15:19:27

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

Add load-module module-switch-on-connect before the if...udev-detect line in your /etc/pulse/default.pa

Also what kind of headphones are we talking here? USB should be no problem, a normal jack one might be tricky depending on correct jack sensing in ALSA and Pulseaudio. There was some work to help this case in pulseaudio 8 but it turned out to be buggy and break previously working setups more than it helped and has hence been reverted in the Arch package, follow this bug https://bugs.freedesktop.org/show_bug.cgi?id=93946 for the current state of affairs

Last edited by V1del (2016-04-20 15:35:00)

Offline

#3 2016-04-20 15:48:30

tmiddleton
Member
Registered: 2016-03-29
Posts: 28

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

V1del wrote:

Add load-module module-switch-on-connect before the if...udev-detect line in your /etc/pulse/default.pa

This doesn't seem to work. I've added it to my default.pa and its show up in the daemon:

>>> list-modules
22 module(s) loaded.
    index: 0
        name: <module-device-restore>
        argument: <>
        used: -1
        load once: yes
        properties:
                module.author = "Lennart Poettering"
                module.description = "Automatically restore the volume/mute state of devices"
                module.version = "8.0"
    index: 1
        name: <module-stream-restore>
        argument: <restore_device=0>
        used: -1
        load once: yes
        properties:
                module.author = "Lennart Poettering"
                module.description = "Automatically restore the volume/mute/device state of streams"
                module.version = "8.0"
    index: 2
        name: <module-card-restore>
        argument: <>
        used: -1
        load once: yes
        properties:
                module.author = "Lennart Poettering"
                module.description = "Automatically restore profile of cards"
                module.version = "8.0"
    index: 3
        name: <module-augment-properties>
        argument: <>
        used: -1
        load once: yes
        properties:
                module.author = "Lennart Poettering"
                module.description = "Augment the property sets of streams with additional static information"
                module.version = "8.0"
    index: 4
        name: <module-switch-on-connect>
        argument: <>
        used: -1
        load once: yes
        properties:
                module.author = "Michael Terry"
                module.description = "When a sink/source is added, switch to it or conditionally switch to it"
                module.version = "8.0"
    index: 5
        name: <module-udev-detect>
        argument: <>
        used: -1
        load once: yes
        properties:
                module.author = "Lennart Poettering"
                module.description = "Detect available audio hardware and load matching drivers"
                module.version = "8.0"

I have 2 sinks - 0 is my hdmi audio, 1 is my headphones on an HDA device on my mobo. When I plug and unplug my headphones, I can see the port go available and unavailable:

                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: no)
                        properties:

                analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-headphones"
        active port: <analog-output-headphones>
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: no)
                        properties:

                analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: yes)
                        properties:
                                device.icon_name = "audio-headphones"
        active port: <analog-output-headphones>

How does module-switch-on-connect work? Is it supposed to change the default sink? My default sink never changes as I plug and unplug my headphones, regardless of what the default was to begin with (HDMI or headphones). Neither existing streams nor new streams switch sinks either - if they're on the HDMI, they don't switch to headphones when I plug them in. If they're on headphones, they stay on headphones whether I unplug them or plug them back in.

Offline

#4 2016-04-22 23:35:36

tmiddleton
Member
Registered: 2016-03-29
Posts: 28

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

V1del wrote:

Also what kind of headphones are we talking here? USB should be no problem, a normal jack one might be tricky depending on correct jack sensing in ALSA and Pulseaudio. There was some work to help this case in pulseaudio 8 but it turned out to be buggy and break previously working setups more than it helped and has hence been reverted in the Arch package, follow this bug https://bugs.freedesktop.org/show_bug.cgi?id=93946 for the current state of affairs

It's a normal 1/8" jack. I'll have a close look at that bug - thanks.

Offline

#5 2016-04-23 01:11:26

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

There might be a setting in pavucontrol, specifically in the input section. I'll look there now and see if anything comes up. Also, there might be a particular setting in alsa mixer that allows for the switching you're mentioning. I'll look there too then and post back any findings.

EDIT: The lack of audio settings in pavucontrol, at least the gui portion, is disturbing... However I did immediately find the Auto Mute Mode setting (scroll to the right) in alsamixer. You have to select the other sound card, in my case HD-Audio Generic, for the auto mute option to show up. Try mucking with that.

Last edited by JohnBobSmith (2016-04-23 01:15:56)


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#6 2016-04-23 23:29:14

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

@JohnBobSmith likely not gonna help, automute is for sound coming out of the speakers, as far as ALSA is concerned the internal card where the headphones connect to is a seperate card from HDMI

Offline

#7 2016-04-23 23:54:45

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

Oh, if thats the case then ignore my post. Sorry about that.


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#8 2016-05-06 07:04:26

tmiddleton
Member
Registered: 2016-03-29
Posts: 28

Re: PulseAudio - default to HDMI, switch to headphones when plugged in?

V1del wrote:

Also what kind of headphones are we talking here? USB should be no problem, a normal jack one might be tricky depending on correct jack sensing in ALSA and Pulseaudio. There was some work to help this case in pulseaudio 8 but it turned out to be buggy and break previously working setups more than it helped and has hence been reverted in the Arch package, follow this bug https://bugs.freedesktop.org/show_bug.cgi?id=93946 for the current state of affairs

I've had a look at that bug and it doesn't seem to apply? They seem to be having problems with the appearance of HDMI devices - my HDMI device is constant but my headphones appear and disappear?

Offline

Board footer

Powered by FluxBB