Commit 59d07523 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Workflow: Making frame rendering synchrone

IE wait for a frame to be ready when calling getOutput
parent d6d55f59
...@@ -45,16 +45,18 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) : ...@@ -45,16 +45,18 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) :
m_renderLock = new QMutex; m_renderLock = new QMutex;
m_availableBuffersMutex = new QMutex; m_availableBuffersMutex = new QMutex;
m_computedBuffersMutex = new QMutex; m_computedBuffersMutex = new QMutex;
m_renderWaitCond = new WaitCondition;
} }
ClipWorkflow::~ClipWorkflow() ClipWorkflow::~ClipWorkflow()
{ {
delete m_renderWaitCond;
delete m_computedBuffersMutex;
delete m_availableBuffersMutex;
delete m_renderLock; delete m_renderLock;
delete m_pausingStateWaitCond; delete m_pausingStateWaitCond;
delete m_initWaitCond; delete m_initWaitCond;
delete m_stateLock; delete m_stateLock;
delete m_availableBuffersMutex;
delete m_computedBuffersMutex;
} }
void ClipWorkflow::initialize() void ClipWorkflow::initialize()
......
...@@ -210,8 +210,8 @@ class ClipWorkflow : public QObject ...@@ -210,8 +210,8 @@ class ClipWorkflow : public QObject
virtual void releasePrealocated() = 0; virtual void releasePrealocated() = 0;
private: private:
WaitCondition* m_initWaitCond; WaitCondition *m_initWaitCond;
WaitCondition* m_pausingStateWaitCond; WaitCondition *m_pausingStateWaitCond;
/** /**
* \brief Used by the trackworkflow to query a clipworkflow resync. * \brief Used by the trackworkflow to query a clipworkflow resync.
* *
...@@ -243,6 +243,7 @@ class ClipWorkflow : public QObject ...@@ -243,6 +243,7 @@ class ClipWorkflow : public QObject
qint64 m_pauseDuration; qint64 m_pauseDuration;
bool m_fullSpeedRender; bool m_fullSpeedRender;
int debugType; int debugType;
WaitCondition *m_renderWaitCond;
private slots: private slots:
void loadingComplete(); void loadingComplete();
......
...@@ -20,12 +20,13 @@ ...@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include "VideoClipWorkflow.h" #include "Clip.h"
#include "LightVideoFrame.h"
#include "MainWorkflow.h" #include "MainWorkflow.h"
#include "StackedBuffer.hpp" #include "StackedBuffer.hpp"
#include "LightVideoFrame.h" #include "VideoClipWorkflow.h"
#include "Clip.h"
#include "VLCMedia.h" #include "VLCMedia.h"
#include "WaitCondition.hpp"
#include <QReadWriteLock> #include <QReadWriteLock>
...@@ -113,10 +114,19 @@ VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode ) ...@@ -113,10 +114,19 @@ VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
QMutexLocker lock( m_renderLock ); QMutexLocker lock( m_renderLock );
QMutexLocker lock2( m_computedBuffersMutex ); QMutexLocker lock2( m_computedBuffersMutex );
if ( preGetOutput() == false )
return NULL;
if ( isEndReached() == true ) if ( isEndReached() == true )
return NULL; return NULL;
if ( preGetOutput() == false )
{
QMutexLocker waitLock( m_renderWaitCond->getMutex() );
m_computedBuffersMutex->unlock();
m_renderLock->unlock();
m_renderWaitCond->waitLocked();
m_renderLock->lock();
m_computedBuffersMutex->lock();
}
::StackedBuffer<LightVideoFrame*>* buff; ::StackedBuffer<LightVideoFrame*>* buff;
if ( mode == ClipWorkflow::Pop ) if ( mode == ClipWorkflow::Pop )
buff = new StackedBuffer( m_computedBuffers.dequeue(), this, true ); buff = new StackedBuffer( m_computedBuffers.dequeue(), this, true );
...@@ -161,6 +171,8 @@ VideoClipWorkflow::unlock( VideoClipWorkflow *cw, void *buffer, int width, ...@@ -161,6 +171,8 @@ VideoClipWorkflow::unlock( VideoClipWorkflow *cw, void *buffer, int width,
cw->commonUnlock(); cw->commonUnlock();
cw->m_renderLock->unlock(); cw->m_renderLock->unlock();
cw->m_computedBuffersMutex->unlock(); cw->m_computedBuffersMutex->unlock();
QMutexLocker lock( cw->m_renderWaitCond->getMutex() );
cw->m_renderWaitCond->wake();
} }
uint32_t uint32_t
......
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