summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2013-04-23 14:21:43 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-04-23 10:30:15 -0500
commit9a3cfcd109515026d82243e156bd691dc9c51aa2 (patch)
treedbb4f8d67be7236ba222ed0fd8846a69d4f07f0a /src
parentcf6dce3445290ee96015d9d524e90a588c4b9bc4 (diff)
downloadofono-9a3cfcd109515026d82243e156bd691dc9c51aa2.tar.bz2
core: Add SetProperty for EchoCancelingNoiseReduction
This patch extends SetProperty method of the Handsfree interface allowing to disable echo canceling and noise reduction feature in the audio gateway through a D-Bus method call. Once disabled, it is not allowed to enable it using this procedure.
Diffstat (limited to 'src')
-rw-r--r--src/handsfree.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/handsfree.c b/src/handsfree.c
index 6b15a243..b23cc3ab 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -217,11 +217,36 @@ static void voicerec_set_cb(const struct ofono_error *error, void *data)
&hf->voice_recognition);
}
+static void nrec_set_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_handsfree *hf = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ __ofono_dbus_pending_reply(&hf->pending,
+ __ofono_error_failed(hf->pending));
+ return;
+ }
+
+ hf->nrec = FALSE;
+
+ __ofono_dbus_pending_reply(&hf->pending,
+ dbus_message_new_method_return(hf->pending));
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "EchoCancelingNoiseReduction",
+ DBUS_TYPE_BOOLEAN,
+ &hf->nrec);
+}
+
static DBusMessage *handsfree_set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct ofono_handsfree *hf = data;
DBusMessageIter iter, var;
+ ofono_bool_t enabled;
const char *name;
if (hf->pending)
@@ -241,28 +266,39 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
dbus_message_iter_recurse(&iter, &var);
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &enabled);
+
if (g_str_equal(name, "VoiceRecognition") == TRUE) {
- ofono_bool_t enabled;
if (!hf->driver->voice_recognition)
return __ofono_error_not_implemented(msg);
- if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
- return __ofono_error_invalid_args(msg);
-
- dbus_message_iter_get_basic(&var, &enabled);
-
if (hf->voice_recognition == enabled)
return dbus_message_new_method_return(msg);
hf->voice_recognition_pending = enabled;
hf->pending = dbus_message_ref(msg);
hf->driver->voice_recognition(hf, enabled, voicerec_set_cb, hf);
+ } else if (g_str_equal(name, "EchoCancelingNoiseReduction") == TRUE) {
- return NULL;
- }
+ if (!(hf->ag_features & HFP_AG_FEATURE_ECNR))
+ return __ofono_error_not_supported(msg);
- return __ofono_error_invalid_args(msg);
+ if (!hf->driver->disable_nrec || enabled == TRUE)
+ return __ofono_error_not_implemented(msg);
+
+ if (hf->nrec == FALSE)
+ return dbus_message_new_method_return(msg);
+
+ hf->pending = dbus_message_ref(msg);
+ hf->driver->disable_nrec(hf, nrec_set_cb, hf);
+ } else
+ return __ofono_error_invalid_args(msg);
+
+ return NULL;
}
static void request_phone_number_cb(const struct ofono_error *error,