[PATCH 15/17] bluetooth: Add pa_bluetooth_transport_set_state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

---
 src/modules/bluetooth/backend-ofono.c | 15 ++++-----------
 src/modules/bluetooth/bluez5-util.c   | 10 +++++-----
 src/modules/bluetooth/bluez5-util.h   |  1 +
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c
index 56a1944..41810d4 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -271,7 +271,6 @@ fail:
 
 static void hf_audio_agent_card_removed(pa_bluetooth_backend *backend, const char *path) {
     hf_audio_card *card;
-    bool old_any_connected;
 
     pa_assert(backend);
     pa_assert(path);
@@ -282,14 +281,8 @@ static void hf_audio_agent_card_removed(pa_bluetooth_backend *backend, const cha
     if (!card)
         return;
 
-    old_any_connected = pa_bluetooth_device_any_transport_connected(card->transport->device);
-
-    card->transport->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
-    card->transport->device->transports[card->transport->profile] = NULL;
-    pa_hook_fire(pa_bluetooth_discovery_hook(backend->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED), card->transport);
-
-    if (old_any_connected != pa_bluetooth_device_any_transport_connected(card->transport->device))
-        pa_hook_fire(pa_bluetooth_discovery_hook(backend->discovery, PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED), card->transport->device);
+    if (card->transport)
+        pa_bluetooth_transport_set_state(card->transport, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED);
 
     hf_audio_card_free(card);
 }
@@ -546,8 +539,8 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
 
     card->fd = fd;
     card->transport->codec = codec;
-    card->transport->state = PA_BLUETOOTH_TRANSPORT_STATE_PLAYING;
-    pa_hook_fire(pa_bluetooth_discovery_hook(backend->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED), card->transport);
+
+    pa_bluetooth_transport_set_state(card->transport, PA_BLUETOOTH_TRANSPORT_STATE_PLAYING);
 
     pa_assert_se(r = dbus_message_new_method_return(m));
 
diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 93677b4..83e27d7 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -167,7 +167,7 @@ static const char *transport_state_to_string(pa_bluetooth_transport_state_t stat
     return "invalid";
 }
 
-static void transport_state_changed(pa_bluetooth_transport *t, pa_bluetooth_transport_state_t state) {
+void pa_bluetooth_transport_set_state(pa_bluetooth_transport *t, pa_bluetooth_transport_state_t state) {
     bool old_any_connected;
 
     pa_assert(t);
@@ -191,7 +191,7 @@ static void transport_state_changed(pa_bluetooth_transport *t, pa_bluetooth_tran
 }
 
 void pa_bluetooth_transport_put(pa_bluetooth_transport *t) {
-    transport_state_changed(t, PA_BLUETOOTH_TRANSPORT_STATE_IDLE);
+    pa_bluetooth_transport_set_state(t, PA_BLUETOOTH_TRANSPORT_STATE_IDLE);
 }
 
 void pa_bluetooth_transport_free(pa_bluetooth_transport *t) {
@@ -328,7 +328,7 @@ static void parse_transport_property(pa_bluetooth_transport *t, DBusMessageIter
                     return;
                 }
 
-                transport_state_changed(t, state);
+                pa_bluetooth_transport_set_state(t, state);
             }
 
             break;
@@ -412,7 +412,7 @@ static void device_free(pa_bluetooth_device *d) {
         if (!(t = d->transports[i]))
             continue;
 
-        transport_state_changed(t, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED);
+        pa_bluetooth_transport_set_state(t, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED);
         pa_bluetooth_transport_free(t);
     }
 
@@ -1433,7 +1433,7 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *conn, DBusMessa
 
     if ((t = pa_hashmap_get(y->transports, path))) {
         pa_log_debug("Clearing transport %s profile %s", t->path, pa_bluetooth_profile_to_string(t->profile));
-        transport_state_changed(t, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED);
+        pa_bluetooth_transport_set_state(t, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED);
         pa_bluetooth_transport_free(t);
     }
 
diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
index 67377e9..5bcab16 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -112,6 +112,7 @@ void pa_bluetooth_backend_free(pa_bluetooth_backend *b);
 pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
                                                    pa_bluetooth_profile_t p, const uint8_t *config, size_t size);
 
+void pa_bluetooth_transport_set_state(pa_bluetooth_transport *t, pa_bluetooth_transport_state_t state);
 void pa_bluetooth_transport_put(pa_bluetooth_transport *t);
 void pa_bluetooth_transport_free(pa_bluetooth_transport *t);
 
-- 
1.9.3



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux