Commit f2ef00a9 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

End of a track is now handled by a signal emitted from the ClipWorkflow, in...

End of a track is now handled by a signal emitted from the ClipWorkflow, in horder to avoid hangs up
parent c4847c3f
......@@ -210,6 +210,7 @@ void ClipWorkflow::startRender( bool startInPausedMode )
void ClipWorkflow::clipEndReached()
{
setState( EndReached );
emit endReached( this );
}
Clip* ClipWorkflow::getClip()
......
......@@ -218,6 +218,7 @@ class ClipWorkflow : public QObject
void renderComplete( ClipWorkflow* );
void paused();
void unpaused();
void endReached( ClipWorkflow* );
};
#endif // CLIPWORKFLOW_H
......@@ -63,6 +63,7 @@ void TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
connect( cw, SIGNAL( renderComplete( ClipWorkflow* ) ), this, SLOT( clipWorkflowRenderCompleted( ClipWorkflow* ) ), Qt::DirectConnection );
connect( cw, SIGNAL( paused() ), this, SLOT( clipWorkflowPaused() ) );
connect( cw, SIGNAL( unpaused() ), this, SLOT( clipWorkflowUnpaused() ) );
connect( cw, SIGNAL( endReached( ClipWorkflow* ) ), this, SLOT( clipWorkflowEndReached( ClipWorkflow* ) ) );
m_clips.insert( start, cw );
computeLength();
}
......@@ -236,19 +237,10 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
{
// qDebug() << "Unexpected ClipWorkflow::State when stopping :" << cw->getState();
cw->getStateLock()->unlock();
return ;
}
}
bool TrackWorkflow::checkEnd( qint64 currentFrame ) const
{
if ( m_clips.size() == 0 )
return true;
//This is the last video by chronological order :
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
//If it ends before the current frame, we reached end.
return ( it.value()->getClip()->getLength() + it.key() < currentFrame );
}
void TrackWorkflow::stop()
{
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
......@@ -271,11 +263,6 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
bool needRepositioning;
bool hasRendered = false;
if ( checkEnd( currentFrame ) == true )
{
emit trackEndReached( m_trackId );
//We continue, as there can be ClipWorkflow that required to be stopped.
}
{
QMutexLocker lock( m_forceRepositionningMutex );
if ( m_forceRepositionning == true )
......@@ -482,3 +469,18 @@ void TrackWorkflow::clipWorkflowUnpaused()
emit trackUnpaused();
}
}
void TrackWorkflow::clipWorkflowEndReached( ClipWorkflow* cw )
{
//If this clip is the last, we emit the trackEndReached signal, and stop the
//clip workflow.
cw->stop();
//this obviously couldn't happen, since we have a clipworkflow...
Q_ASSERT ( m_clips.size() != 0 );
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
//If it ends before the current frame, we reached end.
if ( it.value() == cw )
emit trackEndReached( m_trackId );
}
......@@ -74,7 +74,6 @@ class TrackWorkflow : public QObject
qint64 start, bool needRepositioning );
void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const;
private:
unsigned int m_trackId;
......@@ -107,6 +106,7 @@ class TrackWorkflow : public QObject
void clipWorkflowPaused();
void clipWorkflowUnpaused();
void clipWorkflowRenderCompleted( ClipWorkflow* );
void clipWorkflowEndReached( ClipWorkflow* );
signals:
void trackEndReached( unsigned int );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment