Commit 27b832c3 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Merge branch 'chouquette_debug_pause'

Conflicts:
	src/Workflow/ClipWorkflow.cpp
	src/Workflow/MainWorkflow.cpp
	src/Workflow/TrackWorkflow.cpp
	src/renderer/WorkflowRenderer.cpp
parents c277adec 3084c18a
...@@ -173,7 +173,7 @@ void MediaPlayer::takeSnapshot( const char* outputFil ...@@ -173,7 +173,7 @@ void MediaPlayer::takeSnapshot( const char* outputFil
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
} }
bool MediaPlayer::isPlaying() bool MediaPlayer::isPlaying()
{ {
int res = libvlc_media_player_is_playing( m_internalPtr, m_ex ); int res = libvlc_media_player_is_playing( m_internalPtr, m_ex );
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
......
...@@ -110,11 +110,12 @@ void ClipWorkflow::unlock( ClipWorkflow* cw ) ...@@ -110,11 +110,12 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
{ {
cw->m_state = Sleeping; cw->m_state = Sleeping;
cw->m_stateLock->unlock(); cw->m_stateLock->unlock();
//Signal that render has been completed.
cw->m_renderWaitCond->wake(); cw->m_renderWaitCond->wake();
// qDebug() << "Entering condwait"; // qDebug() << "Entering condwait";
cw->m_waitCond->wait(); cw->m_waitCond->wait( cw->m_condMutex );
// qDebug() << "Leaved condwait"; // qDebug() << "Leaved condwait";
cw->m_stateLock->lockForWrite(); cw->m_stateLock->lockForWrite();
cw->m_state = Rendering; cw->m_state = Rendering;
// { // {
...@@ -125,7 +126,6 @@ void ClipWorkflow::unlock( ClipWorkflow* cw ) ...@@ -125,7 +126,6 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
} }
else if ( cw->m_state == Paused ) else if ( cw->m_state == Paused )
{ {
// qDebug() << "Forcing pause by pausing thread";
cw->m_stateLock->unlock(); cw->m_stateLock->unlock();
cw->m_waitCond->wait(); cw->m_waitCond->wait();
} }
...@@ -287,13 +287,14 @@ void ClipWorkflow::setState( State state ) ...@@ -287,13 +287,14 @@ void ClipWorkflow::setState( State state )
void ClipWorkflow::queryStateChange( State newState ) void ClipWorkflow::queryStateChange( State newState )
{ {
// qDebug() << "Querying state change to" << newState;
QMutexLocker lock( m_requiredStateLock ); QMutexLocker lock( m_requiredStateLock );
m_requiredState = newState; m_requiredState = newState;
} }
void ClipWorkflow::wake() void ClipWorkflow::wake()
{ {
m_waitCond->wake(); m_waitCond->wakeAll();
} }
QReadWriteLock* ClipWorkflow::getStateLock() QReadWriteLock* ClipWorkflow::getStateLock()
......
...@@ -122,6 +122,8 @@ unsigned char* MainWorkflow::getOutput() ...@@ -122,6 +122,8 @@ unsigned char* MainWorkflow::getOutput()
void MainWorkflow::pause() void MainWorkflow::pause()
{ {
QMutexLocker lock( m_renderMutex );
for ( unsigned int i = 0; i < m_trackCount; ++i ) for ( unsigned int i = 0; i < m_trackCount; ++i )
{ {
if ( m_tracks[i].activated() == true ) if ( m_tracks[i].activated() == true )
......
...@@ -202,15 +202,11 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw ) ...@@ -202,15 +202,11 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
} }
else if ( cw->getState() == ClipWorkflow::Rendering ) else if ( cw->getState() == ClipWorkflow::Rendering )
{ {
qDebug() << "Stopping while rendering";
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
qDebug() << "Waiting complete render";
cw->waitForCompleteRender(); cw->waitForCompleteRender();
qDebug() << "Waited ok.";
cw->queryStateChange( ClipWorkflow::Stopping ); cw->queryStateChange( ClipWorkflow::Stopping );
cw->wake(); cw->wake();
cw->stop(); cw->stop();
qDebug() << "Stopped clip workflow";
} }
else if ( cw->getState() == ClipWorkflow::Initializing ) else if ( cw->getState() == ClipWorkflow::Initializing )
{ {
...@@ -265,14 +261,8 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame ) ...@@ -265,14 +261,8 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
bool needRepositioning; bool needRepositioning;
bool oneFrameOnlyFlag = false; bool oneFrameOnlyFlag = false;
// qDebug() << "Checking flag...";
if ( m_oneFrameOnly == 1 ) if ( m_oneFrameOnly == 1 )
{
// qDebug() << "...Flag is activated";
oneFrameOnlyFlag = true; oneFrameOnlyFlag = true;
}
// else
// qDebug() << "...Flag is OFF";
if ( checkEnd( currentFrame ) == true ) if ( checkEnd( currentFrame ) == true )
{ {
emit trackEndReached( m_trackId ); emit trackEndReached( m_trackId );
...@@ -341,14 +331,15 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw ) ...@@ -341,14 +331,15 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
cw->getState() == ClipWorkflow::Ready || cw->getState() == ClipWorkflow::Ready ||
cw->getState() == ClipWorkflow::EndReached ) cw->getState() == ClipWorkflow::EndReached )
{ {
cw->getStateLock()->unlock();
cw->queryStateChange( ClipWorkflow::Pausing ); cw->queryStateChange( ClipWorkflow::Pausing );
cw->getStateLock()->unlock();
cw->wake(); cw->wake();
} }
else if ( cw->getState() == ClipWorkflow::Rendering ) else if ( cw->getState() == ClipWorkflow::Rendering )
{ {
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
cw->waitForCompleteRender(); cw->waitForCompleteRender();
QMutexLocker lock( cw->getSleepMutex() );
cw->queryStateChange( ClipWorkflow::Pausing ); cw->queryStateChange( ClipWorkflow::Pausing );
cw->wake(); cw->wake();
} }
...@@ -359,7 +350,6 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw ) ...@@ -359,7 +350,6 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
} }
else else
{ {
qDebug() << "Unexpected ClipWorkflow::State when pausing:" << cw->getState();
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
} }
cw->waitForPausingState(); cw->waitForPausingState();
...@@ -393,7 +383,7 @@ void TrackWorkflow::pause() ...@@ -393,7 +383,7 @@ void TrackWorkflow::pause()
{ {
//This should never be used. //This should never be used.
//TODO: remove this in a few revision (wrote on July 16 2009 ) //TODO: remove this in a few revision (wrote on July 16 2009 )
Q_ASSERT( false ); qDebug() << "Asking to pause in an already paused state";
} }
} }
m_paused = !m_paused; m_paused = !m_paused;
......
...@@ -83,9 +83,11 @@ void* WorkflowRenderer::lock( void* datas ) ...@@ -83,9 +83,11 @@ void* WorkflowRenderer::lock( void* datas )
{ {
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas ); WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
//If we're not playing, then where in a paused media player.
if ( self->m_mediaPlayer->isPlaying() == false )
return self->m_lastFrame;
if ( self->m_oneFrameOnly < 2 ) if ( self->m_oneFrameOnly < 2 )
{ {
// qDebug() << "\nQuerying new picture";
void* ret = self->m_mainWorkflow->getOutput(); void* ret = self->m_mainWorkflow->getOutput();
self->m_lastFrame = static_cast<unsigned char*>( ret ); self->m_lastFrame = static_cast<unsigned char*>( ret );
return ret; return ret;
...@@ -151,6 +153,12 @@ void WorkflowRenderer::previousFrame() ...@@ -151,6 +153,12 @@ void WorkflowRenderer::previousFrame()
} }
void WorkflowRenderer::pauseMainWorkflow()
{
m_mainWorkflow->pause();
m_paused = true;
}
void WorkflowRenderer::togglePlayPause( bool forcePause ) void WorkflowRenderer::togglePlayPause( bool forcePause )
{ {
//If force pause is true, we just ensure that this render is paused... no need to start it. //If force pause is true, we just ensure that this render is paused... no need to start it.
......
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