summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Desneux <stephane.desneux@iot.bzh>2019-10-17 13:41:13 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-10-17 13:41:13 +0000
commit08b3b84be12627c62b289a75dc0f6c752300df55 (patch)
treea96f16b250e4c477fc4f00542d661dd6c70cb45f
parent554e65bd655021c0779bb1c06dbc75602bbf0117 (diff)
parent7dafc934fbe6eff77bb801717c6a64097b04978c (diff)
Merge "Rework Alsacore subscription functions"
-rw-r--r--src/4a-internals-hal/4a-internals-hal-alsacore-link.c45
-rw-r--r--src/4a-internals-hal/4a-internals-hal-alsacore-link.h2
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c2
3 files changed, 38 insertions, 11 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 1a89b23..b910899 100644
--- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
+++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
@@ -102,20 +102,17 @@ int InternalHalGetCardInfo(afb_api_t apiHandle, json_object *requestJ, json_obje
return errorToReturn;
}
-int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId)
+int InternalHalSubscribeToAlsacoreEvent(afb_api_t apiHandle,
+ json_object *subscribeQueryJ)
{
- int err = 0, wrapRet;
+ int err = 0;
char *returnedError = NULL, *returnedInfo = NULL;
- json_object *subscribeQueryJ, *responseJ = NULL;
+ json_object *responseJ = NULL;
- wrapRet = wrap_json_pack(&subscribeQueryJ,
- "{s:s, s:s}",
- "event", ALSACORE_CARD_CONTROL_EVENT_NAME,
- "devid", cardId);
- if(wrapRet) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate subscription query json object");
+ if(! apiHandle || ! subscribeQueryJ) {
+ AFB_API_ERROR(apiHandle, "Invalid argument(s)");
return -1;
}
@@ -144,6 +141,36 @@ int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId)
return err;
}
+int InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle,
+ char *cardId)
+{
+ int err, wrapRet;
+
+ json_object *subscribeQueryJ = NULL;
+
+ wrapRet = wrap_json_pack(&subscribeQueryJ,
+ "{s:s, s:s}",
+ "event", ALSACORE_CARD_CONTROL_EVENT_NAME,
+ "devid", cardId);
+ if(wrapRet) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate subscription query json object");
+ return -1;
+ }
+
+ err = InternalHalSubscribeToAlsacoreEvent(apiHandle, subscribeQueryJ);
+ if(err) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i happened when tried to subscribe to %s card event",
+ err,
+ ALSACORE_API);
+ if(! subscribeQueryJ)
+ json_object_put(subscribeQueryJ);
+ return -2;
+ }
+
+ return 0;
+}
+
int InternalHalGetAlsaCtlInfo(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl, json_object **returnedDataJ)
{
int wrapRet;
diff --git a/src/4a-internals-hal/4a-internals-hal-alsacore-link.h b/src/4a-internals-hal/4a-internals-hal-alsacore-link.h
index dccf266..ee9adb2 100644
--- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.h
+++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.h
@@ -45,7 +45,7 @@ snd_ctl_elem_type_t InternalHalMapsAlsaTypeToEnum(const char *label);
// Internals HAL alsacore calls funtions
int InternalHalGetCardInfo(afb_api_t apiHandle, json_object *requestJ, json_object **responseJ);
-int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId);
+int InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle, char *cardId);
int InternalHalUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl);
int InternalHalSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ);
int InternalHalCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *alsaCtlToCreate);
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index cef8605..34fbe74 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -1116,7 +1116,7 @@ int InternalHalHandleOneHalMapObject(afb_api_t apiHandle, struct InternalHalAlsa
halMapData->action = toLoadAction;
}
- if(InternalHalSubscribeToAlsaCardEvent(apiHandle, cardNbString)) {
+ if(InternalHalSubscribeToAlsacoreCardEvent(apiHandle, cardNbString)) {
AFB_API_ERROR(apiHandle, "Error when trying to subscribe to alsacore event for audio card '%s'", cardNbString);
return -7;
}