[pulseaudio-discuss] Switching devices by application

Colin Guthrie gmane at colin.guthr.ie
Mon Oct 11 03:00:52 PDT 2010


Hi Patrick,

'Twas brillig, and Patrick Ben Koetter at 11/10/10 10:34 did gyre and
gimble:
> I seek advice configuring my PulseAudio setup on my Ubuntu Desktop. What I
> want is use my headphone for phone calls (using BRIA SIP client for Linux) and
> the soundcard to listen to music.

When you say your "headphone", do you mean a specific separate device
(e.g. a USB or Bluetooth headset) or just the headphone port of your
built in sound card?

> Both devices should work separately and automated i.e. when a phone call comes
> in don't switch manually from soundcard to headphone etc., but have it
> assigned to the headphone automatically.
> 
> The people who produce BRIA told me, it is out of their SIP client's control
> to trigger/control which device should be used and told me this needs to be
> configured in my PulseAudio server instead.
> 
> I looked up the documentation, but could figure out if and how it would be
> done in PulseAudio.
> 
> Any help would greatly be appreciated.


The answer of "how to do this" depends a bit on your Desktop. e.g. in
KDE it's a little different than on Gnome (although the principle is the
same).

There are also a couple things the BRIA people *can* do to make the
process work properly.

In the short term, all you really need to do is use pavucontrol.

When your SIP client is running and has an active call, pavucontrol
should show you two streams for this application - one for playback and
one for recording. These will be shown on the first two tabs in pavucontrol.

All you need to do is set the right device for the streams - i.e. move
them from the default/fallback device to the headset device. You will
need to do this for both your recoding stream and the playback stream.

Once you have done this once, PA will remember this decision and restore
it next time (assuming the device is plugged in!).


The UIs built into Gnome itself are somewhat lacking in the control
regard in this base and attempt to be more "intelligent" without you
having to do anything.

This is where the BRIA people can be nice and provide suitable metadata
when they output audio. Every stream in PA can have a "proplist"
basically a list of key-value pair metadata. One of the properties you
can set is the media.role property. The sound of a phone ringing and
presense information changing etc. (i.e. all non-call sound) should
likely be tagged with media.role=event. All in-call sound (playback and
recording) should have media.role=voip. Skype, for example, correctly
tags it's streams in this way on our recommendation.

When this metadata is present, PA can do some clever, contextual things,
e.g. if you have a device plugged in that is detected as a "headset", PA
can be a bit clever and say... "hmmm there is a phone call currently
underway, and I have a headset device... the two should probably work
together". This logic is currently implemented by module-intended-roles
which is loaded by default.

So, while the BRIA people are correct that they do not actively control
the devices (which we recommend) they can supply suitable metadata to
help us make the right decision automatically (which can still be
overridden by user preferences :))


I've not gone into too much detail here, but hopefully it's enough
information to get your setup correct, but I'd appreciate it if you
could pass on a link to this thread
(http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/7596) to
the BRIA guys who are welcome to get in touch for more info/advice.

All the best

Col



-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




More information about the pulseaudio-discuss mailing list