--- android/handsfree.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/android/handsfree.c b/android/handsfree.c index 7c8020c..d83f0a2 100644 --- a/android/handsfree.c +++ b/android/handsfree.c @@ -852,15 +852,17 @@ static void at_cmd_btrh(struct hfp_gw_result *result, enum hfp_gw_cmd_type type, static gboolean sco_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer user_data) { - g_io_channel_shutdown(device.sco, TRUE, NULL); - g_io_channel_unref(device.sco); - device.sco = NULL; + struct hf_device *dev = user_data; + + g_io_channel_shutdown(dev->sco, TRUE, NULL); + g_io_channel_unref(dev->sco); + dev->sco = NULL; DBG(""); - device.sco_watch = 0; + dev->sco_watch = 0; - set_audio_state(&device, HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED); + set_audio_state(dev, HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED); return FALSE; } @@ -894,19 +896,20 @@ done: static void connect_sco_cb(GIOChannel *chan, GError *err, gpointer user_data) { + struct hf_device *dev = user_data; + if (err) { error("handsfree: audio connect failed (%s)", err->message); - set_audio_state(&device, - HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED); + set_audio_state(dev, HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED); - if (!(device.features & HFP_HF_FEAT_CODEC)) + if (!(dev->features & HFP_HF_FEAT_CODEC)) return; /* If other failed, try connecting with CVSD */ - if (device.negotiated_codec != CODEC_ID_CVSD) { + if (dev->negotiated_codec != CODEC_ID_CVSD) { info("handsfree: trying fallback with CVSD"); - select_codec(&device, CODEC_ID_CVSD); + select_codec(dev, CODEC_ID_CVSD); } return; @@ -914,11 +917,11 @@ static void connect_sco_cb(GIOChannel *chan, GError *err, gpointer user_data) g_io_channel_set_close_on_unref(chan, TRUE); - device.sco = g_io_channel_ref(chan); - device.sco_watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL, - sco_watch_cb, NULL); + dev->sco = g_io_channel_ref(chan); + dev->sco_watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL, + sco_watch_cb, dev); - set_audio_state(&device, HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTED); + set_audio_state(dev, HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTED); } static bool connect_sco(void) @@ -937,7 +940,7 @@ static bool connect_sco(void) else voice_settings = BT_VOICE_CVSD_16BIT; - io = bt_io_connect(connect_sco_cb, NULL, NULL, &gerr, + io = bt_io_connect(connect_sco_cb, &device, NULL, &gerr, BT_IO_OPT_SOURCE_BDADDR, &adapter_addr, BT_IO_OPT_DEST_BDADDR, &device.bdaddr, BT_IO_OPT_VOICE, voice_settings, @@ -2373,7 +2376,7 @@ static void confirm_sco_cb(GIOChannel *chan, gpointer user_data) goto drop; } - if (!bt_io_accept(chan, connect_sco_cb, NULL, NULL, NULL)) { + if (!bt_io_accept(chan, connect_sco_cb, &device, NULL, NULL)) { error("handsfree: failed to accept audio connection"); goto drop; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html