Commit 5f1eb6dd authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Rendering is still active when paused.

IE you can pause the preview, but still change the position, and the render gets updated.
parent 7ca64756
......@@ -97,7 +97,9 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
cw->m_renderWaitCond->wake();
cw->emit renderComplete( cw );
// qDebug() << ">>>Entering condwait";
cw->m_waitCond->wait( cw->m_condMutex );
// qDebug() << "<<<Leaving condwait";
cw->m_stateLock->lockForWrite();
cw->m_state = Rendering;
cw->m_stateLock->unlock();
......@@ -238,6 +240,12 @@ bool ClipWorkflow::isRendering() const
return m_state == ClipWorkflow::Rendering;
}
bool ClipWorkflow::isSleeping() const
{
QReadLocker lock( m_stateLock );
return m_state == ClipWorkflow::Sleeping;
}
void ClipWorkflow::checkSynchronisation( State newState )
{
switch ( newState )
......@@ -286,12 +294,14 @@ void ClipWorkflow::reinitialize()
void ClipWorkflow::pause()
{
qDebug() << "Pausing clip workflow";
setState( Pausing );
qDebug() << "State set to Pausing";
m_mediaPlayer->pause();
qDebug() << "Pause asked";
QMutexLocker lock( m_requiredStateLock );
m_requiredState = ClipWorkflow::None;
QReadLocker lock2( m_stateLock );
if ( m_state == Sleeping )
{
QMutexLocker sync( m_condMutex );
wake();
......@@ -330,6 +340,7 @@ LibVLCpp::MediaPlayer* ClipWorkflow::getMediaPlayer()
void ClipWorkflow::pausedMediaPlayer()
{
setState( Paused );
qDebug() << "Clip workflow is paused";
emit paused();
}
......
......@@ -92,9 +92,7 @@ class ClipWorkflow : public QObject
*/
bool isRendering() const;
bool isPausing() const;
bool isThreadPaused() const;
bool isSleeping() const;
/**
* Returns the current workflow state.
......
......@@ -318,7 +318,9 @@ unsigned char* MainWorkflow::getSynchroneOutput()
{
m_synchroneRenderWaitConditionMutex->lock();
getOutput();
qDebug() << "Waiting for synchrone output";
m_synchroneRenderWaitCondition->wait( m_synchroneRenderWaitConditionMutex );
qDebug() << "And got it";
m_synchroneRenderWaitConditionMutex->unlock();
if ( m_synchroneRenderingBuffer == NULL )
return MainWorkflow::blackOutput;
......
......@@ -144,8 +144,19 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->getStateLock()->unlock();
//The stopClipWorkflow() method will take care of that.
}
else if ( cw->getState() == ClipWorkflow::Paused )
{
cw->getStateLock()->unlock();
if ( needRepositioning == true )
{
float pos = ( (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) );
cw->setPosition( pos );
}
clipWorkflowRenderCompleted( cw );
}
else
{
qDebug() << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Unexpected state while rendering";
cw->getStateLock()->unlock();
}
}
......@@ -317,6 +328,7 @@ void TrackWorkflow::pause()
{
cw->getStateLock()->unlock();
m_nbClipToPause.fetchAndAddAcquire( 1 );
qDebug() << "Track is asking clip to pause. state lock unlocked";
cw->pause();
}
else
......
......@@ -61,6 +61,9 @@ WorkflowRenderer::WorkflowRenderer( MainWorkflow* mainWorkflow ) :
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
connect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
m_condMutex = new QMutex;
m_waitCond = new QWaitCondition;
}
......@@ -76,6 +79,8 @@ WorkflowRenderer::~WorkflowRenderer()
delete m_actionsLock;
delete m_media;
delete m_condMutex;
delete m_waitCond;
}
void* WorkflowRenderer::lock( void* datas )
......@@ -114,7 +119,8 @@ void WorkflowRenderer::checkActions()
if ( m_pauseAsked == true )
continue ;
m_pauseAsked = true;
m_mediaPlayer->pause();
// m_mediaPlayer->pause();
pauseMainWorkflow();
//This will also pause the MainWorkflow via a signal/slot
break ;
default:
......@@ -166,12 +172,14 @@ void WorkflowRenderer::pauseMainWorkflow()
if ( m_paused == true )
return ;
m_pausedMediaPlayer = true;
QMutexLocker lock( m_condMutex );
m_mainWorkflow->pause();
m_waitCond->wait( m_condMutex );
}
void WorkflowRenderer::unpauseMainWorkflow()
{
qDebug() << "unpauseMainWorkflow();";
if ( m_paused == false )
return ;
m_pausedMediaPlayer = false;
......@@ -182,12 +190,17 @@ void WorkflowRenderer::mainWorkflowPaused()
{
m_paused = true;
m_pauseAsked = false;
qDebug() << "mainworkflow is paused 1";
{
QMutexLocker lock( m_condMutex );
}
qDebug() << "mainworkflow is paused 2";
m_waitCond->wakeAll();
emit paused();
}
void WorkflowRenderer::mainWorkflowUnpaused()
{
qDebug() << "Emmiting signal playing";
m_paused = false;
m_unpauseAsked = false;
emit playing();
......
......@@ -77,6 +77,8 @@ class WorkflowRenderer : public GenericRenderer
QReadWriteLock* m_actionsLock;
bool m_pauseAsked;
bool m_unpauseAsked;
QMutex* m_condMutex;
QWaitCondition* m_waitCond;
/**
* \brief This flag is used to avoid using libvlc function from the media player thread,
......@@ -88,15 +90,17 @@ class WorkflowRenderer : public GenericRenderer
void setMedia( const Media* ){}
void mediaUnloaded( const QUuid& ) {}
void mainWorkflowPaused();
void mainWorkflowUnpaused();
void __positionChanged();
void __positionChanged( float pos );
void __videoPaused();
void __videoStopped();
void __videoPlaying();
void __endReached();
private slots:
void mainWorkflowPaused();
void mainWorkflowUnpaused();
};
#endif // WORKFLOWRENDERER_H
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