[vlmc-devel] TrackWorkflow: Simplify renderOneFrame

Hugo Beauzée-Luyssen git at videolan.org
Sun Mar 27 17:03:56 CEST 2016


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Mar 27 16:47:06 2016 +0200| [4e8e9bcc23a67de97a5326673b658a14b88da908] | committer: Hugo Beauzée-Luyssen

TrackWorkflow: Simplify renderOneFrame

> https://code.videolan.org/videolan/vlmc/commit/4e8e9bcc23a67de97a5326673b658a14b88da908
---

 src/Workflow/TrackWorkflow.cpp | 17 ++++-------------
 src/Workflow/TrackWorkflow.h   |  3 +--
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index cd3ad52..e27602e 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -50,7 +50,6 @@ TrackWorkflow::TrackWorkflow( Workflow::TrackType type, quint32 trackId  ) :
         m_lastFrame( 0 ),
         m_trackId( trackId )
 {
-    m_renderOneFrameMutex = new QMutex;
     m_clipsLock = new QReadWriteLock;
     m_mixerBuffer = new Workflow::Frame;
 
@@ -74,7 +73,6 @@ TrackWorkflow::~TrackWorkflow()
         it = m_clips.erase( it );
     }
     delete m_clipsLock;
-    delete m_renderOneFrameMutex;
 }
 
 void
@@ -279,18 +277,12 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
     Workflow::OutputBuffer                      *ret = NULL;
     Workflow::Frame                             *frames[EffectsEngine::MaxFramesForMixer];
     quint32                                     frameId = 0;
-    bool                                        renderOneFrame = false;
+    bool                                        renderOneFrame;
 
     if ( m_lastFrame == -1 )
         m_lastFrame = currentFrame;
-    {
-        QMutexLocker      lock2( m_renderOneFrameMutex );
-        if ( m_renderOneFrame == true )
-        {
-            m_renderOneFrame = false;
-            renderOneFrame = true;
-        }
-    }
+    renderOneFrame = m_renderOneFrame.testAndSetRelease( true, false );
+
     {
         // This is a bit hackish : when we want to pop a frame in renderOneFrame mode,
         // we also set the position to avoid the stream to be missynchronized.
@@ -518,8 +510,7 @@ TrackWorkflow::adjustClipTime( qint64 currentFrame, qint64 start, ClipWorkflow*
 void
 TrackWorkflow::renderOneFrame()
 {
-    QMutexLocker    lock( m_renderOneFrameMutex );
-    m_renderOneFrame = true;
+    m_renderOneFrame.store( true );
 }
 
 void
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 4584f32..831ca95 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -120,8 +120,7 @@ class   TrackWorkflow : public EffectUser
         */
         qint64                                  m_length;
 
-        bool                                    m_renderOneFrame;
-        QMutex                                  *m_renderOneFrameMutex;
+        QAtomicInteger<bool>                    m_renderOneFrame;
 
         QReadWriteLock*                         m_clipsLock;
 



More information about the Vlmc-devel mailing list