* 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; bool forceSendingBuffer = true;
bigtime_t lastFrameSentAt = 0; bigtime_t lastFrameSentAt = 0;
int64 lastPlaylistFrame = 0; int64 lastPlaylistFrame = 0;
int32 droppedFrames = 0;
const int32 kMaxDroppedFrames = 15;
bool running = true; bool running = true;
while (running) { while (running) {
TRACE("_FrameGeneratorThread: loop: %Ld\n", fFrame); TRACE("_FrameGeneratorThread: loop: %Ld\n", fFrame);
@@ -744,7 +746,8 @@ VideoProducer::_FrameGeneratorThread()
if (ignoreEvent || !fRunning || !fEnabled) { if (ignoreEvent || !fRunning || !fEnabled) {
TRACE("_FrameGeneratorThread: ignore event\n"); TRACE("_FrameGeneratorThread: ignore event\n");
// nothing to do // 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. // Drop frame if it's at least a frame late.
printf("VideoProducer: dropped frame (%Ld)\n", fFrame); printf("VideoProducer: dropped frame (%Ld)\n", fFrame);
if (fManager->LockWithTimeout(10000) == B_OK) { if (fManager->LockWithTimeout(10000) == B_OK) {
@@ -752,6 +755,7 @@ VideoProducer::_FrameGeneratorThread()
fManager->Unlock(); fManager->Unlock();
} }
// next frame // next frame
droppedFrames++;
fFrame++; fFrame++;
} else if (playingDirection != 0 || forceSendingBuffer) { } else if (playingDirection != 0 || forceSendingBuffer) {
// Send buffers only, if playing, the node is running and // Send buffers only, if playing, the node is running and
@@ -762,7 +766,7 @@ VideoProducer::_FrameGeneratorThread()
BBuffer* buffer = fUsedBufferGroup->RequestBuffer( BBuffer* buffer = fUsedBufferGroup->RequestBuffer(
fConnectedFormat.display.bytes_per_row fConnectedFormat.display.bytes_per_row
* fConnectedFormat.display.line_count, 0LL); * fConnectedFormat.display.line_count, 0LL);
if (buffer) { if (buffer != NULL) {
// Fill out the details about this buffer. // Fill out the details about this buffer.
media_header* h = buffer->Header(); media_header* h = buffer->Header();
h->type = B_MEDIA_RAW_VIDEO; h->type = B_MEDIA_RAW_VIDEO;
@@ -777,7 +781,7 @@ VideoProducer::_FrameGeneratorThread()
// TODO: Fix the runmode stuff! Setting the consumer to B_OFFLINE does // TODO: Fix the runmode stuff! Setting the consumer to B_OFFLINE does
// not do the trick. I made the VideoConsumer check the performance // not do the trick. I made the VideoConsumer check the performance
// time of the buffer and if it is 0, it plays it regardless. // 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->start_time = 0;
} }
h->file_pos = 0; h->file_pos = 0;
@@ -834,6 +838,7 @@ h->start_time = 0;
} }
// next frame // next frame
fFrame++; fFrame++;
droppedFrames = 0;
} else { } else {
TRACE("_FrameGeneratorThread: not playing\n"); TRACE("_FrameGeneratorThread: not playing\n");
// next frame // next frame