diff options
-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 |