From: Mikel Astiz <[email protected]>
The old implementation is limited to parsing the profile state, but
the D-Bus API actually exposes many more properties that are currently
not being considered, specially within org.bluez.Headset.
---
src/modules/bluetooth/bluetooth-util.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/modules/bluetooth/bluetooth-util.c
b/src/modules/bluetooth/bluetooth-util.c
index 4986501..fa08bba 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -452,12 +452,12 @@ static int parse_device_property(pa_bluetooth_device *d,
DBusMessageIter *i) {
return 0;
}
-static int parse_audio_property(pa_bluetooth_discovery *u, int *state,
DBusMessageIter *i) {
+static int parse_audio_property(pa_bluetooth_device *d, enum profile p,
DBusMessageIter *i) {
const char *key;
DBusMessageIter variant_i;
- pa_assert(u);
- pa_assert(state);
+ pa_assert(d);
+ pa_assert(i);
key = check_variant_property(i);
if (key == NULL)
@@ -475,8 +475,20 @@ static int parse_audio_property(pa_bluetooth_discovery *u,
int *state, DBusMessa
dbus_message_iter_get_basic(&variant_i, &value);
if (pa_streq(key, "State")) {
- *state = pa_bt_audio_state_from_string(value);
+ pa_bt_audio_state_t state =
pa_bt_audio_state_from_string(value);
+
pa_log_debug("dbus: property 'State' changed to value '%s'",
value);
+
+ if (state == PA_BT_AUDIO_STATE_INVALID)
+ return -1;
+
+ /* A hackish p == PROFILE_OFF is used to represent
org.bluez.Audio */
+ if (p == PROFILE_OFF) {
+ d->audio_state = state;
+ break;
+ }
+
+ d->profile_state[p] = state;
}
break;
@@ -609,16 +621,13 @@ static void get_properties_reply(DBusPendingCall
*pending, void *userdata) {
goto finish;
} else if (dbus_message_has_interface(p->message,
"org.bluez.Audio")) {
- if (parse_audio_property(y, &d->audio_state, &dict_i) < 0)
+ if (parse_audio_property(d, PROFILE_OFF, &dict_i) < 0)
goto finish;
} else if
(pa_bt_audio_profile_from_interface(dbus_message_get_interface(p->message),
&profile)) {
- pa_bt_audio_state_t state;
-
- if (parse_audio_property(y, &state, &dict_i) < 0)
+ if (parse_audio_property(d, profile, &dict_i) < 0)
goto finish;
- d->profile_state[profile] = state;
}
}
@@ -873,16 +882,13 @@ static DBusHandlerResult filter_cb(DBusConnection *bus,
DBusMessage *m, void *us
goto fail;
} else if (dbus_message_has_interface(m, "org.bluez.Audio")) {
- if (parse_audio_property(y, &d->audio_state, &arg_i) < 0)
+ if (parse_audio_property(d, PROFILE_OFF, &arg_i) < 0)
goto fail;
} else if
(pa_bt_audio_profile_from_interface(dbus_message_get_interface(m), &profile)) {
- pa_bt_audio_state_t state;
-
- if (parse_audio_property(y, &state, &arg_i) < 0)
+ if (parse_audio_property(d, profile, &arg_i) < 0)
goto fail;
- d->profile_state[profile] = state;
}
if (old_any_connected !=
pa_bluetooth_device_any_audio_connected(d))
--
1.7.11.7
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss