[pulseaudio-discuss] [PATCH v2] bluetooth: Add support for automatic switch between hsp and a2dp profiles
Pali Rohár
pali.rohar at gmail.com
Fri Oct 31 06:22:59 PDT 2014
On Friday 31 October 2014 13:40:57 Tanu Kaskinen wrote:
> On Fri, 2014-10-31 at 13:07 +0100, Pali Rohár wrote:
> > On Friday 31 October 2014 12:49:08 Tanu Kaskinen wrote:
> > > On Tue, 2014-10-28 at 12:33 +0100, Pali Rohár wrote:
> > > > On Tuesday 28 October 2014 09:44:53 Tanu Kaskinen wrote:
> > > > > On Sun, 2014-10-19 at 13:42 +0200, Pali Rohár wrote:
> > > > > > 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.
> > > >
> > > > Ok. And what to do when application does not specify any
> > > > role?
> > >
> > > Nothing.
> >
> > Ok, what about adding new bool parameter to this module
> > (which will be off by default) to use also heuristic when
> > application does not specify media.role?
>
> Do you have a real use case (not something that you are able
> to imagine, but something that either you or someone else
> really needs)? I'm hesitant to accept any more heuristics
> than really necessary, because this is not how I think
> routing policy "should" be implemented, but the way I think
> routing policy "should" be implemented takes so much work
> that it doesn't make sense to ask you to do it.
>
Yes I have real use case. I'm using alsa based application for
voice calls and obviously it does not (and cannot) set media.role
because it is not pulse application.
I and also there are other people who want to use bluetooth
microphone as primary recording device. But when if no
application want to record sound it is the best to switch back to
a2dp mode for better output quality. And manually switching
profiles is pain.
Another use case is when there is no sound card with recording
capability or it is integrated sound card is configured to
output-only mode, because user does not have any microphone
plugged in.
> So yes, adding another parameter to module-bluetooth-policy
> should be fine if there's real need for it. In a separate
> patch, please, because I'd like to merge the
> by-media-role-only heuristic first.
>
Ok. I will send move heuristic into new patch and send two v3
patches.
> > > > > 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.
> > > >
> > > > Patch automatically switch between hsp and a2dp mode in
> > > > source output hook function. Because switching procedure
> > > > takes some time (and it is asynchronous) it is not
> > > > finished before returning from hook function.
> > >
> > > As far as I know, switching card profiles is synchronous.
> > >
> > > > Once profile switch is done new source card output
> > > > appears and can be used for recording audio. When I
> > > > configured hsp source with high priority in KDE4
> > > > multimedia settings PA automatically switch to hsp
> > > > bluetooth card when it is available for all exiting
> > > > source streams.
> > >
> > > Ok, so this patch relies on some other policy module to
> > > automatically move streams when a new sink/source appears.
> > > I think that's fine for now.
> >
> > Ok. So only problematic part of my patch is using heuristic
> > when application does not provide media.role information?
>
> I haven't done thorough review, so there may be smaller
> issues, but overall the logic seems ok to me.
Ok.
--
Pali Rohár
pali.rohar at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20141031/1f780f77/attachment.sig>
More information about the pulseaudio-discuss
mailing list