[RFCv2 17/17] bluetooth: Postpone sink and source creation for BlueZ 5 HFP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jo?o Paulo,

On Wed, Apr 17, 2013 at 9:20 PM, Jo?o Paulo Rechi Vita
<jprvita at openbossa.org> wrote:
> On Mon, Apr 15, 2013 at 6:53 PM,  <jprvita at gmail.com> wrote:
>> From: Jo?o Paulo Rechi Vita <jprvita at openbossa.org>
>>
>> CVSD and mSBC stream have different sample rates, and the CODEC of the
>> Audio Connection is only on NewConnection(). Since the sample rate is
>> needed to create the sink/source their creation is postponed to when the
>> transport changes its state to 'playing'.
>
> Ideally instead of postponing the sink/source creation what I want
> here is to update their sample rate, otherwise I can't support (1)
> subsequent calls with different sample rates and (2) HF-initiated call
> transfer from the HF to the AG. For (1) a workaround would be
> destroying the sink after the call ends (HUP on stream fd) but I
> couldn't think of anything to cover (2).

As you already point out, postponing the creation seems a bad idea
since the current approach relies on their existence to for example
resume them automatically (connect SCO) when some audio gets streamed
(e.g. point (2) above). This seems now more tricky with HFP 1.6 so we
might have to reconsider this assumption if there's no other
alternative.

>
> I've played a bit with pa_sink_update_rate() but I always got a
> message complaining that the attached monitor source was not idle,
> even when the sink was idle. Can someone give me any help on that?

I'm not familiar with _update_rate but basically what you need is to
be able to change the sample rate of a *suspended* sink/source. This
sounds like a feature that the core should provide, regardless of the
state of the monitor.

Cheers,
Mikel

>
>> ---
>>  src/modules/bluetooth/module-bluetooth-device.c | 21 +++++++++++++++++++--
>>  1 file changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
>> index 22880c6..1f5bcbc 100644
>> --- a/src/modules/bluetooth/module-bluetooth-device.c
>> +++ b/src/modules/bluetooth/module-bluetooth-device.c
>> @@ -1579,6 +1579,11 @@ static pa_available_t get_port_availability(struct userdata *u, pa_direction_t d
>>      return result;
>>  }
>>
>> +static void bt_transport_config(struct userdata *u);
>> +static int add_source(struct userdata *u);
>> +static int add_sink(struct userdata *u);
>> +static int start_thread(struct userdata *u);
>> +
>>  /* Run from main thread */
>>  static void handle_transport_state_change(struct userdata *u, struct pa_bluetooth_transport *transport) {
>>      bool acquire = false;
>> @@ -1613,6 +1618,18 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
>>
>>      if (acquire)
>>          if (bt_transport_acquire(u, true) >= 0) {
>> +
>> +            /* Create sink and source with the correct sample rate for PROFILE_HFGW && BLUEZ5 */
>> +            if ((pa_bluetooth_discovery_get_bluez_version(u->discovery) == BLUEZ_VERSION_5) && profile == PROFILE_HFGW &&
>> +                (!u->sink || !u->source)) {
>> +
>> +                bt_transport_config(u);
>> +                add_sink(u);
>> +                add_source(u);
>> +                if (u->sink || u->source)
>> +                    start_thread(u);
>> +            }
>> +
>>              if (u->source) {
>>                  pa_log_debug("Resuming source %s, because the bluetooth audio state changed to 'playing'.", u->source->name);
>>                  pa_source_suspend(u->source, false, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
>> @@ -2194,13 +2211,13 @@ static int init_profile(struct userdata *u) {
>>
>>      if (u->profile == PROFILE_A2DP ||
>>          u->profile == PROFILE_HSP ||
>> -        u->profile == PROFILE_HFGW)
>> +        (u->profile == PROFILE_HFGW && pa_bluetooth_discovery_get_bluez_version(u->discovery) == BLUEZ_VERSION_4))
>>          if (add_sink(u) < 0)
>>              r = -1;
>>
>>      if (u->profile == PROFILE_HSP ||
>>          u->profile == PROFILE_A2DP_SOURCE ||
>> -        u->profile == PROFILE_HFGW)
>> +        (u->profile == PROFILE_HFGW && pa_bluetooth_discovery_get_bluez_version(u->discovery) == BLUEZ_VERSION_4))
>>          if (add_source(u) < 0)
>>              r = -1;
>>
>> --
>> 1.7.11.7
>>
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux