summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSimon Fels <simon.fels@canonical.com>2015-10-22 18:05:39 +0200
committerDenis Kenzior <denkenz@gmail.com>2015-10-26 11:43:09 -0500
commit2113b0a5ed97b0e9805efac954dce4acd78fc77d (patch)
treef29a204bbb7c4a1d05bf5023b1e66df1e73fbdb6 /plugins
parent046f032b32779fe13c180fbf3a46f605d1932378 (diff)
downloadofono-2113b0a5ed97b0e9805efac954dce4acd78fc77d.tar.bz2
hfp_ag_bluez5: use codec negotiation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hfp_ag_bluez5.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 3aca792c..22faeb78 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -38,6 +38,11 @@
#include <ofono/modem.h>
#include <ofono/handsfree-audio.h>
+typedef struct GAtChat GAtChat;
+typedef struct GAtResult GAtResult;
+
+#include "drivers/atmodem/atutil.h"
+
#include "hfp.h"
#include "bluez5.h"
#include "bluetooth.h"
@@ -69,12 +74,59 @@ static void hfp_card_remove(struct ofono_handsfree_card *card)
DBG("");
}
+static void codec_negotiation_done_cb(int err, void *data)
+{
+ struct cb_data *cbd = data;
+ ofono_handsfree_card_connect_cb_t cb = cbd->cb;
+
+ DBG("err %d", err);
+
+ if (err < 0) {
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+ goto done;
+ }
+
+ /*
+ * We don't have anything to do at this point as when the
+ * codec negotiation succeeded the emulator internally
+ * already triggered the SCO connection setup of the
+ * handsfree card which also takes over the processing
+ * of the pending dbus message
+ */
+
+done:
+ g_free(cbd);
+}
+
static void hfp_card_connect(struct ofono_handsfree_card *card,
ofono_handsfree_card_connect_cb_t cb,
void *data)
{
+ int err;
+ struct ofono_emulator *em = ofono_handsfree_card_get_data(card);
+ struct cb_data *cbd;
+
DBG("");
- ofono_handsfree_card_connect_sco(card);
+
+ cbd = cb_data_new(cb, data);
+
+ /*
+ * The emulator core will take care if the remote side supports
+ * codec negotiation or not.
+ */
+ err = ofono_emulator_start_codec_negotiation(em,
+ codec_negotiation_done_cb, cbd);
+ if (err < 0) {
+ CALLBACK_WITH_FAILURE(cb, data);
+
+ g_free(cbd);
+ return;
+ }
+
+ /*
+ * We hand over to the emulator core here to establish the
+ * SCO connection once the codec is negotiated
+ * */
}
static void hfp_sco_connected_hint(struct ofono_handsfree_card *card)
@@ -208,6 +260,8 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
OFONO_HANDSFREE_CARD_TYPE_GATEWAY,
HFP_AG_DRIVER, em);
+ ofono_handsfree_card_set_data(card, em);
+
ofono_handsfree_card_set_local(card, local);
ofono_handsfree_card_set_remote(card, remote);