Commit 48d1a8ae authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Removed paused state from the mainworkflow.

The renderer gives the paused state directly to the workflow, thus
avoiding missynchronisation
parent 030870fe
...@@ -82,8 +82,6 @@ void WorkflowRenderer::initializeRenderer() ...@@ -82,8 +82,6 @@ void WorkflowRenderer::initializeRenderer()
m_media->addOption( ":text-renderer dummy" ); m_media->addOption( ":text-renderer dummy" );
//Workflow part //Workflow part
connect( m_mainWorkflow, SIGNAL( mainWorkflowPaused() ), this, SLOT( mainWorkflowPaused() ), Qt::DirectConnection );
connect( m_mainWorkflow, SIGNAL( mainWorkflowUnpaused() ), this, SLOT( mainWorkflowUnpaused() ), Qt::DirectConnection );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) ); connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
connect( m_mainWorkflow, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ), connect( m_mainWorkflow, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ),
this, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) ); this, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) );
...@@ -135,7 +133,7 @@ WorkflowRenderer::lockVideo( qint64 *pts, size_t *bufferSize, void **buffer ) ...@@ -135,7 +133,7 @@ WorkflowRenderer::lockVideo( qint64 *pts, size_t *bufferSize, void **buffer )
if ( m_stopping == false ) if ( m_stopping == false )
{ {
MainWorkflow::OutputBuffers* ret = MainWorkflow::OutputBuffers* ret =
m_mainWorkflow->getOutput( MainWorkflow::VideoTrack ); m_mainWorkflow->getOutput( MainWorkflow::VideoTrack, m_paused );
memcpy( m_renderVideoFrame, memcpy( m_renderVideoFrame,
(*(ret->video))->frame.octets, (*(ret->video))->frame.octets,
(*(ret->video))->nboctets ); (*(ret->video))->nboctets );
...@@ -164,7 +162,8 @@ WorkflowRenderer::lockAudio( qint64 *pts, size_t *bufferSize, void **buffer ) ...@@ -164,7 +162,8 @@ WorkflowRenderer::lockAudio( qint64 *pts, size_t *bufferSize, void **buffer )
if ( m_stopping == false && m_paused == false ) if ( m_stopping == false && m_paused == false )
{ {
MainWorkflow::OutputBuffers* ret = m_mainWorkflow->getOutput( MainWorkflow::AudioTrack ); MainWorkflow::OutputBuffers* ret = m_mainWorkflow->getOutput( MainWorkflow::AudioTrack,
m_paused );
renderAudioSample = ret->audio; renderAudioSample = ret->audio;
} }
else else
...@@ -235,18 +234,6 @@ void WorkflowRenderer::previousFrame() ...@@ -235,18 +234,6 @@ void WorkflowRenderer::previousFrame()
m_mainWorkflow->previousFrame( MainWorkflow::VideoTrack ); m_mainWorkflow->previousFrame( MainWorkflow::VideoTrack );
} }
void WorkflowRenderer::mainWorkflowPaused()
{
m_paused = true;
emit paused();
}
void WorkflowRenderer::mainWorkflowUnpaused()
{
m_paused = false;
emit playing();
}
void WorkflowRenderer::togglePlayPause( bool forcePause ) void WorkflowRenderer::togglePlayPause( bool forcePause )
{ {
if ( m_isRendering == false && forcePause == false ) if ( m_isRendering == false && forcePause == false )
...@@ -262,13 +249,15 @@ void WorkflowRenderer::internalPlayPause( bool forcePause ) ...@@ -262,13 +249,15 @@ void WorkflowRenderer::internalPlayPause( bool forcePause )
{ {
if ( m_paused == true && forcePause == false ) if ( m_paused == true && forcePause == false )
{ {
m_mainWorkflow->unpause(); m_paused = false;
emit playing();
} }
else else
{ {
if ( m_paused == false ) if ( m_paused == false )
{ {
m_mainWorkflow->pause(); m_paused = true;
emit paused();
} }
} }
} }
......
...@@ -271,14 +271,6 @@ class WorkflowRenderer : public GenericRenderer ...@@ -271,14 +271,6 @@ class WorkflowRenderer : public GenericRenderer
void __endReached(); void __endReached();
private slots: private slots:
/**
* \brief called when the workflow is paused
*/
void mainWorkflowPaused();
/**
* \brief called when the workflow is unpaused
*/
void mainWorkflowUnpaused();
/** /**
* \brief Used to launch "permanent playback", as soon as the length * \brief Used to launch "permanent playback", as soon as the length
* first changed to a non zero value. * first changed to a non zero value.
......
...@@ -134,7 +134,7 @@ MainWorkflow::startRender() ...@@ -134,7 +134,7 @@ MainWorkflow::startRender()
} }
MainWorkflow::OutputBuffers* MainWorkflow::OutputBuffers*
MainWorkflow::getOutput( TrackType trackType ) MainWorkflow::getOutput( TrackType trackType, bool paused )
{ {
QMutexLocker lock( m_renderStartedMutex ); QMutexLocker lock( m_renderStartedMutex );
...@@ -143,7 +143,7 @@ MainWorkflow::getOutput( TrackType trackType ) ...@@ -143,7 +143,7 @@ MainWorkflow::getOutput( TrackType trackType )
QReadLocker lock2( m_currentFrameLock ); QReadLocker lock2( m_currentFrameLock );
m_tracks[trackType]->getOutput( m_currentFrame[VideoTrack], m_tracks[trackType]->getOutput( m_currentFrame[VideoTrack],
m_currentFrame[trackType] ); m_currentFrame[trackType], paused );
if ( trackType == MainWorkflow::VideoTrack ) if ( trackType == MainWorkflow::VideoTrack )
{ {
m_effectEngine->setCurrentFrameNumber( m_currentFrame[VideoTrack] ); m_effectEngine->setCurrentFrameNumber( m_currentFrame[VideoTrack] );
...@@ -160,22 +160,6 @@ MainWorkflow::getOutput( TrackType trackType ) ...@@ -160,22 +160,6 @@ MainWorkflow::getOutput( TrackType trackType )
return m_outputBuffers; return m_outputBuffers;
} }
void
MainWorkflow::pause()
{
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->pause();
emit mainWorkflowPaused();
}
void
MainWorkflow::unpause()
{
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->unpause();
emit mainWorkflowUnpaused();
}
void void
MainWorkflow::nextFrame( MainWorkflow::TrackType trackType ) MainWorkflow::nextFrame( MainWorkflow::TrackType trackType )
{ {
...@@ -221,7 +205,6 @@ MainWorkflow::stop() ...@@ -221,7 +205,6 @@ MainWorkflow::stop()
m_tracks[i]->stop(); m_tracks[i]->stop();
m_currentFrame[i] = 0; m_currentFrame[i] = 0;
} }
unpause();
emit frameChanged( 0, Renderer ); emit frameChanged( 0, Renderer );
} }
......
...@@ -117,8 +117,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -117,8 +117,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* the output buffer is guarantied to be filled. The same applies for * the output buffer is guarantied to be filled. The same applies for
* AudioTrack * AudioTrack
* \param trackType The type of track you wish to get the render from. * \param trackType The type of track you wish to get the render from.
* \param paused The paused state of the renderer
*/ */
OutputBuffers* getOutput( TrackType trackType ); OutputBuffers* getOutput( TrackType trackType, bool paused );
/** /**
* \brief Returns the effect engine instance used by the workflow * \brief Returns the effect engine instance used by the workflow
* *
...@@ -157,22 +158,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -157,22 +158,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
void stop(); void stop();
/**
* \brief Pause the workflow.
*
* This will cause the mainworkflow to render the same frame over and over again
* if calling getOutput().
*
* \sa unpause()
*/
void pause();
/**
* \brief Unpause the workflow.
*
* \sa pause()
*/
void unpause();
/** /**
* \brief Unconditionnaly switch to the next frame. * \brief Unconditionnaly switch to the next frame.
* *
...@@ -513,20 +498,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -513,20 +498,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* \sa clear(); * \sa clear();
*/ */
void cleared(); void cleared();
/**
* \brief Emitted when the workflow is paused.
*
* \sa pause();
* \sa unpause();
*/
void mainWorkflowPaused();
/**
* \brief Emitted when the workflow is unpaused.
*
* \sa pause();
* \sa unpause();
*/
void mainWorkflowUnpaused();
/** /**
* \brief Emitted when the global length of the workflow changes. * \brief Emitted when the global length of the workflow changes.
......
...@@ -79,7 +79,6 @@ TrackHandler::addClip( Clip* clip, unsigned int trackId, qint64 start ) ...@@ -79,7 +79,6 @@ TrackHandler::addClip( Clip* clip, unsigned int trackId, qint64 start )
void void
TrackHandler::startRender() TrackHandler::startRender()
{ {
m_paused = false;
m_endReached = false; m_endReached = false;
computeLength(); computeLength();
if ( m_length == 0 ) if ( m_length == 0 )
...@@ -111,7 +110,7 @@ TrackHandler::getLength() const ...@@ -111,7 +110,7 @@ TrackHandler::getLength() const
} }
void void
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{ {
m_tmpAudioBuffer = NULL; m_tmpAudioBuffer = NULL;
for ( unsigned int i = 0; i < m_trackCount; ++i ) for ( unsigned int i = 0; i < m_trackCount; ++i )
...@@ -124,7 +123,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -124,7 +123,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
} }
else else
{ {
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame ); void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
if ( ret == NULL ) if ( ret == NULL )
m_effectEngine->setVideoInput( i + 1, *TrackHandler::nullOutput ); m_effectEngine->setVideoInput( i + 1, *TrackHandler::nullOutput );
else else
...@@ -139,7 +138,8 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -139,7 +138,8 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
{ {
if ( m_tracks[i].activated() == true ) if ( m_tracks[i].activated() == true )
{ {
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame ); //If paused is false at this point, there's probably something wrong...
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
//m_tmpAudioBuffer is NULl by default, so it will remain NULL if we continue; //m_tmpAudioBuffer is NULl by default, so it will remain NULL if we continue;
if ( ret == NULL ) if ( ret == NULL )
continue ; continue ;
...@@ -152,26 +152,6 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -152,26 +152,6 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
} }
} }
void
TrackHandler::pause()
{
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
if ( m_tracks[i].activated() == true )
m_tracks[i]->pause();
}
}
void
TrackHandler::unpause()
{
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
//Don't check for track activation, as it could have change from the time we paused.
m_tracks[i]->unpause();
}
}
void void
TrackHandler::activateAll() TrackHandler::activateAll()
{ {
...@@ -275,12 +255,6 @@ TrackHandler::clear() ...@@ -275,12 +255,6 @@ TrackHandler::clear()
m_length = 0; m_length = 0;
} }
bool
TrackHandler::isPaused() const
{
return m_paused;
}
bool bool
TrackHandler::endIsReached() const TrackHandler::endIsReached() const
{ {
......
...@@ -52,12 +52,12 @@ class TrackHandler : public QObject ...@@ -52,12 +52,12 @@ class TrackHandler : public QObject
* \param subFrame The type-dependent frame. IE, for a video track, * \param subFrame The type-dependent frame. IE, for a video track,
* it's the same as currentFrame, but for an audio * it's the same as currentFrame, but for an audio
* track, it will be different. * track, it will be different.
* \param paused The renderer paused state
* \todo This should probably be partialy handled by the trackHandler, as the work * \todo This should probably be partialy handled by the trackHandler, as the work
* is exactly the same for both audio and video trackWorkflow in most of the case... or not. * is exactly the same for both audio and video trackWorkflow in most of the case... or not.
*/ */
void getOutput( qint64 currentFrame, qint64 subFrame ); void getOutput( qint64 currentFrame, qint64 subFrame,
void pause(); bool paused );
void unpause();
void activateAll(); void activateAll();
qint64 getClipPosition( const QUuid& uuid, unsigned int trackId ) const; qint64 getClipPosition( const QUuid& uuid, unsigned int trackId ) const;
void stop(); void stop();
...@@ -72,7 +72,6 @@ class TrackHandler : public QObject ...@@ -72,7 +72,6 @@ class TrackHandler : public QObject
//FIXME: remove this. This should go by the effect engine. //FIXME: remove this. This should go by the effect engine.
AudioClipWorkflow::AudioSample* getTmpAudioBuffer() { return m_tmpAudioBuffer; } AudioClipWorkflow::AudioSample* getTmpAudioBuffer() { return m_tmpAudioBuffer; }
bool isPaused() const;
bool endIsReached() const; bool endIsReached() const;
void save( QDomDocument& doc, QDomElement& timelineNode ) const; void save( QDomDocument& doc, QDomElement& timelineNode ) const;
...@@ -109,7 +108,6 @@ class TrackHandler : public QObject ...@@ -109,7 +108,6 @@ class TrackHandler : public QObject
MainWorkflow::TrackType m_trackType; MainWorkflow::TrackType m_trackType;
qint64 m_length; qint64 m_length;
unsigned int m_highestTrackNumber; unsigned int m_highestTrackNumber;
bool m_paused;
bool m_endReached; bool m_endReached;
EffectsEngine* m_effectEngine; EffectsEngine* m_effectEngine;
AudioClipWorkflow::AudioSample* m_tmpAudioBuffer; AudioClipWorkflow::AudioSample* m_tmpAudioBuffer;
......
...@@ -37,7 +37,6 @@ TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type ...@@ -37,7 +37,6 @@ TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type
m_trackId( trackId ), m_trackId( trackId ),
m_length( 0 ), m_length( 0 ),
m_forceRepositionning( false ), m_forceRepositionning( false ),
m_paused( false ),
m_trackType( type ), m_trackType( type ),
m_lastFrame( 0 ), m_lastFrame( 0 ),
m_videoStackedBuffer( NULL ), m_videoStackedBuffer( NULL ),
...@@ -131,11 +130,12 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid ) ...@@ -131,11 +130,12 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid )
return NULL; return NULL;
} }
void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, void*
TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start , bool needRepositioning, qint64 start , bool needRepositioning,
bool renderOneFrame ) bool renderOneFrame, bool paused )
{ {
ClipWorkflow::GetMode mode = ( m_paused == false || renderOneFrame == true ? ClipWorkflow::GetMode mode = ( paused == false || renderOneFrame == true ?
ClipWorkflow::Pop : ClipWorkflow::Get ); ClipWorkflow::Pop : ClipWorkflow::Get );
cw->getStateLock()->lockForRead(); cw->getStateLock()->lockForRead();
...@@ -215,7 +215,8 @@ bool TrackWorkflow::checkEnd( qint64 currentFrame ) const ...@@ -215,7 +215,8 @@ bool TrackWorkflow::checkEnd( qint64 currentFrame ) const
return ( it.value()->getClip()->getLength() + it.key() < currentFrame ); return ( it.value()->getClip()->getLength() + it.key() < currentFrame );
} }
void TrackWorkflow::stop() void
TrackWorkflow::stop()
{ {
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin(); QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end(); QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
...@@ -229,7 +230,8 @@ void TrackWorkflow::stop() ...@@ -229,7 +230,8 @@ void TrackWorkflow::stop()
m_lastFrame = 0; m_lastFrame = 0;
} }
void TrackWorkflow::releasePreviousRender() void
TrackWorkflow::releasePreviousRender()
{ {
if ( m_audioStackedBuffer != NULL ) if ( m_audioStackedBuffer != NULL )
{ {
...@@ -244,7 +246,7 @@ void TrackWorkflow::releasePreviousRender() ...@@ -244,7 +246,7 @@ void TrackWorkflow::releasePreviousRender()
} }
void* void*
TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame ) TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{ {
releasePreviousRender(); releasePreviousRender();
QReadLocker lock( m_clipsLock ); QReadLocker lock( m_clipsLock );
...@@ -283,7 +285,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -283,7 +285,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
// If this condition is true, the clipworkflow will flush all its buffer // If this condition is true, the clipworkflow will flush all its buffer
// as we need to resynchronize after a setTime, so this condition has to remain // as we need to resynchronize after a setTime, so this condition has to remain
// false. Easy ain't it ? // false. Easy ain't it ?
else if ( m_paused == true && subFrame != m_lastFrame && renderOneFrame == false) else if ( paused == true && subFrame != m_lastFrame && renderOneFrame == false)
needRepositioning = true; needRepositioning = true;
else else
needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false; needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false;
...@@ -298,7 +300,8 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -298,7 +300,8 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
{ {
if ( ret != NULL ) if ( ret != NULL )
qCritical() << "There's more than one clip to render here. Undefined behaviour !"; qCritical() << "There's more than one clip to render here. Undefined behaviour !";
ret = renderClip( cw, currentFrame, start, needRepositioning, renderOneFrame ); ret = renderClip( cw, currentFrame, start, needRepositioning,
renderOneFrame, paused );
if ( m_trackType == MainWorkflow::VideoTrack ) if ( m_trackType == MainWorkflow::VideoTrack )
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret ); m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret );
else else
...@@ -318,12 +321,6 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -318,12 +321,6 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
return ret; return ret;
} }
void TrackWorkflow::pause()
{
m_paused = true;
m_lastFrame = -1;
}
void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame ) void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
{ {
QWriteLocker lock( m_clipsLock ); QWriteLocker lock( m_clipsLock );
...@@ -399,11 +396,6 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id ) ...@@ -399,11 +396,6 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id )
return NULL; return NULL;
} }
void TrackWorkflow::unpause()
{
m_paused = false;
}
void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
{ {
QReadLocker lock( m_clipsLock ); QReadLocker lock( m_clipsLock );
......
...@@ -59,11 +59,9 @@ class TrackWorkflow : public QObject ...@@ -59,11 +59,9 @@ class TrackWorkflow : public QObject
~TrackWorkflow(); ~TrackWorkflow();
void* getOutput( qint64 currentFrame, void* getOutput( qint64 currentFrame,
qint64 subFrame ); qint64 subFrame, bool paused );
qint64 getLength() const; qint64 getLength() const;
void stop(); void stop();
void pause();
void unpause();
void moveClip( const QUuid& id, qint64 startingFrame ); void moveClip( const QUuid& id, qint64 startingFrame );
Clip* removeClip( const QUuid& id ); Clip* removeClip( const QUuid& id );
ClipWorkflow* removeClipWorkflow( const QUuid& id ); ClipWorkflow* removeClipWorkflow( const QUuid& id );
...@@ -99,7 +97,7 @@ class TrackWorkflow : public QObject ...@@ -99,7 +97,7 @@ class TrackWorkflow : public QObject
void computeLength(); void computeLength();
void* renderClip( ClipWorkflow* cw, qint64 currentFrame, void* renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start, bool needRepositioning, qint64 start, bool needRepositioning,
bool renderOneFrame ); bool renderOneFrame, bool paused );
void preloadClip( ClipWorkflow* cw ); void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( ClipWorkflow* cw ); void stopClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const; bool checkEnd( qint64 currentFrame ) const;
...@@ -128,8 +126,6 @@ class TrackWorkflow : public QObject ...@@ -128,8 +126,6 @@ class TrackWorkflow : public QObject
QReadWriteLock* m_clipsLock; QReadWriteLock* m_clipsLock;
bool m_paused;
MainWorkflow::TrackType m_trackType; MainWorkflow::TrackType m_trackType;
qint64 m_lastFrame; qint64 m_lastFrame;
StackedBuffer<LightVideoFrame*>* m_videoStackedBuffer; StackedBuffer<LightVideoFrame*>* m_videoStackedBuffer;
......
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