summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/4a-internals-hal/4a-internals-hal-alsacore-link.c23
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, &currentHalData->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;
}