aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alsa-binding/Alsa-RegEvt.c48
-rw-r--r--conf.d/cmake/config.cmake11
2 files changed, 54 insertions, 5 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);
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 55dd171..a44371f 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -111,11 +111,12 @@ set(COMPILE_OPTIONS
-fdata-sections
-fPIC
# Personal compilation options
--DMAX_SND_CARD=32 # default ALSA max cards
--DMAX_CARD_DEVICES=32 # 32 devices by sound card should be enough (more investigation needed about this)
--DMAX_DEVICE_SUBDEVICES=8 # 8 subdevices by device should be enough (more investigation needed about this)
--DMAX_LINEAR_DB_SCALE=24 # until 24db volume normalisation use a simple linear scale
--DTLV_BYTE_SIZE=256 # Alsa use 4096 as default but 256 should fit most sndcards
+-DMAX_SND_CARD=32 # default ALSA max cards
+-DMAX_CARD_DEVICES=32 # 32 devices by sound card should be enough (more investigation needed about this)
+-DMAX_DEVICE_SUBDEVICES=8 # 8 subdevices by device should be enough (more investigation needed about this)
+-DMAX_LINEAR_DB_SCALE=24 # until 24db volume normalisation use a simple linear scale
+-DTLV_BYTE_SIZE=256 # Alsa use 4096 as default but 256 should fit most sndcards
+#-DFORCE_STATUS_REFRESH_MS=5000 # Force card/pcm status refresh every X ms (use to be sure to catch every status changes)
-DCONTROL_MAXPATH_LEN=255
CACHE STRING "Compilation flags")
#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.")