From 096a1f31a5baf2e9c65325e409ae377baa81ea0e Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 20 Feb 2024 09:25:43 -0500 Subject: [PATCH] MT#40962 increase idle sleep time If there are no sessions then it makes no senes to process ticks in real time. Sleep up to 0.5 seconds in that case. When sessions are added we are immediately woken up through the conditional variable. Only setting the shutdown flag would not wake up the thread, but a sleep time of half a second should be an acceptable delay for shutdowns. Change-Id: I5aa43382248754ff8dec811038998cf636579734 --- core/AmMediaProcessor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/AmMediaProcessor.cpp b/core/AmMediaProcessor.cpp index a1dbf2ab..3f9a1eee 100644 --- a/core/AmMediaProcessor.cpp +++ b/core/AmMediaProcessor.cpp @@ -249,8 +249,12 @@ void AmMediaProcessorThread::run() uint64_t diff = next_tick - now; - if(diff) - events.waitForEventTimed(diff / 1000); + if(diff) { + if (sessions.empty()) + events.waitForEventTimed(500); // 0.5 s + else + events.waitForEventTimed(diff / 1000); + } } events.processEvents();