MediaEventLooper: Calculate lateness from the nearest value

* When the event is late there are two major situations, the first
is when the enqueue time is in past compared to the performance time.
The second happen when the performance time is in past compared to the
enqueue time. The purpose of this change is to calculate the lateness
considering always the nearest of the two values. This way the exceding
latency is trimmed out from the calculus depending on what the actual
source of delay is.
* There is a lot more that could be done by looking at the previous
lateness value.
This commit is contained in:
Dario Casalinuovo 2016-05-07 13:17:54 +02:00
parent 17078f9997
commit e042d9ebff

View File

@ -246,14 +246,11 @@ BMediaEventLooper::ControlLoop()
// in the meantime, so that the client can
// notify to the producer only the portion
// that might be attributable.
bigtime_t lateness = 0;
if (waitUntil > 0) {
lateness = waitUntil - TimeSource()->RealTime();
if (lateness > 0) {
bigtime_t enqueueLatency
= event.enqueue_time - waitUntil;
if (enqueueLatency > 0)
lateness += enqueueLatency;
bigtime_t lateness = waitUntil - TimeSource()->RealTime();
if (lateness < 0) {
if (event.enqueue_time > waitUntil) {
lateness = event.enqueue_time
- TimeSource()->RealTime();
}
}
DispatchEvent(&event, -lateness, hasRealtime);