Commit 71d21aa9 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Revert "Solved hang up when end of last track is reached"

This reverts commit 56a33199.

Conflicts:

	src/Workflow/MainWorkflow.cpp
	src/Workflow/TrackWorkflow.cpp
parent a1fd8876
......@@ -32,7 +32,7 @@ Instance::Instance()
{
char const *argv[] =
{
// "-vvvvv",
"-vvvvv",
"--no-skip-frames",
// "--intf", "dummy",
//"--no-audio",
......
......@@ -44,7 +44,6 @@ MainWorkflow::MainWorkflow( int trackCount ) :
for ( int i = 0; i < trackCount; ++i )
{
m_tracks[i].setPtr( new TrackWorkflow( i ) );
m_tracks[i].deactivate();
connect( m_tracks[i], SIGNAL( trackEndReached( unsigned int ) ), this, SLOT( trackEndReached(unsigned int) ) );
connect( m_tracks[i], SIGNAL( trackPaused() ), this, SLOT( trackPaused() ) );
connect( m_tracks[i], SIGNAL( trackUnpaused() ), this, SLOT( trackUnpaused() ) );
......@@ -77,9 +76,10 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
Q_ASSERT_X( trackId < m_trackCount, "MainWorkflow::addClip",
"The specified trackId isn't valid, for it's higher than the number of tracks");
m_tracks[trackId]->addClip( clip, start );
//if the track is deactivated, we need to reactivate it :
activateTrack( trackId );
if ( m_tracks[trackId].deactivated() == true )
m_tracks[trackId].activate();
m_tracks[trackId]->addClip( clip, start );
if ( m_tracks[trackId]->getLength() > m_length )
m_length = m_tracks[trackId]->getLength();
}
......@@ -103,9 +103,7 @@ void MainWorkflow::startRender()
m_currentFrame = 0;
emit frameChanged( 0 );
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
activateTrack( i );
}
m_tracks[i].activate();
computeLength();
}
......@@ -186,7 +184,7 @@ void MainWorkflow::setPosition( float pos )
//Since any track can be reactivated, we reactivate all of them, and let them
//unable themself if required.
for ( unsigned int i = 0; i < m_trackCount; ++i)
activateTrack( i );
m_tracks[i].activate();
qint64 frame = static_cast<qint64>( (float)m_length * pos );
m_currentFrame = frame;
......@@ -265,14 +263,14 @@ void MainWorkflow::moveClip( const QUuid& clipUuid, unsigned int oldTr
{
//And now, just move the clip.
m_tracks[newTrack]->moveClip( clipUuid, startingFrame );
activateTrack( newTrack );
m_tracks[newTrack].activate();
}
else
{
Clip* clip = m_tracks[oldTrack]->removeClip( clipUuid );
m_tracks[newTrack]->addClip( clip, startingFrame );
activateTrack( oldTrack );
activateTrack( newTrack );
m_tracks[oldTrack].activate();
m_tracks[newTrack].activate();
}
computeLength();
if ( undoRedoCommand == true )
......@@ -372,10 +370,3 @@ void MainWorkflow::setCurrentFrame( qint64 currentFrame )
emit positionChanged( (float)m_currentFrame / (float)m_length );
}
void MainWorkflow::activateTrack( unsigned int trackId )
{
if ( m_tracks[trackId]->getLength() > 0 )
m_tracks[trackId].activate();
else
m_tracks[trackId].deactivate();
}
......@@ -104,7 +104,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
private:
void computeLength();
void activateTrack( unsigned int trackId );
private:
Toggleable<TrackWorkflow*>* m_tracks;
......
......@@ -191,7 +191,7 @@ void TrackWorkflow::preloadClip( ClipWorkflow* cw )
cw->getStateLock()->unlock();
}
void TrackWorkflow::stopClipWorkflow( CW& cw )
void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
{
cw->getStateLock()->lockForRead();
......@@ -239,7 +239,6 @@ void TrackWorkflow::stopClipWorkflow( CW& cw )
cw->getStateLock()->unlock();
return ;
}
cw.activate();
}
void TrackWorkflow::stop()
......@@ -278,7 +277,7 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
}
m_nbClipToRender = 0;
for (; it != end; ++it )
while ( it != end )
{
qint64 start = it.key();
ClipWorkflow* cw = it.value();
......@@ -290,8 +289,6 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
}
if ( start <= currentFrame && currentFrame <= start + cw->getClip()->getLength() )
{
if ( it.value().activated() == false )
continue ;
m_nbClipToRender.fetchAndAddAcquire( 1 );
renderClip( cw, currentFrame, start, needRepositioning );
lastFrame = currentFrame;
......@@ -306,8 +303,10 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
//Is it supposed to be stopped ?
else
{
stopClipWorkflow( it.value() );
stopClipWorkflow( cw );
}
++it;
}
if ( hasRendered == false )
{
......@@ -478,29 +477,16 @@ void TrackWorkflow::clipWorkflowUnpaused()
void TrackWorkflow::clipWorkflowEndReached( ClipWorkflow* cw )
{
QMap<qint64, CW>::iterator it = m_clips.begin();
QMap<qint64, CW>::iterator end = m_clips.end();
while ( it != end )
{
if ( it.value() == cw )
break ;
}
Q_ASSERT( it != end );
qDebug() << "Deactivating clip";
clipWorkflowRenderCompleted( cw );
stopClipWorkflow( it.value() );
qDebug() << "Stopped clip workflow";
it.value().deactivate();
//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 );
Q_ASSERT ( m_clips.size() != 0 );
QMap<qint64, CW>::const_iterator last = m_clips.end() - 1;
//If this was the last clip, we reached end.
if ( last.value() == cw )
QMap<qint64, CW>::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 );
//Else: simulating that the clip render is complete, because the TrackWorkflow
//waits for this clip to render.
......
......@@ -75,7 +75,7 @@ class TrackWorkflow : public QObject
void renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start, bool needRepositioning );
void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( CW& cw );
void stopClipWorkflow( ClipWorkflow* cw );
private:
unsigned int m_trackId;
......
Markdown is supported
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