handsfree-audio: Toggle wideband support when the agent registers
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Mon, 15 Apr 2013 13:54:53 +0000 (10:54 -0300)
committerDenis Kenzior <denkenz@gmail.com>
Mon, 15 Apr 2013 12:08:26 +0000 (07:08 -0500)
Each time an agent registers itself, we check if we support deferred
setup and if the agent has mSBC as a codec, if both checks are true,
we enable wideband speech support.

src/handsfree-audio.c

index fc3d15b41e581787b258cea46ca9fd25e9985a6d..c24e78762c060cd29c76816daec41256e9541642 100644 (file)
@@ -646,7 +646,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
        unsigned char *codecs;
        DBusMessageIter iter, array;
        int length, i;
-       gboolean has_cvsd = FALSE;
+       gboolean has_cvsd = FALSE, has_msbc = FALSE;
 
        if (agent)
                return __ofono_error_in_use(msg);
@@ -668,10 +668,17 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
        for (i = 0; i < length; i++) {
                if (codecs[i] == HFP_CODEC_CVSD)
                        has_cvsd = TRUE;
-               else if (codecs[i] != HFP_CODEC_MSBC)
+               else if (codecs[i] == HFP_CODEC_MSBC)
+                       has_msbc = TRUE;
+               else
                        return __ofono_error_invalid_args(msg);
        }
 
+       if (has_msbc && defer_setup == 1)
+               has_wideband = TRUE;
+       else
+               has_wideband = FALSE;
+
        if (has_cvsd == FALSE) {
                ofono_error("CVSD codec is mandatory");
                return __ofono_error_invalid_args(msg);