diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-12-19 16:23:46 +0100 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-12-20 15:18:36 +0100 |
commit | 2c9738f3741ca79b7859ec415a873d6624bb57fa (patch) | |
tree | 2b9b8f3f35e67e156b540217894ea10e1fd77b15 | |
parent | 5b607a175a5c8ddbbab12b384a6ea9fd02ab0485 (diff) |
Send back control previous and current values
Send back control previous and current values if the value(s) specified
in request json has been applied correctly when calling halmap verbs.
Bug-AGL: SPEC-1313
Change-Id: Ie190b4749a6739945a82532909281fb70c92df5d
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c | 41 |
1 files changed, 36 insertions, 5 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 a6ff2c6..6da534b 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 @@ -491,7 +491,9 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) *convertedJ, *answerJ, *previousControlValuesJ, - *normalizedPreviousControlValuesJ; + *normalizedPreviousControlValuesJ, + *appliedControlValuesJ, + *normalizedAppliedControlValuesJ; apiHandle = (AFB_ApiT) afb_request_get_dynapi(request); if(! apiHandle) { @@ -557,10 +559,10 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) } json_object_put(previousControlValuesJ); - json_object_put(normalizedPreviousControlValuesJ); 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(normalizedPreviousControlValuesJ); return; } @@ -568,6 +570,7 @@ 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(normalizedPreviousControlValuesJ); return; } @@ -580,21 +583,49 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) "request_json", "Error when trying to convert request values '%s'", json_object_get_string(valueJ)); + json_object_put(normalizedPreviousControlValuesJ); return; } 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', message '%s'", + "Error while trying to set value on alsa control %i, device '%s', converted '%s'", currentAlsaCtl->ctl.numid, cardIdString, - json_object_get_string(requestJson)); + json_object_get_string(convertedJ)); json_object_put(convertedJ); + json_object_put(normalizedPreviousControlValuesJ); return; } json_object_put(convertedJ); - AFB_ReqSuccess(request, NULL, "Action on alsa control correctly done"); + if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &appliedControlValuesJ)) { + AFB_ReqFailF(request, "applied_values", "Error when trying to get applied alsa control values"); + json_object_put(normalizedPreviousControlValuesJ); + return; + } + else if(HalCtlsConvertJsonValues(apiHandle, + ¤tAlsaCtl->ctl.alsaCtlProperties, + appliedControlValuesJ, + &normalizedAppliedControlValuesJ, + CONVERSION_ALSACORE_TO_NORMALIZED)) { + AFB_ReqFailF(request, + "request_json", + "Error when trying to normalize applied values json '%s'", + json_object_get_string(appliedControlValuesJ)); + json_object_put(normalizedPreviousControlValuesJ); + json_object_put(appliedControlValuesJ); + return; + } + + json_object_put(appliedControlValuesJ); + + wrap_json_pack(&answerJ, + "{s:o, s:o}", + "previous", normalizedPreviousControlValuesJ, + "current", normalizedAppliedControlValuesJ); + + AFB_ReqSuccess(request, answerJ, "Values correctly applied on alsa control"); }
\ No newline at end of file |