* Automatic white space cleanup

* Small hack to display at least some frames (one every 15 frames) when the
  CPU is utterly incapable of decoding video fast enough.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31610 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-07-16 22:20:43 +00:00
parent da82d38f42
commit 36c088531f
@@ -665,6 +665,8 @@ VideoProducer::_FrameGeneratorThread()
bool forceSendingBuffer = true;
bigtime_t lastFrameSentAt = 0;
int64 lastPlaylistFrame = 0;
int32 droppedFrames = 0;
const int32 kMaxDroppedFrames = 15;
bool running = true;
while (running) {
TRACE("_FrameGeneratorThread: loop: %Ld\n", fFrame);
@@ -744,7 +746,8 @@ VideoProducer::_FrameGeneratorThread()
if (ignoreEvent || !fRunning || !fEnabled) {
TRACE("_FrameGeneratorThread: ignore event\n");
// nothing to do
} else if (nextWaitUntil < system_time()) {
} else if (nextWaitUntil < system_time()
&& droppedFrames < kMaxDroppedFrames) {
// Drop frame if it's at least a frame late.
printf("VideoProducer: dropped frame (%Ld)\n", fFrame);
if (fManager->LockWithTimeout(10000) == B_OK) {
@@ -752,6 +755,7 @@ VideoProducer::_FrameGeneratorThread()
fManager->Unlock();
}
// next frame
droppedFrames++;
fFrame++;
} else if (playingDirection != 0 || forceSendingBuffer) {
// Send buffers only, if playing, the node is running and
@@ -759,16 +763,16 @@ VideoProducer::_FrameGeneratorThread()
TRACE("_FrameGeneratorThread: produce frame\n");
BAutolock _(fLock);
// Fetch a buffer from the buffer group
BBuffer *buffer = fUsedBufferGroup->RequestBuffer(
BBuffer* buffer = fUsedBufferGroup->RequestBuffer(
fConnectedFormat.display.bytes_per_row
* fConnectedFormat.display.line_count, 0LL);
if (buffer) {
if (buffer != NULL) {
// Fill out the details about this buffer.
media_header *h = buffer->Header();
media_header* h = buffer->Header();
h->type = B_MEDIA_RAW_VIDEO;
h->time_source = TimeSource()->ID();
h->size_used = fConnectedFormat.display.bytes_per_row
* fConnectedFormat.display.line_count;
* fConnectedFormat.display.line_count;
// For a buffer originating from a device, you might
// want to calculate this based on the
// PerformanceTimeFor the time your buffer arrived at
@@ -777,7 +781,7 @@ VideoProducer::_FrameGeneratorThread()
// TODO: Fix the runmode stuff! Setting the consumer to B_OFFLINE does
// not do the trick. I made the VideoConsumer check the performance
// time of the buffer and if it is 0, it plays it regardless.
if (playingMode < 0) {
if (playingMode < 0 || droppedFrames >= kMaxDroppedFrames) {
h->start_time = 0;
}
h->file_pos = 0;
@@ -834,6 +838,7 @@ h->start_time = 0;
}
// next frame
fFrame++;
droppedFrames = 0;
} else {
TRACE("_FrameGeneratorThread: not playing\n");
// next frame