[pulseaudio-discuss] [PATCH 1/3] bluetooth: Only create backend instance once objects are listed

Luiz Augusto von Dentz luiz.dentz at gmail.com
Mon Sep 8 03:29:03 PDT 2014


Hi Tanu,

On Mon, Sep 8, 2014 at 12:46 PM, Tanu Kaskinen
<tanu.kaskinen at linux.intel.com> wrote:
> On Mon, 2014-09-08 at 12:14 +0300, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>
>>
>> This makes sure the devices are discovered before the backend start
>> creating new transports.
>> ---
>>  src/modules/bluetooth/bluez5-util.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
>> index 93677b4..818790d 100644
>> --- a/src/modules/bluetooth/bluez5-util.c
>> +++ b/src/modules/bluetooth/bluez5-util.c
>> @@ -889,6 +889,9 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
>>
>>      y->objects_listed = true;
>>
>> +    if (!y->backend)
>> +        y->backend = pa_bluetooth_backend_new(y->core);
>> +
>>  finish:
>>      dbus_message_unref(r);
>>
>> @@ -1591,7 +1594,6 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
>>
>>      endpoint_init(y, PA_BLUETOOTH_PROFILE_A2DP_SINK);
>>      endpoint_init(y, PA_BLUETOOTH_PROFILE_A2DP_SOURCE);
>> -    y->backend = pa_bluetooth_backend_new(c);
>>
>>      get_managed_objects(y);
>>
>
> The idea is that the backend should only exist when objects_listed is
> true, right? If so, you need to free the backend when objects_listed is
> set to false.

True, although in practice this only happens during first list since
once bluetoothd disappear so does the objects in oFono side, but I
guess we can make it consistent here and free the backend if
bluetoothd exit.

> This also doesn't solve the problem that if a new device appears,
> there's a race between BlueZ and oFono about which one's signals will
> reach PulseAudio first. I believe we don't handle it properly if oFono
> wins.

In case of oFono this is not a problem, the cards are only added when
the device is connected which should never happen while the device is
being added.

-- 
Luiz Augusto von Dentz


More information about the pulseaudio-discuss mailing list