67 lines
2.4 KiB
Diff
67 lines
2.4 KiB
Diff
From b4b046cd37324454c7125d345cceabb5c6f61612 Mon Sep 17 00:00:00 2001
|
|
From: Bastien Nocera <hadess@hadess.net>
|
|
Date: Thu, 3 Sep 2009 18:17:43 +0100
|
|
Subject: [PATCH] =?utf-8?q?Bug=C2=A0594055=20-=20applet=20fails=20to=20connect=20to=20any=20disconnected=20audio=20device?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=utf-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Hunted down by Peter Hurley <phurley@charter.net>.
|
|
|
|
Description
|
|
If the remote device is disconnected when the applet starts, the applet
|
|
will be unable to initiate connection to the audio interface of the
|
|
device.
|
|
|
|
Cause
|
|
Incorrect use of g_hash_table_lookup in the device_list_nodes() function
|
|
in lib/bluetooth-client.c
|
|
|
|
Discussion
|
|
For a given device, device_list_nodes() loops through the known
|
|
detectable interfaces (those in detectable_interfaces[]) and adds
|
|
them to the returned hash table if calling the interfaces's
|
|
.GetProperties dbus method returns true.
|
|
|
|
The value of the "Connected" property is then stored as the associated
|
|
value with the interface name as the key in the hash table.
|
|
|
|
The *connectable* interface "org.bluez.Audio" is only added if at least
|
|
either of the *detectable* interfaces "org.bluez.Headset" or
|
|
"org.bluez.AudioSink" were added the the hash table in previous
|
|
iterations within device_list_nodes().
|
|
|
|
However, the test for whether those *detectable* interfaces were added
|
|
is not correct. Currently, g_hash_table_lookup() is used to determine
|
|
if the interface names are in the hash table. g_hash_table_lookup()
|
|
will return NULL if the the key is not present in the hash table,
|
|
OTHERWISE IT RETURNS THE VALUE ASSOCIATED WITH THE KEY. If that value
|
|
is 0 (== BLUETOOTH_STATUS_DISCONNECTED), the logic mistakenly believes
|
|
that the key is not present in the hash table, and as a result, fails
|
|
to add the only connectable audio interface "org.bluez.Audio".
|
|
|
|
Recommend
|
|
Either use g_hash_table_lookup_extended() to test for key presence
|
|
or change enum BLUET00TH_STATUS_DISCONNECTED to be != 0.
|
|
---
|
|
lib/bluetooth-enums.h | 3 ++-
|
|
1 files changed, 2 insertions(+), 1 deletions(-)
|
|
|
|
diff --git a/lib/bluetooth-enums.h b/lib/bluetooth-enums.h
|
|
index 7563c4c..450c38c 100644
|
|
--- a/lib/bluetooth-enums.h
|
|
+++ b/lib/bluetooth-enums.h
|
|
@@ -80,7 +80,8 @@ typedef enum {
|
|
} BluetoothColumn;
|
|
|
|
typedef enum {
|
|
- BLUETOOTH_STATUS_DISCONNECTED = 0,
|
|
+ BLUETOOTH_STATUS_INVALID = 0,
|
|
+ BLUETOOTH_STATUS_DISCONNECTED,
|
|
BLUETOOTH_STATUS_CONNECTED,
|
|
BLUETOOTH_STATUS_CONNECTING,
|
|
BLUETOOTH_STATUS_PLAYING
|
|
--
|
|
1.6.2.5
|
|
|