summaryrefslogtreecommitdiffstats
path: root/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/4a-internals-hal/4a-internals-hal-alsacore-link.c')
-rw-r--r--src/4a-internals-hal/4a-internals-hal-alsacore-link.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
index e1ad6dd..81e60f9 100644
--- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
+++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
@@ -295,24 +295,28 @@ int InternalHalUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct
if(err) {
return err;
}
+ else if(! currentAlsaCtl->alsaCtlProperties) {
+ AFB_API_ERROR(apiHandle, "Data structure to store alsa control properties is not allocated");
+ err = -9;
+ }
// TBD JAI : get dblinear/dbminmax/... values
else if(wrap_json_unpack(returnedDataJ,
"{s:i s:s s:{s?:i s?:i s?:i s?:i s?:i}}",
"id", &currentAlsaCtl->numid,
"name", &name,
"ctl",
- "type", (int *) &currentAlsaCtl->alsaCtlProperties.type,
- "count", &currentAlsaCtl->alsaCtlProperties.count,
- "min", &currentAlsaCtl->alsaCtlProperties.minval,
- "max", &currentAlsaCtl->alsaCtlProperties.maxval,
- "step", &currentAlsaCtl->alsaCtlProperties.step)) {
+ "type", (int *) &currentAlsaCtl->alsaCtlProperties->type,
+ "count", &currentAlsaCtl->alsaCtlProperties->count,
+ "min", &currentAlsaCtl->alsaCtlProperties->minval,
+ "max", &currentAlsaCtl->alsaCtlProperties->maxval,
+ "step", &currentAlsaCtl->alsaCtlProperties->step)) {
AFB_API_ERROR(apiHandle,
"Didn't succeed to get control %i properties on device '%s' : '%s'",
currentAlsaCtl->numid,
cardId,
json_object_get_string(returnedDataJ));
- err = -9;
+ err = -10;
}
else {
currentAlsaCtl->name = strdup(name);
@@ -578,6 +582,11 @@ void InternalHalActionOnAlsaCtl(afb_req_t request)
return;
}
+ if(! currentAlsaCtl->ctl.alsaCtlProperties) {
+ afb_req_fail(request, "alsa_control_not_available", "Alsa control is not available");
+ return;
+ }
+
snprintf(cardIdString, 6, "hw:%i", currentHalData->sndCardId);
if(InternalHalGetAlsaCtlValues(apiHandle, cardIdString, &currentAlsaCtl->ctl, &previousControlValuesJ)) {
@@ -585,7 +594,7 @@ void InternalHalActionOnAlsaCtl(afb_req_t request)
return;
}
else if(InternalHalConvertJsonValues(apiHandle,
- &currentAlsaCtl->ctl.alsaCtlProperties,
+ currentAlsaCtl->ctl.alsaCtlProperties,
previousControlValuesJ,
&normalizedPreviousControlValuesJ,
CONVERSION_ALSACORE_TO_NORMALIZED)) {
@@ -632,7 +641,7 @@ void InternalHalActionOnAlsaCtl(afb_req_t request)
if((! json_object_is_type(valueJ, json_type_string)) &&
InternalHalConvertJsonValues(apiHandle,
- &currentAlsaCtl->ctl.alsaCtlProperties,
+ currentAlsaCtl->ctl.alsaCtlProperties,
valueJ,
&convertedJ,
CONVERSION_NORMALIZED_TO_ALSACORE)) {
@@ -646,7 +655,7 @@ void InternalHalActionOnAlsaCtl(afb_req_t request)
}
else if(json_object_is_type(valueJ, json_type_string) &&
InternalHalChangePreviousValuesUsingJson(apiHandle,
- &currentAlsaCtl->ctl.alsaCtlProperties,
+ currentAlsaCtl->ctl.alsaCtlProperties,
valueJ,
previousControlValuesJ,
&convertedJ)) {
@@ -682,7 +691,7 @@ void InternalHalActionOnAlsaCtl(afb_req_t request)
return;
}
else if(InternalHalConvertJsonValues(apiHandle,
- &currentAlsaCtl->ctl.alsaCtlProperties,
+ currentAlsaCtl->ctl.alsaCtlProperties,
appliedControlValuesJ,
&normalizedAppliedControlValuesJ,
CONVERSION_ALSACORE_TO_NORMALIZED)) {