Commit 8ee8758c authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Revert "Removed debug" so that debug can continue ! Hurray

This reverts commit df19117a.
parent df19117a
...@@ -79,7 +79,7 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev ...@@ -79,7 +79,7 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
self->emit playing(); self->emit playing();
break; break;
case libvlc_MediaPlayerPaused: case libvlc_MediaPlayerPaused:
// qDebug() << "Media player paused"; qDebug() << "Media player paused";
self->emit paused(); self->emit paused();
break; break;
case libvlc_MediaPlayerStopped: case libvlc_MediaPlayerStopped:
......
...@@ -73,11 +73,13 @@ void ClipWorkflow::checkStateChange() ...@@ -73,11 +73,13 @@ void ClipWorkflow::checkStateChange()
QWriteLocker lock2( m_stateLock ); QWriteLocker lock2( m_stateLock );
if ( m_requiredState != ClipWorkflow::None ) if ( m_requiredState != ClipWorkflow::None )
{ {
// qDebug() << "Changed state from" << m_state << "to state" << m_requiredState; qDebug() << "Changed state from" << m_state << "to state" << m_requiredState;
m_state = m_requiredState; m_state = m_requiredState;
m_requiredState = ClipWorkflow::None; m_requiredState = ClipWorkflow::None;
checkSynchronisation( m_state ); checkSynchronisation( m_state );
} }
else
qDebug() << "No state required";
} }
void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret ) void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret )
...@@ -91,7 +93,7 @@ void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret ) ...@@ -91,7 +93,7 @@ void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret )
// else // else
// { // {
*pp_ret = cw->m_buffer; *pp_ret = cw->m_buffer;
// qDebug() << "Clip workflow locking <<<<<<<<<<<<<<<<<<<<<<<<<<"; qDebug() << "Clip workflow locking <<<<<<<<<<<<<<<<<<<<<<<<<<";
// } // }
} }
...@@ -112,14 +114,15 @@ void ClipWorkflow::unlock( ClipWorkflow* cw ) ...@@ -112,14 +114,15 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
{ {
QMutexLocker lock( cw->m_condMutex ); QMutexLocker lock( cw->m_condMutex );
qDebug() << "Setting state to Sleeping";
cw->m_state = Sleeping; cw->m_state = Sleeping;
cw->m_stateLock->unlock(); cw->m_stateLock->unlock();
//Signal that render has been completed. //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_condMutex ); 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;
// { // {
...@@ -130,6 +133,7 @@ void ClipWorkflow::unlock( ClipWorkflow* cw ) ...@@ -130,6 +133,7 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
} }
else if ( cw->m_state == Paused ) else if ( cw->m_state == Paused )
{ {
qDebug() << "Forcing pause inside of unlock";
cw->m_stateLock->unlock(); cw->m_stateLock->unlock();
cw->m_waitCond->wait( cw->m_condMutex ); cw->m_waitCond->wait( cw->m_condMutex );
} }
...@@ -279,6 +283,7 @@ void ClipWorkflow::checkSynchronisation( State newState ) ...@@ -279,6 +283,7 @@ void ClipWorkflow::checkSynchronisation( State newState )
m_initWaitCond->wake(); m_initWaitCond->wake();
break ; break ;
case Pausing: case Pausing:
qDebug() << "Waking m_pausingStateWaitCond";
m_pausingStateWaitCond->wake(); m_pausingStateWaitCond->wake();
break ; break ;
default: default:
...@@ -297,7 +302,7 @@ void ClipWorkflow::setState( State state ) ...@@ -297,7 +302,7 @@ void ClipWorkflow::setState( State state )
void ClipWorkflow::queryStateChange( State newState ) void ClipWorkflow::queryStateChange( State newState )
{ {
// qDebug() << "Querying state change to" << newState; qDebug() << "Querying state change to" << newState;
QMutexLocker lock( m_requiredStateLock ); QMutexLocker lock( m_requiredStateLock );
m_requiredState = newState; m_requiredState = newState;
} }
...@@ -305,6 +310,7 @@ void ClipWorkflow::queryStateChange( State newState ) ...@@ -305,6 +310,7 @@ void ClipWorkflow::queryStateChange( State newState )
void ClipWorkflow::wake() void ClipWorkflow::wake()
{ {
m_waitCond->wakeAll(); m_waitCond->wakeAll();
qDebug() << "Awaked thread";
} }
QReadWriteLock* ClipWorkflow::getStateLock() QReadWriteLock* ClipWorkflow::getStateLock()
...@@ -324,6 +330,7 @@ void ClipWorkflow::pause() ...@@ -324,6 +330,7 @@ void ClipWorkflow::pause()
setState( Paused ); setState( Paused );
m_mediaPlayer->pause(); m_mediaPlayer->pause();
QMutexLocker lock( m_requiredStateLock ); QMutexLocker lock( m_requiredStateLock );
qDebug() << "ClipWorkflow::pause(); Reseting required state";
m_requiredState = ClipWorkflow::None; m_requiredState = ClipWorkflow::None;
} }
......
...@@ -126,11 +126,13 @@ void MainWorkflow::pause() ...@@ -126,11 +126,13 @@ void MainWorkflow::pause()
{ {
QMutexLocker lock( m_renderMutex ); QMutexLocker lock( m_renderMutex );
qDebug() << "Pausing.......................";
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 )
m_tracks[i]->pause(); m_tracks[i]->pause();
} }
qDebug() << "Pausing completed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
} }
void MainWorkflow::nextFrame() void MainWorkflow::nextFrame()
......
...@@ -128,6 +128,7 @@ unsigned char* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentF ...@@ -128,6 +128,7 @@ unsigned char* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentF
// qDebug() << "Querying state back to pause after render"; // qDebug() << "Querying state back to pause after render";
cw->queryStateChange( ClipWorkflow::Paused ); cw->queryStateChange( ClipWorkflow::Paused );
} }
qDebug() << ">>> Awaking ClipWorkflow thread for render";
cw->wake(); cw->wake();
} }
else if ( cw->getState() == ClipWorkflow::Stopped ) else if ( cw->getState() == ClipWorkflow::Stopped )
...@@ -200,11 +201,15 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw ) ...@@ -200,11 +201,15 @@ 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 )
{ {
...@@ -259,6 +264,7 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame ) ...@@ -259,6 +264,7 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
bool needRepositioning; bool needRepositioning;
bool oneFrameOnlyFlag = false; bool oneFrameOnlyFlag = false;
qDebug() << "Asking for track output";
// qDebug() << "Checking flag..."; // qDebug() << "Checking flag...";
if ( m_oneFrameOnly == 1 ) if ( m_oneFrameOnly == 1 )
{ {
...@@ -335,30 +341,42 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw ) ...@@ -335,30 +341,42 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
cw->getState() == ClipWorkflow::Ready || cw->getState() == ClipWorkflow::Ready ||
cw->getState() == ClipWorkflow::EndReached ) cw->getState() == ClipWorkflow::EndReached )
{ {
qDebug() << "Pausing a sleeping, ready or EndReached ClipWorkflow, state =" << cw->getState();
cw->queryStateChange( ClipWorkflow::Pausing ); cw->queryStateChange( ClipWorkflow::Pausing );
qDebug() << "Unlocked state mutex";
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
cw->wake(); cw->wake();
} }
else if ( cw->getState() == ClipWorkflow::Rendering ) else if ( cw->getState() == ClipWorkflow::Rendering )
{ {
qDebug() << "Pausing a rendering clip workflow";
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
qDebug() << "Waiting for render complete";
cw->waitForCompleteRender(); cw->waitForCompleteRender();
qDebug() << "Waiting complete";
qDebug() << "Waiting for sleep mutex";
QMutexLocker lock( cw->getSleepMutex() ); QMutexLocker lock( cw->getSleepMutex() );
qDebug() << "Got sleep mutex";
cw->queryStateChange( ClipWorkflow::Pausing ); cw->queryStateChange( ClipWorkflow::Pausing );
cw->wake(); cw->wake();
} }
else if ( cw->getState() == ClipWorkflow::Initializing ) else if ( cw->getState() == ClipWorkflow::Initializing )
{ {
qDebug() << "Pausing a Initializing ClipWorkflow";
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
//TODO: since a Initializing clipworkflow will pause itself at the end, shouldn't we do nothing ? //TODO: since a Initializing clipworkflow will pause itself at the end, shouldn't we do nothing ?
cw->waitForCompleteInit(); cw->waitForCompleteInit();
} }
else else
{ {
qDebug() << "Unexpected ClipWorkflow::State when pausing:" << cw->getState();
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
} }
qDebug() << "Waiting for pausing state";
cw->waitForPausingState(); cw->waitForPausingState();
qDebug() << "Waiting ok. Pausing now... ";
cw->pause(); cw->pause();
qDebug() << "Clip paused.";
} }
void TrackWorkflow::pause() void TrackWorkflow::pause()
...@@ -369,6 +387,7 @@ void TrackWorkflow::pause() ...@@ -369,6 +387,7 @@ void TrackWorkflow::pause()
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end(); QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
//FIXME: it's probably bad to iterate over every clip workflows. //FIXME: it's probably bad to iterate over every clip workflows.
qDebug() << "Started track pause loop";
for ( ; it != end; ++it ) for ( ; it != end; ++it )
{ {
ClipWorkflow* cw = it.value(); ClipWorkflow* cw = it.value();
...@@ -388,9 +407,10 @@ void TrackWorkflow::pause() ...@@ -388,9 +407,10 @@ 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 )
// qDebug() << "Asking to pause in an already paused state"; qDebug() << "Asking to pause in an already paused state";
} }
} }
qDebug() << "End of loop";
m_paused = !m_paused; m_paused = !m_paused;
} }
......
...@@ -90,8 +90,10 @@ void* WorkflowRenderer::lock( void* datas ) ...@@ -90,8 +90,10 @@ void* WorkflowRenderer::lock( void* datas )
return self->m_lastFrame; 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 );
qDebug() << "Got picture";
return ret; return ret;
} }
else else
...@@ -123,6 +125,7 @@ void WorkflowRenderer::checkActions() ...@@ -123,6 +125,7 @@ void WorkflowRenderer::checkActions()
switch ( act ) switch ( act )
{ {
case Pause: case Pause:
qDebug() << "Pausing WorkflowRenderer mediaPlayer";
m_mediaPlayer->pause(); m_mediaPlayer->pause();
//This will also pause the MainWorkflow via a signal/slot //This will also pause the MainWorkflow via a signal/slot
break ; break ;
...@@ -181,6 +184,7 @@ void WorkflowRenderer::previousFrame() ...@@ -181,6 +184,7 @@ void WorkflowRenderer::previousFrame()
void WorkflowRenderer::pauseMainWorkflow() void WorkflowRenderer::pauseMainWorkflow()
{ {
qDebug() << "In pause callback";
m_mainWorkflow->pause(); m_mainWorkflow->pause();
m_paused = true; m_paused = true;
} }
......
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