diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2014-02-24 13:44:12 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-02-28 15:22:45 +0100 |
commit | dd1e44fce160c1883d8600ff2816a3403c967b12 (patch) | |
tree | 8c55cd6a12e9be1669174074190e16ab6aaf3311 /android/a2dp.c | |
parent | a7471c5334595ff4de1fe5aab17ad9ce8a90bae0 (diff) | |
download | bluez-dd1e44fce160c1883d8600ff2816a3403c967b12.tar.gz |
android: Refactor IPC init
This allows to pass socket path and max service ID while initializaing
IPC. This is first step to allow use it both for BT and Audio HALs.
Diffstat (limited to 'android/a2dp.c')
-rw-r--r-- | android/a2dp.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/android/a2dp.c b/android/a2dp.c index 5d7dc78af..b05d4bd0d 100644 --- a/android/a2dp.c +++ b/android/a2dp.c @@ -39,9 +39,9 @@ #include "lib/sdp_lib.h" #include "profiles/audio/a2dp-codecs.h" #include "src/log.h" -#include "a2dp.h" #include "hal-msg.h" #include "ipc.h" +#include "a2dp.h" #include "utils.h" #include "bluetooth.h" #include "avdtp.h" @@ -63,6 +63,8 @@ static uint32_t record_id = 0; static guint audio_retry_id = 0; static bool audio_retrying = false; +static struct ipc *hal_ipc = NULL; + struct a2dp_preset { void *data; int8_t len; @@ -226,8 +228,8 @@ static void bt_a2dp_notify_state(struct a2dp_device *dev, uint8_t state) bdaddr2android(&dev->dst, ev.bdaddr); ev.state = state; - ipc_send_notif(HAL_SERVICE_ID_A2DP, HAL_EV_A2DP_CONN_STATE, sizeof(ev), - &ev); + ipc_send_notif(hal_ipc, HAL_SERVICE_ID_A2DP, HAL_EV_A2DP_CONN_STATE, + sizeof(ev), &ev); if (state != HAL_A2DP_STATE_DISCONNECTED) return; @@ -253,8 +255,8 @@ static void bt_audio_notify_state(struct a2dp_setup *setup, uint8_t state) bdaddr2android(&setup->dev->dst, ev.bdaddr); ev.state = state; - ipc_send_notif(HAL_SERVICE_ID_A2DP, HAL_EV_A2DP_AUDIO_STATE, sizeof(ev), - &ev); + ipc_send_notif(hal_ipc, HAL_SERVICE_ID_A2DP, HAL_EV_A2DP_AUDIO_STATE, + sizeof(ev), &ev); } static void disconnect_cb(void *user_data) @@ -597,7 +599,7 @@ static void bt_a2dp_connect(const void *buf, uint16_t len) status = HAL_STATUS_SUCCESS; failed: - ipc_send_rsp(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT, status); + ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT, status); } static void bt_a2dp_disconnect(const void *buf, uint16_t len) @@ -631,7 +633,8 @@ static void bt_a2dp_disconnect(const void *buf, uint16_t len) bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTING); failed: - ipc_send_rsp(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_DISCONNECT, status); + ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_DISCONNECT, + status); } static const struct ipc_handler cmd_handlers[] = { @@ -1540,7 +1543,7 @@ retry: audio_disconnected); } -bool bt_a2dp_register(const bdaddr_t *addr) +bool bt_a2dp_register(struct ipc *ipc, const bdaddr_t *addr) { GError *err = NULL; sdp_record_t *rec; @@ -1573,7 +1576,9 @@ bool bt_a2dp_register(const bdaddr_t *addr) } record_id = rec->handle; - ipc_register(HAL_SERVICE_ID_A2DP, cmd_handlers, + hal_ipc = ipc; + + ipc_register(hal_ipc, HAL_SERVICE_ID_A2DP, cmd_handlers, G_N_ELEMENTS(cmd_handlers)); bt_audio_register(audio_disconnected); @@ -1600,7 +1605,9 @@ void bt_a2dp_unregister(void) g_slist_free_full(devices, a2dp_device_free); devices = NULL; - ipc_unregister(HAL_SERVICE_ID_A2DP); + ipc_unregister(hal_ipc, HAL_SERVICE_ID_A2DP); + hal_ipc = NULL; + audio_ipc_unregister(); bt_adapter_remove_record(record_id); |