[pulseaudio-discuss] PulseAudio, switch audio output on device connection

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Thu Oct 2 02:04:35 PDT 2014


On Sun, 2014-09-28 at 21:16 +0200, Mark Gaiser wrote:
> Hi PulseAudio list,
> 
> Note: please keep me in CC, i'm not registered on this list.
> 
> I've been having this issue for as long as i use Linux (with
> pulseaudio) but never really bothered to look into the issue and try
> to resolve it. That's something i've been trying to tackle for a few
> days now without any notable success.
> 
> First to clear make my use case clear.
> - I have a USB headset (but the same is true for jack).
> - On windows and mac, whenever i plug in a headset (usb or jack) all
> audio is redirected to that device.
> 
> My linux setup:
> - Archlinux x64 (fully up to date)
> - KDE 4.xx
> 
> What i want to accomplish is to have the same hassle free use case on
> linux as it works on windows and mac. My (fairly default) default.pa
> can be found here [1]. The only things i added (as far as i can
> remember) is:
> # automatically switch to newly-connected devices
> load-module module-switch-on-connect
> 
> Which i did because it "looked" like the thing i needed based on one
> of the comments in [2]. It doesn't seem to do anything for me though.
> 
> So how do i let PulseAudio redirect all audio output to (the last)
> audio device that i connected to it? Just like it works on Windows and
> Mac? I mean, i can change output sinks in pavucontrol, but that is
> hardly a sane way to do every time. There must be "some" easy way out
> there to do this, right?
> 
> Also, it would be very nice of the audio switched sink while audio is playing.
> 
> I prefer doing this using just default pulseaudio and linux commands.
> I know of the "paswitch" git project somewhere that allows me to
> switch output devices, but i don't believe that's the right way to do
> something like this.
> 
> I hope this list could share the appropriate way in getting this done.
> 
> For reference, i tried the same use case in Ubuntu, Kubuntu and Magaia
> (plug in a headset, play music and listen where the sound comes from).
> In all cases no sound was coming out of my headset. All sound came out
> of the speakers (that are connected via a jack plug).

I don't know why it's not working for you, but here's some information
that may help with figuring it out.

The first thing to note is that USB headsets and headphones that are
plugged into an audio jack are handled differently.

The policy of moving streams to a newly plugged-in USB headset is
handled by module-switch-on-connect. That module changes the default
sink to a newly plugged-in sound card, and moves streams if and only if
the following conditions are fulfilled: the stream is currently playing
to the sink that was the old default sink, and you have not previously
explicitly moved the stream.

The policy of switching to the headphones when you plug them to an audio
jack is handled by module-switch-on-port-available. That module never
moves streams. Instead, it just switches the port on the sink that has
the headphone port. I don't know the details of your setup, but if the
jack to which you have connected the speakers is part of a different
sink than the one that handles the headphone jack, then audio won't
automatically move to the headphones.

The above is a description how things are, not necessarily of they
should be.

-- 
Tanu



More information about the pulseaudio-discuss mailing list