[vlmc-devel] commit: File rendering: Fixed synchronisation bug. (Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Sat Mar 13 16:41:49 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Sat Mar 13 16:40:44 2010 +0100| [e254c50f731471f6379b44dc5ffee71229b1b251] | committer: Hugo Beauzee-Luyssen 

File rendering: Fixed synchronisation bug.

The buffer are now preload a bit before rendering.

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

 src/Renderer/WorkflowFileRenderer.cpp |   10 ++++++----
 src/Workflow/TrackHandler.cpp         |    3 +++
 src/Workflow/TrackWorkflow.cpp        |   17 +++++++++++++++++
 src/Workflow/TrackWorkflow.h          |    2 ++
 4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/Renderer/WorkflowFileRenderer.cpp b/src/Renderer/WorkflowFileRenderer.cpp
index 3b8bbdf..100d230 100644
--- a/src/Renderer/WorkflowFileRenderer.cpp
+++ b/src/Renderer/WorkflowFileRenderer.cpp
@@ -90,6 +90,8 @@ void        WorkflowFileRenderer::run()
 
     m_mainWorkflow->setFullSpeedRender( true );
     m_mainWorkflow->startRender( width, height );
+    //Waiting for renderers to preload some frames:
+    sleep( 1 );
     m_mediaPlayer->play();
 }
 
@@ -133,25 +135,25 @@ WorkflowFileRenderer::lock( void *datas, qint64 *dts, qint64 *pts, quint32 *flag
     return ret;
 }
 
-void        
+void
 WorkflowFileRenderer::unlock( void *datas, size_t size, void* buff )
 {
     WorkflowRenderer::unlock( datas, size, buff );
 }
 
-void        
+void
 WorkflowFileRenderer::__frameChanged( qint64 frame, MainWorkflow::FrameChangedReason )
 {
     m_dialog->setProgressBarValue( frame * 100 / m_mainWorkflow->getLengthFrame() );
 }
 
-void*       
+void*
 WorkflowFileRenderer::getLockCallback()
 {
     return (void*)&WorkflowFileRenderer::lock;
 }
 
-void*       
+void*
 WorkflowFileRenderer::getUnlockCallback()
 {
     return (void*)&WorkflowFileRenderer::unlock;
diff --git a/src/Workflow/TrackHandler.cpp b/src/Workflow/TrackHandler.cpp
index 4cbc789..d2d81f8 100644
--- a/src/Workflow/TrackHandler.cpp
+++ b/src/Workflow/TrackHandler.cpp
@@ -87,7 +87,10 @@ TrackHandler::startRender()
     else
     {
         for ( unsigned int i = 0; i < m_trackCount; ++i )
+        {
             activateTrack( i );
+            m_tracks[i]->preload();
+        }
     }
 }
 
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index f987b80..8b75d15 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -487,3 +487,20 @@ TrackWorkflow::unmuteClip( const QUuid &uuid )
     qWarning() << "Failed to unmute clip" << uuid << "it probably doesn't exist "
             "in this track";
 }
+
+void
+TrackWorkflow::preload()
+{
+    QReadLocker     lock( m_clipsLock );
+
+    QMap<qint64, ClipWorkflow*>::iterator       it = m_clips.begin();
+    QMap<qint64, ClipWorkflow*>::iterator       end = m_clips.end();
+    while ( it != end )
+    {
+        qint64          start = it.key();
+        ClipWorkflow*   cw = it.value();
+        if ( start < TrackWorkflow::nbFrameBeforePreload )
+            preloadClip( cw );
+        ++it;
+    }
+}
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 3068fd4..3482b14 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -87,6 +87,8 @@ class   TrackWorkflow : public QObject
         void                                    muteClip( const QUuid& uuid );
         void                                    unmuteClip( const QUuid& uuid );
 
+        void                                    preload();
+
     private:
         void                                    computeLength();
         void*                                   renderClip( ClipWorkflow* cw, qint64 currentFrame,



More information about the Vlmc-devel mailing list