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

Revert "Revert "More debug on pausing render preview.""

This reverts commit c076f2b7.
parent f7f4a441
......@@ -341,7 +341,7 @@ void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
cw->getState() == ClipWorkflow::Ready ||
cw->getState() == ClipWorkflow::EndReached )
{
qDebug() << "Pausing a sleeping, ready or EndReached ClipWorkflow";
qDebug() << "Pausing a sleeping, ready or EndReached ClipWorkflow, state =" << cw->getState();
cw->getStateLock()->unlock();
cw->queryStateChange( ClipWorkflow::Pausing );
cw->wake();
......@@ -406,8 +406,7 @@ void TrackWorkflow::pause()
{
//This should never be used.
//TODO: remove this in a few revision (wrote on July 16 2009 )
qDebug() << "State before crash is:" << cw->getState();
Q_ASSERT( false );
qDebug() << "Asking to pause in an already paused state";
}
}
qDebug() << "End of loop";
......
......@@ -31,6 +31,7 @@ WorkflowRenderer::WorkflowRenderer( MainWorkflow* mainWorkflow ) :
m_mainWorkflow( mainWorkflow ),
m_framePlayed( false )
{
m_actionsLock = new QReadWriteLock;
m_media = new LibVLCpp::Media( "fake://" );
// --invmem-width <integer> Width
// --invmem-height <integer> Height
......@@ -75,6 +76,7 @@ WorkflowRenderer::~WorkflowRenderer()
disconnect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
disconnect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
delete m_actionsLock;
delete m_media;
delete m_mainWorkflow;
}
......@@ -104,6 +106,30 @@ void WorkflowRenderer::unlock( void* datas )
self->m_oneFrameOnly = 2;
}
self->m_framePlayed = true;
self->checkActions();
}
void WorkflowRenderer::checkActions()
{
QReadLocker lock( m_actionsLock );
if ( m_actions.size() == 0 )
return ;
while ( m_actions.empty() == false )
{
Actions act = m_actions.top();
m_actions.pop();
switch ( act )
{
case Pause:
m_mediaPlayer->pause();
//This will also pause the MainWorkflow via a signal/slot
break ;
default:
qDebug() << "Unhandled action:" << act;
break ;
}
}
}
void WorkflowRenderer::stopPreview()
......@@ -178,8 +204,10 @@ void WorkflowRenderer::togglePlayPause( bool forcePause )
//So be careful about pausing two times :
if ( m_paused == false )
{
m_mediaPlayer->pause();
qDebug() << "Waiting for paused media player";
// m_mediaPlayer->pause();
// qDebug() << "Waiting for paused media player";
QWriteLocker lock( m_actionsLock );
m_actions.push( Pause );
}
}
}
......
......@@ -26,6 +26,7 @@
#include <QObject>
#include <QWidget>
#include <QStack>
#include "Workflow/MainWorkflow.h"
#include "GenericRenderer.h"
......@@ -36,6 +37,11 @@ class WorkflowRenderer : public GenericRenderer
Q_DISABLE_COPY( WorkflowRenderer )
public:
enum Actions
{
Pause,
Unpause,
};
WorkflowRenderer( MainWorkflow* mainWorkflow );
~WorkflowRenderer();
......@@ -61,6 +67,7 @@ class WorkflowRenderer : public GenericRenderer
private:
void pauseMainWorkflow();
virtual void startPreview();
void checkActions();
private:
MainWorkflow* m_mainWorkflow;
......@@ -68,6 +75,8 @@ class WorkflowRenderer : public GenericRenderer
QAtomicInt m_oneFrameOnly;
unsigned char* m_lastFrame;
bool m_framePlayed;
QStack<Actions> m_actions;
QReadWriteLock* m_actionsLock;
public slots:
void __positionChanged();
......
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