[vlmc-devel] Workflow: Rework error notifications

Hugo Beauzée-Luyssen git at videolan.org
Sun Feb 16 23:12:20 CET 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Feb 16 23:44:33 2014 +0200| [f3e597ee7d3aede6fe4165f9f43780a7bcf98855] | committer: Hugo Beauzée-Luyssen

Workflow: Rework error notifications

ClipWorkflow won't stop itself but will signal TrackWorkflow instead.

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

 src/Workflow/ClipHelper.h      |    3 ---
 src/Workflow/ClipWorkflow.cpp  |    7 +++----
 src/Workflow/ClipWorkflow.h    |    2 +-
 src/Workflow/TrackWorkflow.cpp |   11 ++++++++++-
 src/Workflow/TrackWorkflow.h   |    1 +
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/Workflow/ClipHelper.h b/src/Workflow/ClipHelper.h
index f12fabf..fe74f6a 100644
--- a/src/Workflow/ClipHelper.h
+++ b/src/Workflow/ClipHelper.h
@@ -59,9 +59,6 @@ class   ClipHelper : public Workflow::Helper
 
     private slots:
         void        clipDestroyed();
-
-    signals:
-        void        error();
 };
 
 #endif // CLIPHELPER_H
diff --git a/src/Workflow/ClipWorkflow.cpp b/src/Workflow/ClipWorkflow.cpp
index 4973e53..64f1b7c 100644
--- a/src/Workflow/ClipWorkflow.cpp
+++ b/src/Workflow/ClipWorkflow.cpp
@@ -39,7 +39,6 @@ ClipWorkflow::ClipWorkflow( ClipHelper* ch ) :
                 m_clipHelper( ch ),
                 m_state( ClipWorkflow::Stopped )
 {
-    connect( this, SIGNAL( error() ), ch, SIGNAL( error() ) );
     m_stateLock = new QReadWriteLock;
     m_initWaitCond = new QWaitCondition;
     m_renderLock = new QMutex;
@@ -139,7 +138,8 @@ ClipWorkflow::stopRenderer()
         MemoryPool<LibVLCpp::MediaPlayer>::getInstance()->release( m_mediaPlayer );
         m_mediaPlayer = NULL;
         delete m_vlcMedia;
-        m_state = Stopped;
+        if ( m_state != Error )
+            m_state = Stopped;
         flushComputedBuffers();
 
         m_initWaitCond->wakeAll();
@@ -286,9 +286,8 @@ ClipWorkflow::isResyncRequired()
 void
 ClipWorkflow::errorEncountered()
 {
-    stopRenderer();
     m_state = Error;
-    emit error();
+    emit error( this );
 }
 
 bool
diff --git a/src/Workflow/ClipWorkflow.h b/src/Workflow/ClipWorkflow.h
index 66d957e..3608e13 100644
--- a/src/Workflow/ClipWorkflow.h
+++ b/src/Workflow/ClipWorkflow.h
@@ -274,7 +274,7 @@ class   ClipWorkflow : public EffectUser
         void                    errorEncountered();
 
     signals:
-        void                    error();
+        void                    error( ClipWorkflow* );
 };
 
 #endif // CLIPWORKFLOW_H
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 4b69932..5bc9bf7 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -102,6 +102,9 @@ TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
              this, SLOT( __effectMoved( EffectHelper*, qint64) ) );
     connect( cw, SIGNAL( effectRemoved( QUuid ) ),
              this, SLOT( __effectRemoved( QUuid ) ) );
+    // For errors, we don't want this to be called directly from a VLC thread, so we queue it.
+    connect( cw, SIGNAL( error( ClipWorkflow* ) ),
+             this, SLOT( clipWorkflowFailure( ClipWorkflow* ) ), Qt::QueuedConnection );
     connect( cw->getClipHelper(), SIGNAL( destroyed( QUuid ) ),
              this, SLOT( clipDestroyed( QUuid ) ) );
     emit clipAdded( this, cw->getClipHelper(), start );
@@ -205,7 +208,8 @@ TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
     else if ( state == ClipWorkflow::EndReached ||
               state == ClipWorkflow::Error )
     {
-        //The stopClipWorkflow() method will take care of that.
+        //The stopClipWorkflow() method will take care of EndReached state.
+        // When a ClipWorkflow is in error state, we don't want to do anything
     }
     else
     {
@@ -406,6 +410,11 @@ TrackWorkflow::clipDestroyed( const QUuid& id )
     }
 }
 
+void TrackWorkflow::clipWorkflowFailure(ClipWorkflow *cw)
+{
+    cw->stop();
+}
+
 Clip*
 TrackWorkflow::removeClip( const QUuid& id )
 {
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index d3b148a..aa15135 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -137,6 +137,7 @@ class   TrackWorkflow : public EffectUser
         void                __effectRemoved( const QUuid& );
         void                __effectMoved( EffectHelper*, qint64 );
         void                clipDestroyed( const QUuid &uuid );
+        void                clipWorkflowFailure( ClipWorkflow* cw );
 
     signals:
         void                lengthChanged( qint64 newLength );



More information about the Vlmc-devel mailing list