[pulseaudio-discuss] [PATCH v2] bluetooth: Add support for automatic switch between hsp and a2dp profiles

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Tue Oct 28 01:44:53 PDT 2014


On Sun, 2014-10-19 at 13:42 +0200, Pali Rohár wrote:
> On Sunday 28 September 2014 12:44:13 Pali Rohár wrote:
> > With this patch module-bluetooth-policy automatically switch
> > from a2dp profile to hsp profile if some application want to
> > start recording.
> > 
> > By default a2dp profile is used for listening music, but for
> > VOIP calls is needed profile with microphone support (hsp).
> > So this patch will switch to hsp profile if some application
> > want to use microphone and after it release it profile is
> > switched back to a2dp. So this patch allows to use bluetooth
> > microphone automatically without need of user interaction.
> > 
> > Signed-off-by: Pali Rohár <pali.rohar at gmail.com>
> > ---
> > Changes since v1:
> > * fixed auto switch for newly created bluetooth cards
> > * changed logic for ignoring source outputs
> >   - do not check for application name
> >   - decide only on media.role property if is set
> >   - ignore source outputs with peaks resampler (volume desktop
> > programs) - ignore source outputs without assigned client
> > (virtual streams) - ignore source outputs which are recording
> > from monitor of sink ---
> >  src/modules/bluetooth/module-bluetooth-policy.c |  214
> > ++++++++++++++++++++++- 1 file changed, 212 insertions(+), 2
> > deletions(-)
> > 
> > diff --git a/src/modules/bluetooth/module-bluetooth-policy.c
> > b/src/modules/bluetooth/module-bluetooth-policy.c index
> > 860868f..e585f70 100644
> > --- a/src/modules/bluetooth/module-bluetooth-policy.c
> > +++ b/src/modules/bluetooth/module-bluetooth-policy.c
> > @@ -35,16 +35,18 @@
> > 
> 
> I would like to remind this patch.
> 
> This patch for bluetooth headsets will automatically switch 
> between hsp (phone quality input+output) and a2dp (full quality 
> output) bluetooth profiles based on running pulseaudio clients.
> 
> I you want to use microphone of your bluetooth headset you need 
> to switch to hsp profile (manually or somehow else... or with 
> this patch).
> 
> This patch will primary use information from "media.role" and 
> will switch only if "media.role" is phone.
> 
> If "media.role" information is not available (e.g pulseaudio 
> client did not set it) then in patch is used some heuristic 
> (ignore resample method peaks, ignore virtual streams, ignore 
> recording from monitors).
> 
> In previous discussion Arun was against last part -- using that 
> heuristic and wanted to use only media.role.
> 
> I would like to hear what other developers thinks. There are more 
> pulseaudio users who want to see this feature in pulseaudio and 
> it is *bad* that user must open volume control settings, change 
> bluetooth configuration (switch from a2dp to hsp) before he wants 
> to make voice call or use blueooth microphone for other purpose.

I'd prefer if the patch would switch the profile to hsp only if a stream
has the "phone" role, and only if the application hasn't explicitly
configured any other device for the stream.

Btw, does this patch actually do what it's supposed to do? It seems to
switch the profile in the source output put hook, but at that point the
stream has already been routed, so I'd expect the stream to not get
routed to the hsp source, since it didn't exist at the time when the
routing for the stream was decided.

-- 
Tanu




More information about the pulseaudio-discuss mailing list