[pulseaudio-discuss] [PATCH next v0 07/11] bluetooth: Add transport hooks into pa_bluetooth_hook_t
Mikel Astiz
mikel.astiz.oss at gmail.com
Thu Dec 6 06:55:32 PST 2012
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
Add the transport-handling hooks to the centralized list of hooks in
pa_bluetooth_hook_t. These are intended to replace the now deprecated
transport-specific hook list in pa_bluetooth_transport_hook_t.
---
src/modules/bluetooth/bluetooth-util.c | 10 ++++++++++
src/modules/bluetooth/bluetooth-util.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 788b459..20d2217 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -201,6 +201,8 @@ static void device_free(pa_bluetooth_device *d) {
d->transports[i] = NULL;
pa_hashmap_remove(d->discovery->transports, t->path);
+ t->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
+ pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
pa_hook_fire(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], NULL);
transport_free(t);
}
@@ -494,6 +496,7 @@ static int parse_audio_property(pa_bluetooth_device *d, enum profile p, DBusMess
if (pa_streq(key, "State")) {
pa_bt_audio_state_t state = pa_bt_audio_state_from_string(value);
+ pa_bluetooth_transport_state_t old_state;
pa_log_debug("dbus: property 'State' changed to value '%s'", value);
@@ -511,7 +514,11 @@ static int parse_audio_property(pa_bluetooth_device *d, enum profile p, DBusMess
if (!transport)
break;
+ old_state = transport->state;
transport->state = pa_bt_audio_state_to_transport_state(state);
+
+ if (transport->state != old_state)
+ pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], transport);
}
break;
@@ -811,6 +818,7 @@ static int pa_bluetooth_transport_parse_property(pa_bluetooth_transport *t, DBus
if (pa_streq(key, "NREC") && t->nrec != value) {
t->nrec = value;
pa_log_debug("Transport %s: Property 'NREC' changed to %s.", t->path, t->nrec ? "True" : "False");
+ pa_hook_fire(&t->device->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_NREC_CHANGED], t);
pa_hook_fire(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_NREC_CHANGED], NULL);
}
@@ -1255,6 +1263,8 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
pa_log_debug("Clearing transport %s profile %d", t->path, t->profile);
t->device->transports[t->profile] = NULL;
pa_hashmap_remove(y->transports, t->path);
+ t->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
+ pa_hook_fire(&y->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
pa_hook_fire(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], NULL);
transport_free(t);
}
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index cc8b08b..b35e533 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -74,6 +74,8 @@ struct pa_bluetooth_hook_uuid_data {
typedef enum pa_bluetooth_hook {
PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device */
PA_BLUETOOTH_HOOK_DEVICE_UUID_ADDED, /* Call data: pa_bluetooth_hook_uuid_data */
+ PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
+ PA_BLUETOOTH_HOOK_TRANSPORT_NREC_CHANGED, /* Call data: pa_bluetooth_transport */
PA_BLUETOOTH_HOOK_MAX
} pa_bluetooth_hook_t;
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list