Commit 3fcab3d0 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

End of track is correctly handled...

... and render is stopped when there is nothing more to do
parent a3e0715c
...@@ -52,15 +52,15 @@ void TrackWorkflow::startRender() ...@@ -52,15 +52,15 @@ void TrackWorkflow::startRender()
//If the first frame is to be render soon, we should play it now. //If the first frame is to be render soon, we should play it now.
if ( m_clips.begin().key() < TrackWorkflow::nbFrameBeforePreload ) if ( m_clips.begin().key() < TrackWorkflow::nbFrameBeforePreload )
{ {
qDebug() << "Next clip is less than" << nbFrameBeforePreload<< "frame ahead"; // qDebug() << "Next clip is less than" << nbFrameBeforePreload<< "frame ahead";
m_clips.begin().value()->initialize( m_mediaPlayer ); m_clips.begin().value()->initialize( m_mediaPlayer );
qDebug() << "Waiting for the first clip to be ready"; // qDebug() << "Waiting for the first clip to be ready";
while ( m_clips.begin().value()->isReady() == false ) while ( m_clips.begin().value()->isReady() == false )
usleep( 150 ); usleep( 150 );
if ( m_current.key() == 0 ) if ( m_current.key() == 0 )
{ {
m_current = m_clips.begin(); m_current = m_clips.begin();
qDebug() << "Clip workflow is at first frame"; // qDebug() << "Clip workflow is at first frame";
m_current.value()->startRender(); m_current.value()->startRender();
m_isRendering = true; m_isRendering = true;
} }
...@@ -74,12 +74,10 @@ bool TrackWorkflow::checkNextClip() ...@@ -74,12 +74,10 @@ bool TrackWorkflow::checkNextClip()
//Picking next clip : //Picking next clip :
if ( m_current == m_clips.end() ) if ( m_current == m_clips.end() )
{ {
// qDebug() << "Using first clip";
next = m_clips.begin(); next = m_clips.begin();
} }
else else
{ {
// qDebug() << "Using next clip";
next = m_clips.begin() + 1; next = m_clips.begin() + 1;
if ( next == m_clips.end() ) if ( next == m_clips.end() )
return false; return false;
...@@ -88,14 +86,14 @@ bool TrackWorkflow::checkNextClip() ...@@ -88,14 +86,14 @@ bool TrackWorkflow::checkNextClip()
//If it's about to be used, initialize it //If it's about to be used, initialize it
if ( next.key() == m_currentFrame + TrackWorkflow::nbFrameBeforePreload ) if ( next.key() == m_currentFrame + TrackWorkflow::nbFrameBeforePreload )
{ {
qDebug() << "Initializing next clipWorkflow"; // qDebug() << "Initializing next clipWorkflow";
next.value()->initialize( m_mediaPlayer ); next.value()->initialize( m_mediaPlayer );
} }
else if ( next.key() == m_currentFrame ) else if ( next.key() == m_currentFrame )
{ {
//It should have been initialized now, however, this ain't very safe :/ //It should have been initialized now, however, this ain't very safe :/
Q_ASSERT( next.value()->isReady() ); Q_ASSERT( next.value()->isReady() );
qDebug() << "Switching current clip workflow"; // qDebug() << "Switching current clip workflow";
//Using it as the current clip from now on. //Using it as the current clip from now on.
m_current = next; m_current = next;
m_current.value()->startRender(); m_current.value()->startRender();
...@@ -106,10 +104,10 @@ bool TrackWorkflow::checkNextClip() ...@@ -106,10 +104,10 @@ bool TrackWorkflow::checkNextClip()
unsigned char* TrackWorkflow::getOutput() unsigned char* TrackWorkflow::getOutput()
{ {
unsigned char* ret = TrackWorkflow::blackOutput; unsigned char* ret = TrackWorkflow::blackOutput;
bool lastClip; bool clipsRemaining;
// qDebug() << "Frame nb" << m_currentFrame; // qDebug() << "Frame nb" << m_currentFrame;
lastClip = checkNextClip(); clipsRemaining = checkNextClip();
if ( m_current == m_clips.end() ) if ( m_current == m_clips.end() )
{ {
// qDebug() << "Stil no clip at this time, going to the next frame"; // qDebug() << "Stil no clip at this time, going to the next frame";
...@@ -124,9 +122,9 @@ unsigned char* TrackWorkflow::getOutput() ...@@ -124,9 +122,9 @@ unsigned char* TrackWorkflow::getOutput()
ret = m_current.value()->getOutput(); ret = m_current.value()->getOutput();
else else
{ {
if ( lastClip == true) if ( clipsRemaining == false )
{ {
qDebug() << "End of track"; // qDebug() << "End of track";
return NULL; return NULL;
} }
} }
......
...@@ -55,6 +55,7 @@ class TrackWorkflow : public QObject ...@@ -55,6 +55,7 @@ class TrackWorkflow : public QObject
private: private:
QMap<qint64, ClipWorkflow*> m_clips; QMap<qint64, ClipWorkflow*> m_clips;
QMap<qint64, ClipWorkflow*>::iterator m_current; QMap<qint64, ClipWorkflow*>::iterator m_current;
//TODO: this MUST be in the MainWorkflow, and passed as a parameter to the getOutput method.
qint64 m_currentFrame; qint64 m_currentFrame;
QMutex* m_condMutex; QMutex* m_condMutex;
QWaitCondition* m_waitCondition; QWaitCondition* m_waitCondition;
......
...@@ -61,7 +61,11 @@ void* RenderPreviewWidget::lock( void* datas ) ...@@ -61,7 +61,11 @@ void* RenderPreviewWidget::lock( void* datas )
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas); RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas);
void* ret = self->m_mainWorkflow->getOutput(); void* ret = self->m_mainWorkflow->getOutput();
if ( ret == NULL ) if ( ret == NULL )
{
//maybe we should display a black screen here to really emphasize
//the end of the render
self->m_mediaPlayer->stop(); self->m_mediaPlayer->stop();
}
return ret; return ret;
} }
......
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