[haiku-commits] r38668 - haiku/trunk/src/apps/mediaplayer/media_node_framework/video

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 16 Sep 2010 14:38:42 +0200 (CEST)

Author: stippi
Date: 2010-09-16 14:38:41 +0200 (Thu, 16 Sep 2010)
New Revision: 38668
Changeset: http://dev.haiku-os.org/changeset/38668

Modified:
   haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp
Log:
Code simplification and a commont on why fOurBuffers is
maintained as member variable.


Modified: 
haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp
===================================================================
--- 
haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp   
    2010-09-16 12:37:45 UTC (rev 38667)
+++ 
haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp   
    2010-09-16 12:38:41 UTC (rev 38668)
@@ -547,7 +547,7 @@
                return;
        }
 
-       // see if this is one of our buffers
+       // See if this is one of our BBitmap buffers
        uint32 index = 0;
        fOurBuffers = true;
        while (index < kBufferCount) {
@@ -557,17 +557,20 @@
                        index++;
        }
        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;
                index = (fLastBufferIndex + 1) % kBufferCount;
        }
 
-       bool dropped = false;
        bool recycle = true;
        bigtime_t now = TimeSource()->Now();
        if (RunMode() == B_OFFLINE
-               || now < buffer->Header()->start_time
-                       + kMaxBufferLateness) {
+               || now < buffer->Header()->start_time + kMaxBufferLateness) {
+               // Only display the buffer if it's not too late, or if we are
+               // in B_OFFLINE run-mode.
                if (!fOurBuffers) {
                        memcpy(fBitmap[index]->Bits(), buffer->Data(),
                                fBitmap[index]->BitsLength());
@@ -589,18 +592,16 @@
                }
                fTargetLock.Unlock();
        } else {
-               dropped = true;
+               // Drop the buffer if it's too late.
+               if (fManager->LockWithTimeout(10000) == B_OK) {
+                       fManager->FrameDropped();
+                       fManager->Unlock();
+               }
                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) {
-                       fManager->FrameDropped();
-                       fManager->Unlock();
-               }
-       }
        if (recycle)
                buffer->Recycle();
 }


Other related posts:

  • » [haiku-commits] r38668 - haiku/trunk/src/apps/mediaplayer/media_node_framework/video - superstippi