Commit 3a542228 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Starting dead lock removal.

Also a warning removed.
parent 4cff51a2
......@@ -113,7 +113,7 @@ void MetaDataManager::getMetaData()
m_currentClip->setLength( m_mediaPlayer->getLength() );
m_currentClip->setWidth( m_mediaPlayer->getWidth() );
m_currentClip->setHeight( m_mediaPlayer->getHeight() );
m_currentClip->setFps( m_mediaPlayer->getFps() );
m_currentClip->setFps( static_cast<unsigned int>( m_mediaPlayer->getFps() ) );
//Setting time for snapshot :
if ( m_currentClip->getFileType() == Media::Video )
......
......@@ -326,6 +326,11 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
{
cw->getStateLock()->lockForRead();
if ( cw->getState() == ClipWorkflow::Stopped )
{
cw->getStateLock()->unlock();
return ;
}
if ( cw->getState() == ClipWorkflow::Sleeping ||
cw->getState() == ClipWorkflow::Ready ||
cw->getState() == ClipWorkflow::EndReached )
......@@ -350,12 +355,13 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
}
else
{
// qDebug() << "Unexpected ClipWorkflow::State when pausing:" << cw->getState();
qDebug() << "Unexpected ClipWorkflow::State when pausing:" << cw->getState();
cw->getStateLock()->unlock();
}
bool pausing = false;
while ( pausing == false )
{
qDebug() << "Waiting for Pausing mode";
cw->getStateLock()->lockForRead();
pausing = ( cw->getState() == ClipWorkflow::Pausing );
SleepMS( 1 );
......@@ -364,7 +370,7 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
cw->pause();
}
void TrackWorkflow::pause()
void TrackWorkflow::pause()
{
QReadLocker lock( m_clipsLock );
......@@ -372,31 +378,34 @@ void TrackWorkflow::pause()
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
//FIXME: it's probably bad to iterate over every clip workflows.
while ( it != end )
qDebug() << "Starting iteration";
for ( ; it != end; ++it )
{
qDebug() << "Getting clip workflow";
ClipWorkflow* cw = it.value();
qDebug() << "Aquiering lock";
cw->getStateLock()->lockForRead();
qDebug() << "Lock aquiered";
if ( cw->getState() == ClipWorkflow::Stopped )
{
cw->getStateLock()->unlock();
continue ;
}
if ( cw->getState() != ClipWorkflow::Paused )
{
qDebug() << "Unlocking";
cw->getStateLock()->unlock();
qDebug() << "Pausing clip workflow";
pauseClipWorkflow( cw );
qDebug() << "Paused clip workflow";
}
else
{
//This should never be used.
//TODO: remove this in a few revision (wrote on July 16 2009 )
Q_ASSERT( false );
if ( cw->getState() == ClipWorkflow::Paused )
{
cw->getStateLock()->unlock();
cw->unpause();
}
else
{
cw->getStateLock()->unlock();
}
}
++it;
}
m_paused = !m_paused;
}
......
......@@ -171,6 +171,7 @@ void RenderPreviewWidget::togglePlayPause( bool forcePause )
//So be careful about pausing two times :
if ( m_paused == false )
{
qDebug() << "Pausing";
m_mediaPlayer->pause();
m_mainWorkflow->pause();
m_paused = true;
......
Supports Markdown
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