summaryrefslogtreecommitdiff
path: root/android/hal-a2dp.c
diff options
context:
space:
mode:
authorJakub Tyszkowski <jakub.tyszkowski@tieto.com>2013-12-05 11:37:15 +0100
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-12-08 17:47:42 +0200
commit2a4b5e91c5e4b963a95d56a45d21d67a298b8c44 (patch)
treee92c1723f72f2c311c3ac68760d439be2b689f38 /android/hal-a2dp.c
parentddbd2e9e62116c88e2addcb665f836a495fa713b (diff)
downloadbluez-2a4b5e91c5e4b963a95d56a45d21d67a298b8c44.tar.gz
android/a2dp: Unregister ipc handlers if init fails
Add ipc handlers cleanup if init fails. Send proper status if already initialized.
Diffstat (limited to 'android/hal-a2dp.c')
-rw-r--r--android/hal-a2dp.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/android/hal-a2dp.c b/android/hal-a2dp.c
index cf39ba226..c8989957d 100644
--- a/android/hal-a2dp.c
+++ b/android/hal-a2dp.c
@@ -96,9 +96,13 @@ static bt_status_t disconnect(bt_bdaddr_t *bd_addr)
static bt_status_t init(btav_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
+ int ret;
DBG("");
+ if (interface_ready())
+ return BT_STATUS_DONE;
+
cbs = callbacks;
hal_ipc_register(HAL_SERVICE_ID_A2DP, ev_handlers,
@@ -106,8 +110,15 @@ static bt_status_t init(btav_callbacks_t *callbacks)
cmd.service_id = HAL_SERVICE_ID_A2DP;
- return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+ ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, 0, NULL, NULL);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ cbs = NULL;
+ hal_ipc_unregister(HAL_SERVICE_ID_A2DP);
+ }
+
+ return ret;
}
static void cleanup()