summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-19 12:06:02 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-20 11:10:17 +0100
commit3aa9dec5d719e5c18d32c3c0b47786ae64f11955 (patch)
tree810a2d6b5bb431103f4929a808b2551e63dc8eba /4a-hal/4a-hal-controllers
parent07c240d783974970138ab94a4221935edf8ae9b6 (diff)
Send back control current values if no request json
Return current ALSA control values if no request json is specified when calling halmap verbs. Bug-AGL: SPEC-1313 Change-Id: I74cc03cdcbe975979be4ad2d353ee44cf8cc13ed Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers')
-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'",