Commit 5dd47b69 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

TracksHandler: Simplifying and fixing the track end detection.

parent eeb5145f
......@@ -29,7 +29,6 @@
TrackHandler::TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType trackType ) :
m_trackCount( nbTracks ),
m_nbRenderingTracks( 0 ),
m_trackType( trackType ),
m_length( 0 )
{
......@@ -37,7 +36,6 @@ TrackHandler::TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType track
for ( unsigned int i = 0; i < nbTracks; ++i )
{
m_tracks[i].setPtr( new TrackWorkflow( trackType ) );
connect( m_tracks[i], SIGNAL( trackEndReached() ), this, SLOT( trackEndReached() ), Qt::DirectConnection );
}
}
......@@ -78,7 +76,6 @@ TrackHandler::startRender()
{
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
m_nbRenderingTracks.fetchAndAddAcquire( 1 );
m_tracks[i]->preload();
}
}
......@@ -106,10 +103,13 @@ TrackHandler::getLength() const
void*
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{
bool validTrack = false;
for ( int i = m_trackCount - 1; i >= 0; --i )
{
if ( m_tracks[i].activated() == false || m_tracks[i]->hasFrameToRender( currentFrame ) )
continue ;
validTrack = true;
if ( m_trackType == MainWorkflow::VideoTrack )
{
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
......@@ -132,6 +132,8 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
return stackedBuffer->get();
}
}
if ( validTrack == false )
allTracksEnded();
return NULL;
}
......@@ -216,11 +218,8 @@ TrackHandler::endIsReached() const
}
void
TrackHandler::trackEndReached()
TrackHandler::allTracksEnded()
{
qDebug() << "deactivated track. remaining:" << m_nbRenderingTracks - 1;
if ( m_nbRenderingTracks.fetchAndAddAcquire( -1 ) != 1 )
return ;
m_endReached = true;
emit tracksEndReached();
}
......
......@@ -105,20 +105,16 @@ class TrackHandler : public QObject
private:
void computeLength();
void allTracksEnded();
private:
Toggleable<TrackWorkflow*>* m_tracks;
unsigned int m_trackCount;
QAtomicInt m_nbRenderingTracks;
MainWorkflow::TrackType m_trackType;
qint64 m_length;
unsigned int m_highestTrackNumber;
bool m_endReached;
private slots:
void trackEndReached();
signals:
void tracksEndReached();
};
......
......@@ -293,11 +293,6 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
if ( m_lastFrame == -1 )
m_lastFrame = currentFrame;
if ( hasFrameToRender( currentFrame ) == true )
{
emit trackEndReached();
//We continue, as there can be ClipWorkflow that requires to be stopped.
}
{
QMutexLocker lock2( m_renderOneFrameMutex );
if ( m_renderOneFrame == true )
......@@ -388,8 +383,6 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
computeLength();
cw->disconnect();
delete cw;
if ( m_length == 0 )
emit trackEndReached();
return clip;
}
++it;
......
......@@ -119,9 +119,6 @@ class TrackWorkflow : public QObject
qint64 m_lastFrame;
StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer;
StackedBuffer<Workflow::AudioSample*>* m_audioStackedBuffer;
signals:
void trackEndReached();
};
#endif // TRACKWORKFLOW_H
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