BMediaEventLooper: Better solution for negative timestamp
* This problem happens only at the startup, so that it's preferred that we deal with it in the BMediaEventLooper side. * This solve some audio stability problems I had with slow systems.
This commit is contained in:
@@ -217,6 +217,7 @@ BMediaEventLooper::ControlLoop()
|
|||||||
bigtime_t waitUntil = B_INFINITE_TIMEOUT;
|
bigtime_t waitUntil = B_INFINITE_TIMEOUT;
|
||||||
bool hasRealtime = false;
|
bool hasRealtime = false;
|
||||||
bool hasEvent = false;
|
bool hasEvent = false;
|
||||||
|
bool hasBooted = false;
|
||||||
|
|
||||||
// While there are no events or it is not time for the earliest event,
|
// While there are no events or it is not time for the earliest event,
|
||||||
// process messages using WaitForMessages. Whenever this funtion times out,
|
// process messages using WaitForMessages. Whenever this funtion times out,
|
||||||
@@ -262,6 +263,15 @@ BMediaEventLooper::ControlLoop()
|
|||||||
waitUntil = TimeSource()->RealTimeFor(
|
waitUntil = TimeSource()->RealTimeFor(
|
||||||
fEventQueue.FirstEventTime(),
|
fEventQueue.FirstEventTime(),
|
||||||
fEventLatency + fSchedulingLatency);
|
fEventLatency + fSchedulingLatency);
|
||||||
|
|
||||||
|
// The first event we handle will have
|
||||||
|
// a negative startup wait. In this case
|
||||||
|
// we just check the port and let the
|
||||||
|
// first event to be executed just now.
|
||||||
|
if (!hasBooted && waitUntil < 0) {
|
||||||
|
waitUntil = 0;
|
||||||
|
hasBooted = true;
|
||||||
|
}
|
||||||
} else if (!hasRealtime) {
|
} else if (!hasRealtime) {
|
||||||
waitUntil = B_INFINITE_TIMEOUT;
|
waitUntil = B_INFINITE_TIMEOUT;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -362,12 +362,6 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, uint32 flags,
|
|||||||
int32 message;
|
int32 message;
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
|
|
||||||
// TODO: Investigate on this issue
|
|
||||||
if (waitUntil < 0) {
|
|
||||||
TRACE("BMediaNode::WaitForMessage: Negative timeout!\n");
|
|
||||||
waitUntil = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
size = read_port_etc(ControlPort(), &message, data,
|
size = read_port_etc(ControlPort(), &message, data,
|
||||||
sizeof(data), B_ABSOLUTE_TIMEOUT, waitUntil);
|
sizeof(data), B_ABSOLUTE_TIMEOUT, waitUntil);
|
||||||
|
|||||||
Reference in New Issue
Block a user