Code simplification and a commont on why fOurBuffers is
maintained as member variable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38668 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -547,7 +547,7 @@ VideoConsumer::_HandleBuffer(BBuffer* buffer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if this is one of our buffers
|
// See if this is one of our BBitmap buffers
|
||||||
uint32 index = 0;
|
uint32 index = 0;
|
||||||
fOurBuffers = true;
|
fOurBuffers = true;
|
||||||
while (index < kBufferCount) {
|
while (index < kBufferCount) {
|
||||||
@@ -557,17 +557,20 @@ VideoConsumer::_HandleBuffer(BBuffer* buffer)
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (index == kBufferCount) {
|
if (index == kBufferCount) {
|
||||||
// no, buffers belong to consumer
|
// Buffers belong to consumer
|
||||||
|
// NOTE: We maintain this in a member variable, since we still need
|
||||||
|
// to recycle this buffer later on, in case it was the last buffer
|
||||||
|
// received before shutting down.
|
||||||
fOurBuffers = false;
|
fOurBuffers = false;
|
||||||
index = (fLastBufferIndex + 1) % kBufferCount;
|
index = (fLastBufferIndex + 1) % kBufferCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dropped = false;
|
|
||||||
bool recycle = true;
|
bool recycle = true;
|
||||||
bigtime_t now = TimeSource()->Now();
|
bigtime_t now = TimeSource()->Now();
|
||||||
if (RunMode() == B_OFFLINE
|
if (RunMode() == B_OFFLINE
|
||||||
|| now < buffer->Header()->start_time
|
|| now < buffer->Header()->start_time + kMaxBufferLateness) {
|
||||||
+ kMaxBufferLateness) {
|
// Only display the buffer if it's not too late, or if we are
|
||||||
|
// in B_OFFLINE run-mode.
|
||||||
if (!fOurBuffers) {
|
if (!fOurBuffers) {
|
||||||
memcpy(fBitmap[index]->Bits(), buffer->Data(),
|
memcpy(fBitmap[index]->Bits(), buffer->Data(),
|
||||||
fBitmap[index]->BitsLength());
|
fBitmap[index]->BitsLength());
|
||||||
@@ -589,17 +592,15 @@ VideoConsumer::_HandleBuffer(BBuffer* buffer)
|
|||||||
}
|
}
|
||||||
fTargetLock.Unlock();
|
fTargetLock.Unlock();
|
||||||
} else {
|
} else {
|
||||||
dropped = true;
|
// Drop the buffer if it's too late.
|
||||||
PROGRESS("VideoConsumer::HandleEvent - DROPPED FRAME\n"
|
|
||||||
" start_time: %lld, current: %lld, latency: %lld\n",
|
|
||||||
buffer->Header()->start_time, TimeSource()->Now(),
|
|
||||||
SchedulingLatency());
|
|
||||||
}
|
|
||||||
if (dropped) {
|
|
||||||
if (fManager->LockWithTimeout(10000) == B_OK) {
|
if (fManager->LockWithTimeout(10000) == B_OK) {
|
||||||
fManager->FrameDropped();
|
fManager->FrameDropped();
|
||||||
fManager->Unlock();
|
fManager->Unlock();
|
||||||
}
|
}
|
||||||
|
PROGRESS("VideoConsumer::HandleEvent - DROPPED FRAME\n"
|
||||||
|
" start_time: %lld, current: %lld, latency: %lld\n",
|
||||||
|
buffer->Header()->start_time, TimeSource()->Now(),
|
||||||
|
SchedulingLatency());
|
||||||
}
|
}
|
||||||
if (recycle)
|
if (recycle)
|
||||||
buffer->Recycle();
|
buffer->Recycle();
|
||||||
|
|||||||
Reference in New Issue
Block a user