From f035ffe3c02867cd551b6caf9ded6484412f9f28 Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Mon, 10 Dec 2012 08:30:39 +0100 Subject: bluetooth: Add transport hooks into pa_bluetooth_hook_t 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 9df3f9d3b..132a50e24 100644 --- a/src/modules/bluetooth/bluetooth-util.c +++ b/src/modules/bluetooth/bluetooth-util.c @@ -204,6 +204,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); } @@ -504,6 +506,7 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D 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("Device %s interface %s property 'State' changed to value '%s'", d->path, interface, value); @@ -522,7 +525,11 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D 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; @@ -815,6 +822,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); } @@ -1251,6 +1259,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 cc8b08b3e..b35e5334f 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; -- cgit v1.2.3