[vlmc-devel] commit: Workflow: Making frame rendering synchrone (Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Wed Mar 17 17:30:24 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Wed Mar 17 17:29:46 2010 +0100| [59d07523adb4278bdaf9492fca13ef5bfe6f8a34] | committer: Hugo Beauzee-Luyssen 

Workflow: Making frame rendering synchrone

IE wait for a frame to be ready when calling getOutput

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=59d07523adb4278bdaf9492fca13ef5bfe6f8a34
---

 src/Workflow/ClipWorkflow.cpp      |    6 ++++--
 src/Workflow/ClipWorkflow.h        |    5 +++--
 src/Workflow/VideoClipWorkflow.cpp |   22 +++++++++++++++++-----
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/Workflow/ClipWorkflow.cpp b/src/Workflow/ClipWorkflow.cpp
index 53e7555..6284d71 100644
--- a/src/Workflow/ClipWorkflow.cpp
+++ b/src/Workflow/ClipWorkflow.cpp
@@ -45,16 +45,18 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) :
     m_renderLock = new QMutex;
     m_availableBuffersMutex = new QMutex;
     m_computedBuffersMutex = new QMutex;
+    m_renderWaitCond = new WaitCondition;
 }
 
 ClipWorkflow::~ClipWorkflow()
 {
+    delete m_renderWaitCond;
+    delete m_computedBuffersMutex;
+    delete m_availableBuffersMutex;
     delete m_renderLock;
     delete m_pausingStateWaitCond;
     delete m_initWaitCond;
     delete m_stateLock;
-    delete m_availableBuffersMutex;
-    delete m_computedBuffersMutex;
 }
 
 void    ClipWorkflow::initialize()
diff --git a/src/Workflow/ClipWorkflow.h b/src/Workflow/ClipWorkflow.h
index e85191f..f689c79 100644
--- a/src/Workflow/ClipWorkflow.h
+++ b/src/Workflow/ClipWorkflow.h
@@ -210,8 +210,8 @@ class   ClipWorkflow : public QObject
         virtual void            releasePrealocated() = 0;
 
     private:
-        WaitCondition*          m_initWaitCond;
-        WaitCondition*          m_pausingStateWaitCond;
+        WaitCondition           *m_initWaitCond;
+        WaitCondition           *m_pausingStateWaitCond;
         /**
          *  \brief              Used by the trackworkflow to query a clipworkflow resync.
          *
@@ -243,6 +243,7 @@ class   ClipWorkflow : public QObject
         qint64                  m_pauseDuration;
         bool                    m_fullSpeedRender;
         int                     debugType;
+        WaitCondition           *m_renderWaitCond;
 
     private slots:
         void                    loadingComplete();
diff --git a/src/Workflow/VideoClipWorkflow.cpp b/src/Workflow/VideoClipWorkflow.cpp
index b7d54b8..414991f 100644
--- a/src/Workflow/VideoClipWorkflow.cpp
+++ b/src/Workflow/VideoClipWorkflow.cpp
@@ -20,12 +20,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include "VideoClipWorkflow.h"
+#include "Clip.h"
+#include "LightVideoFrame.h"
 #include "MainWorkflow.h"
 #include "StackedBuffer.hpp"
-#include "LightVideoFrame.h"
-#include "Clip.h"
+#include "VideoClipWorkflow.h"
 #include "VLCMedia.h"
+#include "WaitCondition.hpp"
 
 #include <QReadWriteLock>
 
@@ -113,10 +114,19 @@ VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
     QMutexLocker    lock( m_renderLock );
     QMutexLocker    lock2( m_computedBuffersMutex );
 
-    if ( preGetOutput() == false )
-        return NULL;
     if ( isEndReached() == true )
         return NULL;
+    if ( preGetOutput() == false )
+    {
+        QMutexLocker    waitLock( m_renderWaitCond->getMutex() );
+        m_computedBuffersMutex->unlock();
+        m_renderLock->unlock();
+
+        m_renderWaitCond->waitLocked();
+
+        m_renderLock->lock();
+        m_computedBuffersMutex->lock();
+    }
     ::StackedBuffer<LightVideoFrame*>* buff;
     if ( mode == ClipWorkflow::Pop )
         buff = new StackedBuffer( m_computedBuffers.dequeue(), this, true );
@@ -161,6 +171,8 @@ VideoClipWorkflow::unlock( VideoClipWorkflow *cw, void *buffer, int width,
     cw->commonUnlock();
     cw->m_renderLock->unlock();
     cw->m_computedBuffersMutex->unlock();
+    QMutexLocker    lock( cw->m_renderWaitCond->getMutex() );
+    cw->m_renderWaitCond->wake();
 }
 
 uint32_t



More information about the Vlmc-devel mailing list