diff options
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-alsacore-link.c | 26 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-alsacore-link.h | 8 |
2 files changed, 27 insertions, 7 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 b910899..7b2fd5f 100644 --- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c +++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c @@ -102,8 +102,9 @@ int InternalHalGetCardInfo(afb_api_t apiHandle, json_object *requestJ, json_obje return errorToReturn; } -int InternalHalSubscribeToAlsacoreEvent(afb_api_t apiHandle, - json_object *subscribeQueryJ) +int InternalHalSubscribeUnscubscribeToAlsacoreEvent(afb_api_t apiHandle, + json_object *subscribeQueryJ, + enum AlsacoreSubscribeUnsubscribeType subscriptionType) { int err = 0; @@ -118,14 +119,14 @@ int InternalHalSubscribeToAlsacoreEvent(afb_api_t apiHandle, if(afb_api_call_sync(apiHandle, ALSACORE_API, - ALSACORE_SUBSCRIBE_VERB, + (subscriptionType == ALSACORE_SUBSCRIPTION) ? ALSACORE_SUBSCRIBE_VERB : ALSACORE_UNSUBSCRIBE_VERB, subscribeQueryJ, &responseJ, &returnedError, &returnedInfo)) { AFB_API_ERROR(apiHandle, "Something went wrong during call to verb '%s' of api '%s' with error '%s' and info '%s'", - ALSACORE_SUBSCRIBE_VERB, + (subscriptionType == ALSACORE_SUBSCRIPTION) ? ALSACORE_SUBSCRIBE_VERB : ALSACORE_UNSUBSCRIBE_VERB, ALSACORE_API, returnedError ? returnedError : "not returned", returnedInfo ? returnedInfo : "not returned"); @@ -141,8 +142,9 @@ int InternalHalSubscribeToAlsacoreEvent(afb_api_t apiHandle, return err; } -int InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle, - char *cardId) +int InternalHalSubscribeUnscubscribeToAlsacoreCardEvent(afb_api_t apiHandle, + char *cardId, + enum AlsacoreSubscribeUnsubscribeType subscriptionType) { int err, wrapRet; @@ -157,7 +159,7 @@ int InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle, return -1; } - err = InternalHalSubscribeToAlsacoreEvent(apiHandle, subscribeQueryJ); + err = InternalHalSubscribeUnscubscribeToAlsacoreEvent(apiHandle, subscribeQueryJ, subscriptionType); if(err) { AFB_API_ERROR(apiHandle, "Error %i happened when tried to subscribe to %s card event", @@ -171,6 +173,16 @@ int InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle, return 0; } +int InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle, char *cardId) +{ + return InternalHalSubscribeUnscubscribeToAlsacoreCardEvent(apiHandle, cardId, ALSACORE_SUBSCRIPTION); +} + +int InternalHalUnsubscribeFromAlsacoreCardEvent(afb_api_t apiHandle, char *cardId) +{ + return InternalHalSubscribeUnscubscribeToAlsacoreCardEvent(apiHandle, cardId, ALSACORE_UNSUBSCRIPTION); +} + 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 ee9adb2..84a096a 100644 --- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.h +++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.h @@ -33,6 +33,7 @@ #define ALSACORE_API "alsacore" #define ALSACORE_SUBSCRIBE_VERB "subscribe" +#define ALSACORE_UNSUBSCRIBE_VERB "unsubscribe" #define ALSACORE_GETINFO_VERB "infoget" #define ALSACORE_CTLGET_VERB "ctlget" #define ALSACORE_CTLSET_VERB "ctlset" @@ -40,12 +41,19 @@ #define ALSACORE_CARD_CONTROL_EVENT_NAME "controls" +// Enum for the type of subscription/unsubscription to do with alsacore +enum AlsacoreSubscribeUnsubscribeType { + ALSACORE_SUBSCRIPTION = 0, + ALSACORE_UNSUBSCRIPTION = 1 +}; + // Alsa control types map from string function 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 InternalHalSubscribeToAlsacoreCardEvent(afb_api_t apiHandle, char *cardId); +int InternalHalUnsubscribeFromAlsacoreCardEvent(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); |