Commit a3e0715c authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

"Normal" end of a Clip is now correctly handled

This way, the TrackWorkflow can return a black output when nothing has
to be rendered
parent cd84faf1
......@@ -125,6 +125,7 @@ void ClipWorkflow::initialize( LibVLCpp::MediaPlayer* mediaPlayer )
m_mediaPlayer->setMedia( m_clip->getParent()->getVLCMedia() );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( setPosition() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( endReached() ), Qt::DirectConnection );
qDebug() << "Launching playback";
m_mediaPlayer->play();
}
......@@ -173,3 +174,9 @@ void ClipWorkflow::startRender()
m_mediaPlayer->play();
}
void ClipWorkflow::endReached()
{
QWriteLocker lock2( m_endReachedLock );
m_endReached = true;
}
......@@ -75,6 +75,7 @@ class ClipWorkflow : public QObject
void pauseAfterPlaybackStarted();
void pausedMediaPlayer();
void setPosition();
void endReached();
};
#endif // CLIPWORKFLOW_H
......@@ -67,7 +67,7 @@ void TrackWorkflow::startRender()
}
}
void TrackWorkflow::checkNextClip()
bool TrackWorkflow::checkNextClip()
{
QMap<qint64, ClipWorkflow*>::iterator next;
......@@ -81,6 +81,8 @@ void TrackWorkflow::checkNextClip()
{
// qDebug() << "Using next clip";
next = m_clips.begin() + 1;
if ( next == m_clips.end() )
return false;
}
//If it's about to be used, initialize it
......@@ -98,15 +100,16 @@ void TrackWorkflow::checkNextClip()
m_current = next;
m_current.value()->startRender();
}
return true;
}
unsigned char* TrackWorkflow::getOutput()
{
unsigned char* ret = TrackWorkflow::blackOutput;
bool lastClip;
qDebug() << "Frame nb" << m_currentFrame;
checkNextClip();
// qDebug() << "Frame nb" << m_currentFrame;
lastClip = checkNextClip();
if ( m_current == m_clips.end() )
{
// qDebug() << "Stil no clip at this time, going to the next frame";
......@@ -114,11 +117,19 @@ unsigned char* TrackWorkflow::getOutput()
return ret;
}
m_waitCondition->wakeAll();
qDebug() << "All waked";
// qDebug() << "All waked";
while ( m_current.value()->renderComplete() == false )
usleep( 20 );
if ( m_current.value()->isEndReached() == false )
ret = m_current.value()->getOutput();
else
{
if ( lastClip == true)
{
qDebug() << "End of track";
return NULL;
}
}
++m_currentFrame;
return ret;
}
......@@ -47,7 +47,10 @@ class TrackWorkflow : public QObject
static unsigned char* blackOutput;
private:
void checkNextClip();
/**
* \return true if at least one video remains, false otherwise (IE end of this track)
*/
bool checkNextClip();
private:
QMap<qint64, ClipWorkflow*> m_clips;
......
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