[vlmc-devel] commit: TrackHandler: Watch for TrackWorkflow length changed. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Aug 26 23:03:07 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Aug 26 00:39:26 2010 +0200| [63d3f6878205a79d97106f7868f8d95487992876] | committer: Hugo Beauzée-Luyssen 

TrackHandler: Watch for TrackWorkflow length changed.

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

 src/Workflow/TrackHandler.cpp  |   21 +++++++++++++++++++++
 src/Workflow/TrackHandler.h    |    3 +++
 src/Workflow/TrackWorkflow.cpp |   16 +++++++++++++---
 src/Workflow/TrackWorkflow.h   |    3 +++
 4 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/src/Workflow/TrackHandler.cpp b/src/Workflow/TrackHandler.cpp
index 91c282b..c9d18a7 100644
--- a/src/Workflow/TrackHandler.cpp
+++ b/src/Workflow/TrackHandler.cpp
@@ -36,6 +36,8 @@ TrackHandler::TrackHandler( unsigned int nbTracks, Workflow::TrackType trackType
     for ( unsigned int i = 0; i < nbTracks; ++i )
     {
         m_tracks[i].setPtr( new TrackWorkflow( trackType ) );
+        connect( m_tracks[i], SIGNAL( lengthChanged( qint64 ) ),
+                 this, SLOT( lengthUpdated(qint64) ) );
     }
 }
 
@@ -274,3 +276,22 @@ TrackHandler::stopFrameComputing()
     for ( unsigned int i = 0; i < m_trackCount; ++i )
         m_tracks[i]->stopFrameComputing();
 }
+
+void
+TrackHandler::lengthUpdated( qint64 newLength )
+{
+    //If the new length is bigger, or if the track that has been resized was the
+    if ( newLength > m_length )
+        m_length = newLength;
+    else
+    {
+        qint64      maxLength = 0;
+
+        for ( unsigned int i = 0; i < m_trackCount; ++i )
+        {
+            if ( m_tracks[i]->getLength() > maxLength )
+                maxLength = m_tracks[i]->getLength();
+        }
+        m_length = maxLength;
+    }
+}
diff --git a/src/Workflow/TrackHandler.h b/src/Workflow/TrackHandler.h
index dbc87ea..29132f2 100644
--- a/src/Workflow/TrackHandler.h
+++ b/src/Workflow/TrackHandler.h
@@ -115,6 +115,9 @@ class   TrackHandler : public QObject
         unsigned int                    m_highestTrackNumber;
         bool                            m_endReached;
 
+    private slots:
+        void                            lengthUpdated( qint64 newLength );
+
     signals:
         void                            tracksEndReached();
 };
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 2192b26..189b214 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -110,13 +110,23 @@ TrackWorkflow::addEffect( Effect *effect, const QUuid &uuid )
 void
 TrackWorkflow::computeLength()
 {
+    bool    changed = false;
     if ( m_clips.count() == 0 )
     {
+        if ( m_length != 0 )
+            changed = true;
         m_length = 0;
-        return ;
     }
-    QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
-    m_length = (it.key() + it.value()->getClipHelper()->length() );
+    else
+    {
+        QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
+        qint64  newLength = it.key() + it.value()->getClipHelper()->length();
+        if ( m_length != newLength )
+            changed = true;
+        m_length = newLength;
+    }
+    if ( changed == true )
+        emit lengthChanged( m_length );
 }
 
 qint64
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 07bd7b2..ff02d29 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -121,6 +121,9 @@ class   TrackWorkflow : public QObject
         qint64                                  m_lastFrame;
         Workflow::Frame                         *m_mixerBuffer;
         double                                  m_fps;
+
+    signals:
+        void                                    lengthChanged( qint64 newLength );
 };
 
 #endif // TRACKWORKFLOW_H



More information about the Vlmc-devel mailing list