aboutsummaryrefslogtreecommitdiffstats
path: root/alsa-binding/Alsa-RegEvt.c
diff options
context:
space:
mode:
Diffstat (limited to 'alsa-binding/Alsa-RegEvt.c')
-rw-r--r--alsa-binding/Alsa-RegEvt.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/alsa-binding/Alsa-RegEvt.c b/alsa-binding/Alsa-RegEvt.c
index 1241e0e..b105288 100644
--- a/alsa-binding/Alsa-RegEvt.c
+++ b/alsa-binding/Alsa-RegEvt.c
@@ -382,6 +382,44 @@ STATIC int sndCardTimerForCreatedFileCB(TimerHandleT *context)
return 1;
}
+#ifdef FORCE_STATUS_REFRESH_MS
+STATIC int forceEventRefreshCB(TimerHandleT *context)
+{
+ int err;
+
+ sndCardsT *sndCards = (sndCardsT *) context->context;
+
+ pcmEvtHandleT *currentPcmToRefresh;
+
+ if(! sndCards) {
+ AFB_ERROR("No 'sndCardsT' data available, impossible to refresh");
+ context->count = 1;
+ return -1;
+ }
+
+ updateAllAlsaCardsAvailabilityAndFireEvents(sndCards);
+
+ if(cds_list_empty(&sndCards->pcmMonitoringHead)) {
+ AFB_DEBUG("No pcm monitoring launched, nothing to refresh");
+ }
+ else {
+ cds_list_for_each_entry(currentPcmToRefresh, &sndCards->pcmMonitoringHead, node) {
+ err = updatePcmAvailabilityAndFireEvent(currentPcmToRefresh);
+ if(err)
+ AFB_ERROR("Error %i happened when tried to refresh %s pcm hw:%i,%i,%i availability",
+ err,
+ (currentPcmToRefresh->stream == SND_PCM_STREAM_PLAYBACK) ? "playback" : "capture",
+ currentPcmToRefresh->card,
+ currentPcmToRefresh->device,
+ currentPcmToRefresh->subdevice);
+ }
+ }
+
+ context->count = 2;
+ return 1;
+}
+#endif
+
STATIC int pcmEventCB(sd_event_source* src, int fd, uint32_t revents, void* userData)
{
int err;
@@ -943,6 +981,16 @@ PUBLIC void alsaEvtSubscribeUnsubscribe(afb_req_t request, EventSubscribeUnsubsc
sndCards = calloc(1, sizeof(sndCardsT));
sndCards->apiHandle = afb_req_get_api(request);
CDS_INIT_LIST_HEAD(&sndCards->pcmMonitoringHead);
+
+#ifdef FORCE_STATUS_REFRESH_MS
+ TimerHandleT *refreshStatusTimerHandle = calloc(1, sizeof(TimerHandleT));
+
+ refreshStatusTimerHandle->uid = "Refresh status for event generation timer";
+ refreshStatusTimerHandle->count = 2;
+ refreshStatusTimerHandle->delay = FORCE_STATUS_REFRESH_MS;
+
+ TimerEvtStart(sndCards->apiHandle, refreshStatusTimerHandle, forceEventRefreshCB, (void *) sndCards);
+#endif
}
queryJ = afb_req_json(request);