From f2bb946bd84dd7fab0c9758a79fc9c42f4c9ae90 Mon Sep 17 00:00:00 2001 From: Dario Casalinuovo Date: Sat, 7 May 2016 13:26:03 +0200 Subject: [PATCH] BMediaEventLooper: Handle events in past differently * When the loop didn't handle an event in performance time, we will attempt at reading the port only if there are messages using a null timeout. --- src/kits/media/MediaEventLooper.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/kits/media/MediaEventLooper.cpp b/src/kits/media/MediaEventLooper.cpp index 2c6b46e22a..5909884ad0 100644 --- a/src/kits/media/MediaEventLooper.cpp +++ b/src/kits/media/MediaEventLooper.cpp @@ -269,13 +269,6 @@ BMediaEventLooper::ControlLoop() waitUntil = TimeSource()->RealTimeFor( fEventQueue.FirstEventTime(), fEventLatency + fSchedulingLatency); - - // TODO: At boot the wait time go - // to negative depending on the system - // speed, this should be fixed. - if (waitUntil < 0) - waitUntil = 0; - } else if (!hasRealtime) waitUntil = B_INFINITE_TIMEOUT; @@ -289,7 +282,12 @@ BMediaEventLooper::ControlLoop() } else hasRealtime = false; } - err = WaitForMessage(waitUntil); + + if (waitUntil != B_INFINITE_TIMEOUT + && TimeSource()->RealTime() >= waitUntil) { + err = WaitForMessage(0); + } else + err = WaitForMessage(waitUntil); } }