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

Correcting a dead lock when reading a non 0 beggining item

parent 64a0d705
......@@ -85,15 +85,15 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
switch ( event->type )
{
case libvlc_MediaPlayerPlaying:
// qDebug() << "Media player playing";
qDebug() << "Media player playing";
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
// qDebug() << "Media player paused";
qDebug() << "Media player paused";
self->emit paused();
break;
case libvlc_MediaPlayerStopped:
// qDebug() << "Media player stopped";
qDebug() << "Media player stopped";
self->emit stopped();
break;
case libvlc_MediaPlayerEndReached:
......
......@@ -181,6 +181,7 @@ Clip* Clip::split( qint64 endFrame )
{
Q_ASSERT( endFrame != m_end );
Clip* newClip = new Clip( this, endFrame, m_end );
qDebug() << "Created new clip. begin:" << newClip->m_begin << "end:" << newClip->m_end;
m_end = endFrame;
computeLength();
return newClip;
......
......@@ -73,17 +73,20 @@ void ClipWorkflow::checkStateChange()
void ClipWorkflow::initialize( bool preloading /*= false*/ )
{
qDebug() << "Setting state to initializing";
setState( Initializing );
m_vlcMedia = new LibVLCpp::Media( "file://" + m_clip->getParent()->getFileInfo()->absoluteFilePath() );
initVlcOutput();
m_mediaPlayer = Pool<LibVLCpp::MediaPlayer>::getInstance()->get();
m_mediaPlayer->setMedia( m_vlcMedia );
qDebug() << "Associating media to media player";
if ( preloading == true )
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( pauseAfterPlaybackStarted() ), Qt::DirectConnection );
else
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( loadingComplete() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ), Qt::DirectConnection );
qDebug() << "Starting playback";
m_mediaPlayer->play();
}
......@@ -92,6 +95,7 @@ void ClipWorkflow::pauseAfterPlaybackStarted()
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( pauseAfterPlaybackStarted() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( initializedMediaPlayer() ), Qt::DirectConnection );
qDebug() << "Media player position changed";
m_mediaPlayer->pause();
}
......@@ -110,6 +114,7 @@ void ClipWorkflow::initializedMediaPlayer()
bool ClipWorkflow::isReady() const
{
QReadLocker lock( m_stateLock );
qDebug() << "State when calling isReady:" << m_state;
return m_state == ClipWorkflow::Ready;
}
......@@ -132,15 +137,18 @@ ClipWorkflow::State ClipWorkflow::getState() const
void ClipWorkflow::startRender( bool startInPausedMode )
{
qDebug() << "Start in paused mode?:" << startInPausedMode;
if ( isReady() == false )
{
// qDebug() << "Waiting for clipworkflow to be ready";
QMutexLocker lock( m_initWaitCond->getMutex() );
qDebug() << "Waiting for init clipworkflow";
m_initWaitCond->waitLocked();
}
// qDebug() << "ClipWorkflow is ready";
if ( startInPausedMode == false )
{
qDebug() << "Starting playback again";
m_mediaPlayer->play();
// qDebug() << "Setting state: Rendering";
setState( Rendering );
......@@ -169,8 +177,7 @@ void ClipWorkflow::stop()
m_mediaPlayer->stop();
disconnect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ) );
Pool<LibVLCpp::MediaPlayer>::getInstance()->release( m_mediaPlayer );
// qDebug() << "Setting media player to NULL";
qDebug() << "Setting media player to NULL";
m_mediaPlayer = NULL;
setState( Stopped );
QMutexLocker lock( m_requiredStateLock );
......
......@@ -151,8 +151,11 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
}
else if ( cw->getState() == ClipWorkflow::Stopped )
{
qDebug() << "Unlocking state lock";
cw->getStateLock()->unlock();
qDebug() << "Initializing";
cw->initialize();
qDebug() << "Calling start render";
cw->startRender( m_paused );
if ( start != currentFrame || cw->getClip()->getBegin() != 0 ) //Clip was not started as its real begining
{
......
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