summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c35
1 files changed, 31 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 cc29dc9..7ea61ac 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
@@ -488,7 +488,10 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
json_object *requestJson,
*valueJ,
- *convertedJ;
+ *convertedJ,
+ *answerJ,
+ *previousControlValuesJ,
+ *normalizedPreviousControlValuesJ;
apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
if(! apiHandle) {
@@ -524,19 +527,43 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
return;
}
+ snprintf(cardIdString, 6, "hw:%i", currentCtlHalData->sndCardId);
+
+ if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, &currentAlsaCtl->ctl, &previousControlValuesJ)) {
+ AFB_ReqFailF(request, "previous_values", "Error when trying to get unchanged alsa control values");
+ return;
+ }
+ else if(HalCtlsConvertJsonValues(apiHandle,
+ &currentAlsaCtl->ctl.alsaCtlProperties,
+ previousControlValuesJ,
+ &normalizedPreviousControlValuesJ,
+ CONVERSION_ALSACORE_TO_NORMALIZED)) {
+ AFB_ReqFailF(request,
+ "request_json",
+ "Error when trying to normalize unchanged alsa control values json '%s'",
+ json_object_get_string(previousControlValuesJ));
+ json_object_put(previousControlValuesJ);
+ return;
+ }
+
requestJson = AFB_ReqJson(request);
if(! requestJson) {
- AFB_ReqFail(request, "request_json", "Can't get request json");
+ wrap_json_pack(&answerJ,
+ "{s:o}",
+ "current", normalizedPreviousControlValuesJ);
+ AFB_ReqSuccess(request, answerJ, "Current controls values");
+ json_object_put(previousControlValuesJ);
return;
}
+ 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));
return;
}
- snprintf(cardIdString, 6, "hw:%i", currentCtlHalData->sndCardId);
-
if(wrap_json_unpack(requestJson, "{s:o}", "value", &valueJ)) {
AFB_ReqFailF(request,
"request_json", "Error when trying to get request value object inside request '%s'",