summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-19 11:01:53 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-20 11:10:17 +0100
commitf741fc82145c57c8dd1e483d9ab26ef2b4a92206 (patch)
tree640f24a4bcd132d4c2c17fb4ff0b761d9eab6229 /4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
parentcdbaaf3f0821c3f991d5a938e5343f877309315a (diff)
Add setting values of a ALSA control using a +/-
Add the possibility to change halmap ALSA controls values using a +/- percentage string. Bug-AGL: SPEC-1313 Change-Id: I3b2cf141fc01171fd403c2602fb3805e654e8d68 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
index f360ceb..4ae5a13 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
@@ -558,10 +558,9 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
return;
}
- json_object_put(previousControlValuesJ);
-
if(! json_object_is_type(requestJson, json_type_object)) {
AFB_ReqFailF(request, "request_json", "Request json is not valid '%s'", json_object_get_string(requestJson));
+ json_object_put(previousControlValuesJ);
json_object_put(normalizedPreviousControlValuesJ);
return;
}
@@ -570,11 +569,13 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
AFB_ReqFailF(request,
"request_json", "Error when trying to get request value object inside request '%s'",
json_object_get_string(requestJson));
+ json_object_put(previousControlValuesJ);
json_object_put(normalizedPreviousControlValuesJ);
return;
}
- if(HalCtlsConvertJsonValues(apiHandle,
+ if((! json_object_is_type(valueJ, json_type_string)) &&
+ HalCtlsConvertJsonValues(apiHandle,
&currentAlsaCtl->ctl.alsaCtlProperties,
valueJ,
&convertedJ,
@@ -583,14 +584,32 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
"request_json",
"Error when trying to convert request values '%s'",
json_object_get_string(valueJ));
+ json_object_put(previousControlValuesJ);
json_object_put(normalizedPreviousControlValuesJ);
return;
}
+ else if(json_object_is_type(valueJ, json_type_string) &&
+ HalCtlsChangePreviousValuesUsingJson(apiHandle,
+ &currentAlsaCtl->ctl.alsaCtlProperties,
+ valueJ,
+ previousControlValuesJ,
+ &convertedJ)) {
+ AFB_ReqFailF(request,
+ "previous_values",
+ "Error when trying to generate changed alsa control values (values : '%s', previous :'%s')",
+ json_object_get_string(valueJ),
+ json_object_get_string(previousControlValuesJ));
+ json_object_put(previousControlValuesJ);
+ json_object_put(normalizedPreviousControlValuesJ);
+ return;
+ }
+
+ json_object_put(previousControlValuesJ);
if(HalCtlsSetAlsaCtlValue(apiHandle, cardIdString, currentAlsaCtl->ctl.numid, convertedJ)) {
AFB_ReqFailF(request,
"alsa_control_call_error",
- "Error while trying to set value on alsa control %i, device '%s', converted '%s'",
+ "Error while trying to set value on alsa control %i, device '%s', converted message '%s'",
currentAlsaCtl->ctl.numid,
cardIdString,
json_object_get_string(convertedJ));