diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-10-02 16:33:03 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-10-02 16:41:06 +0200 |
commit | fea205f5eabfb224ce2c9c2c58fe0e4a0ba0befd (patch) | |
tree | 8e2bc99811359178264d43a3d87af09d0fc66648 /alsa-binding/Alsa-RegEvt.c | |
parent | 1238224125535c8a64615dff006b116d9c78e5b3 (diff) |
Add a definition to force status refresh
Add a 'FORCE_STATUS_REFRESH_MS' definition that can be use to force
cards/PCM status refresh.
Might be used in case of missed events using 'inotify'.
BUG-AGL: SPEC-2849
Change-Id: I8de80a95b752e5e4a14ad433460598e371d3a39f
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'alsa-binding/Alsa-RegEvt.c')
-rw-r--r-- | alsa-binding/Alsa-RegEvt.c | 48 |
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); |