Commit 655474c3 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Now the end of a track is correctly handled

parent 984ca291
......@@ -116,8 +116,6 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
cw->m_usingBackBuffer = !cw->m_usingBackBuffer;
}
}
else
qDebug() << cw->m_state;
cw->m_stateLock->unlock();
cw->checkStateChange();
}
......
......@@ -112,6 +112,11 @@ unsigned char* TrackWorkflow::renderClip( ClipWorkflow* cw, bool needReposi
cw->getStateLock()->unlock();
cw->startRender();
}
else if ( cw->getState() == ClipWorkflow::EndReached )
{
cw->getStateLock()->unlock();
//The stopClipWorkflow() method will take care of that.
}
else
{
// qDebug() << "Unexpected ClipWorkflow::State when rendering:" << cw->getState();
......@@ -174,6 +179,16 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
}
}
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 );
}
unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
{
unsigned char* ret = TrackWorkflow::blackOutput;
......@@ -182,6 +197,11 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
static qint64 lastFrame = 0;
bool needRepositioning;
if ( checkEnd( currentFrame ) == true )
{
emit trackEndReached();
//We continue, as there can be ClipWorkflow that required to be stopped.
}
needRepositioning = ( abs( currentFrame - lastFrame ) > 1 ) ? true : false;
while ( it != end )
{
......
......@@ -58,6 +58,7 @@ class TrackWorkflow : public QObject
unsigned char* renderClip( ClipWorkflow* cw, bool needRepositioning, float pos );
void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const;
private:
QMap<qint64, ClipWorkflow*> m_clips;
......
......@@ -79,7 +79,6 @@ void RenderPreviewWidget::stopPreview()
//This might be called multiple times, but this is due to Qt message loop
m_mediaPlayer->stop();
m_isRendering = false;
qDebug() << "Stopped";
}
void RenderPreviewWidget::startPreview( Media* )
......
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