This patch makes CVSD codec mandatory when registering a Handsfree
Audio Agent.
---
 src/handsfree-audio.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 50bd861..d0ccf29 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -448,6 +448,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
        unsigned char *codecs;
        DBusMessageIter iter, array;
        int length, i;
+       gboolean has_cvsd = FALSE;
 
        if (agent)
                return __ofono_error_in_use(msg);
@@ -467,11 +468,17 @@ static DBusMessage *am_agent_register(DBusConnection 
*conn,
                return __ofono_error_invalid_args(msg);
 
        for (i = 0; i < length; i++) {
-               if (codecs[i] != HFP_CODEC_CVSD &&
-                               codecs[i] != HFP_CODEC_MSBC)
+               if (codecs[i] == HFP_CODEC_CVSD)
+                       has_cvsd = TRUE;
+               else if (codecs[i] != HFP_CODEC_MSBC)
                        return __ofono_error_invalid_args(msg);
        }
 
+       if (has_cvsd == FALSE) {
+               ofono_error("CVSD codec is mandatory");
+               return __ofono_error_invalid_args(msg);
+       }
+
        agent = g_new0(struct agent, 1);
        agent->owner = g_strdup(sender);
        agent->path = g_strdup(path);
-- 
1.7.11.7

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to