[pulseaudio-discuss] PulseAudio, switch audio output on device connection
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Mon Oct 6 03:35:21 PDT 2014
On Thu, 2014-10-02 at 13:41 +0200, Mark Gaiser wrote:
> On Thu, Oct 2, 2014 at 11:04 AM, Tanu Kaskinen
> <tanu.kaskinen at linux.intel.com> wrote:
> > 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
> >
>
> Hi Tanu,
>
> Thank you very much for your reply. For the moment, lets focus on the
> case where a USB headset is plugged in.
> In my current case (with live cd's/dvd's and a natively installed
> archlinux) where the case is: (for clarity):
> - Play some music using some pulseaudio enabled player
> - Sound comes out of the speakers (jack connection)
> - Plug in a USB headset
> - Sound is still being send to the connected speakers (jack) and not
> the newly attached headphone (usb)
>
> This is repeatable for me on a multitude of distributions, even with
> completely different hardware (same usb headset every time).
>
> Therefore i doubt a fault in my configurations since i would expect
> distributions like magaia, ubuntu and kubuntu to have this sorted out
> of the box. Anyway, for reference, my settings again:
> http://pastebin.com/NL7hbvS6
>
> Is there any test i can run to debug this issue and figure out where
> things go wrong?
I don't think there's any simple test. You could add logging to the
sink_put_hook_callback() function in module-switch-on-connect.c for
every case where the function decides to return without moving streams,
and then see from the log why the moving is not happening.
--
Tanu
More information about the pulseaudio-discuss
mailing list