diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 283519f..9e67c7f 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
#include "bluetooth.h"
#include "hal-msg.h"
#include "handsfree-client.h"
+#include "sco.h"
#define HFP_HF_CHANNEL 7
static struct queue *devices = NULL;
static GIOChannel *hfp_hf_server = NULL;
+static struct bt_sco *sco = NULL;
+
static struct device *find_default_device(void)
{
return queue_peek_head(devices);
bt_adapter_remove_record(hfp_hf_record_id);
hfp_hf_record_id = 0;
}
+
+ if (sco) {
+ bt_sco_unref(sco);
+ sco = NULL;
+ }
}
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
if (!enable_hf_client())
goto failed;
+ sco = bt_sco_new(addr);
+ if (!sco) {
+ error("hf-client: Cannot create SCO. HFP AG is in use ?");
+ goto failed;
+ }
+
hal_ipc = ipc;
ipc_register(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT, cmd_handlers,
G_N_ELEMENTS(cmd_handlers));
return true;
failed:
+ cleanup_hfp_hf();
queue_destroy(devices, free);
devices = NULL;