From ffeb987dc475fb6a84f5c00a42c9b0ac86718d29 Mon Sep 17 00:00:00 2001 From: Dario Casalinuovo Date: Sun, 31 Jan 2016 12:54:12 +0100 Subject: [PATCH] BMediaEventLooper: Make lateness calculus in real time * After having this patch applied locally for some time, I'm going to be sure that we have to deal only with real_time values. * Since RealTime() is just a system_time() wrapper, the code will be slightly improved in performances too. * Additionally it performs very well when the thread is externally stopped (such as debugging it), so that the audio recover almost immediately. --- src/kits/media/MediaEventLooper.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/kits/media/MediaEventLooper.cpp b/src/kits/media/MediaEventLooper.cpp index 5110b24c05..8cb3f22975 100644 --- a/src/kits/media/MediaEventLooper.cpp +++ b/src/kits/media/MediaEventLooper.cpp @@ -241,12 +241,11 @@ BMediaEventLooper::ControlLoop() err = fRealTimeQueue.RemoveFirstEvent(&event); if (err == B_OK) { - // We are going to do this calculus in performance time + // We are going to do this calculus in real time // because otherwise we could get erroneous values. // This calculus allow us to detect both early and late // buffers, this is the meaning of the lateness concept. - bigtime_t lateness = event.event_time - fEventLatency - - fSchedulingLatency - TimeSource()->Now(); + bigtime_t lateness = waitUntil - TimeSource()->RealTime(); DispatchEvent(&event, -lateness, hasRealtime); } } else if (err != B_OK)