diff options
author | Stéphane Desneux <stephane.desneux@iot.bzh> | 2019-10-17 13:41:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@automotivelinux.org> | 2019-10-17 13:41:13 +0000 |
commit | b93502de47c945ab80bba7baa8ab84da1ee08499 (patch) | |
tree | b5f76e7e557b5fcc5618fe5097fb23897a3fce31 | |
parent | 178e5b6cea2e79c07a0b06de2d18600d28478b17 (diff) | |
parent | a24105126a8293cd91216f45a91c4ae6f3b8263a (diff) |
Merge "Unsubscribe from unwanted events"
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-alsacore-link.c | 23 |
1 files changed, 20 insertions, 3 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 99b50a8..774054c 100644 --- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c +++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c @@ -87,7 +87,9 @@ int InternalHalHandleAlsaCoreCardControlEvent(afb_api_t apiHandle, json_object *eventJ, struct HalData *currentHalData) { - int numid, cardidx; + int numid, cardidx, controlsUsingCardCount = 0, controlUsedCount = 0; + + char cardNbString[6]; json_object *valuesJ, *normalizedValuesJ; @@ -126,6 +128,9 @@ int InternalHalHandleAlsaCoreCardControlEvent(afb_api_t apiHandle, // Search for corresponding numid in ALSA controls list, if found, launch callback (if available) cds_list_for_each_entry(currentHalMapControl, ¤tHalData->internalHalData->halMapListHead, node) { + if(currentHalMapControl->cardNb == cardidx) + controlsUsingCardCount++; + if(currentHalMapControl->cardNb != cardidx || ! currentHalMapControl->ctl.alsaCtlProperties || currentHalMapControl->ctl.numid != numid) @@ -164,16 +169,28 @@ int InternalHalHandleAlsaCoreCardControlEvent(afb_api_t apiHandle, currentHalMapControl->ctl.numid); } - return 0; + controlUsedCount++; } + if(! controlsUsingCardCount) { + AFB_API_INFO(apiHandle, + "Receiving events from not handle card %i, unscubscribe from these events", + cardidx); + snprintf(cardNbString, sizeof(cardNbString), "hw:%i", cardidx); + InternalHalUnsubscribeFromAlsacoreCardEvent(apiHandle, cardNbString); + return 1; + } + + if(controlUsedCount) + return 0; + AFB_API_INFO(apiHandle, "Alsacore event with an unrecognized numid: %i, evtname=%s [msg=%s]", numid, evtLabel, json_object_get_string(eventJ)); - return 1; + return 2; } |