diff options
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-alsacore-link.c | 45 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-alsacore-link.h | 2 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-cb.c | 2 |
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; } |