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()
m_media->addOption( ":text-renderer dummy" );
//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( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ),
this, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) );
......@@ -135,7 +133,7 @@ WorkflowRenderer::lockVideo( qint64 *pts, size_t *bufferSize, void **buffer )
if ( m_stopping == false )
{
MainWorkflow::OutputBuffers* ret =
m_mainWorkflow->getOutput( MainWorkflow::VideoTrack );
m_mainWorkflow->getOutput( MainWorkflow::VideoTrack, m_paused );
memcpy( m_renderVideoFrame,
(*(ret->video))->frame.octets,
(*(ret->video))->nboctets );
......@@ -164,7 +162,8 @@ WorkflowRenderer::lockAudio( qint64 *pts, size_t *bufferSize, void **buffer )
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;
}
else
......@@ -235,18 +234,6 @@ void WorkflowRenderer::previousFrame()
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 )
{
if ( m_isRendering == false && forcePause == false )
......@@ -262,13 +249,15 @@ void WorkflowRenderer::internalPlayPause( bool forcePause )
{
if ( m_paused == true && forcePause == false )
{
m_mainWorkflow->unpause();
m_paused = false;
emit playing();
}
else
{
if ( m_paused == false )
{
m_mainWorkflow->pause();
m_paused = true;
emit paused();
}
}
}
......
......@@ -271,14 +271,6 @@ class WorkflowRenderer : public GenericRenderer
void __endReached();
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
* first changed to a non zero value.
......
......@@ -134,7 +134,7 @@ MainWorkflow::startRender()
}
MainWorkflow::OutputBuffers*
MainWorkflow::getOutput( TrackType trackType )
MainWorkflow::getOutput( TrackType trackType, bool paused )
{
QMutexLocker lock( m_renderStartedMutex );
......@@ -143,7 +143,7 @@ MainWorkflow::getOutput( TrackType trackType )
QReadLocker lock2( m_currentFrameLock );
m_tracks[trackType]->getOutput( m_currentFrame[VideoTrack],
m_currentFrame[trackType] );
m_currentFrame[trackType], paused );
if ( trackType == MainWorkflow::VideoTrack )
{
m_effectEngine->setCurrentFrameNumber( m_currentFrame[VideoTrack] );
......@@ -160,22 +160,6 @@ MainWorkflow::getOutput( TrackType trackType )
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
MainWorkflow::nextFrame( MainWorkflow::TrackType trackType )
{
......@@ -221,7 +205,6 @@ MainWorkflow::stop()
m_tracks[i]->stop();
m_currentFrame[i] = 0;
}
unpause();
emit frameChanged( 0, Renderer );
}
......
......@@ -117,8 +117,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* the output buffer is guarantied to be filled. The same applies for
* AudioTrack
* \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
*
......@@ -157,22 +158,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
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.
*
......@@ -513,20 +498,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* \sa clear();
*/
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.
......
......@@ -79,7 +79,6 @@ TrackHandler::addClip( Clip* clip, unsigned int trackId, qint64 start )
void
TrackHandler::startRender()
{
m_paused = false;
m_endReached = false;
computeLength();
if ( m_length == 0 )
......@@ -111,7 +110,7 @@ TrackHandler::getLength() const
}
void
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{
m_tmpAudioBuffer = NULL;
for ( unsigned int i = 0; i < m_trackCount; ++i )
......@@ -124,7 +123,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
}
else
{
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame );
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
if ( ret == NULL )
m_effectEngine->setVideoInput( i + 1, *TrackHandler::nullOutput );
else
......@@ -139,7 +138,8 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
{
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;
if ( ret == NULL )
continue ;
......@@ -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
TrackHandler::activateAll()
{
......@@ -275,12 +255,6 @@ TrackHandler::clear()
m_length = 0;
}
bool
TrackHandler::isPaused() const
{
return m_paused;
}
bool
TrackHandler::endIsReached() const
{
......
......@@ -52,12 +52,12 @@ class TrackHandler : public QObject
* \param subFrame The type-dependent frame. IE, for a video track,
* it's the same as currentFrame, but for an audio
* track, it will be different.
* \param paused The renderer paused state
* \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.
*/
void getOutput( qint64 currentFrame, qint64 subFrame );
void pause();
void unpause();
void getOutput( qint64 currentFrame, qint64 subFrame,
bool paused );
void activateAll();
qint64 getClipPosition( const QUuid& uuid, unsigned int trackId ) const;
void stop();
......@@ -72,7 +72,6 @@ class TrackHandler : public QObject
//FIXME: remove this. This should go by the effect engine.
AudioClipWorkflow::AudioSample* getTmpAudioBuffer() { return m_tmpAudioBuffer; }
bool isPaused() const;
bool endIsReached() const;
void save( QDomDocument& doc, QDomElement& timelineNode ) const;
......@@ -109,7 +108,6 @@ class TrackHandler : public QObject
MainWorkflow::TrackType m_trackType;
qint64 m_length;
unsigned int m_highestTrackNumber;
bool m_paused;
bool m_endReached;
EffectsEngine* m_effectEngine;
AudioClipWorkflow::AudioSample* m_tmpAudioBuffer;
......
......@@ -37,7 +37,6 @@ TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type
m_trackId( trackId ),
m_length( 0 ),
m_forceRepositionning( false ),
m_paused( false ),
m_trackType( type ),
m_lastFrame( 0 ),
m_videoStackedBuffer( NULL ),
......@@ -131,11 +130,12 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid )
return NULL;
}
void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
void*
TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
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 );
cw->getStateLock()->lockForRead();
......@@ -215,7 +215,8 @@ bool TrackWorkflow::checkEnd( qint64 currentFrame ) const
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 end = m_clips.end();
......@@ -229,7 +230,8 @@ void TrackWorkflow::stop()
m_lastFrame = 0;
}
void TrackWorkflow::releasePreviousRender()
void
TrackWorkflow::releasePreviousRender()
{
if ( m_audioStackedBuffer != NULL )
{
......@@ -244,7 +246,7 @@ void TrackWorkflow::releasePreviousRender()
}
void*
TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{
releasePreviousRender();
QReadLocker lock( m_clipsLock );
......@@ -283,7 +285,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
// 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
// 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;
else
needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false;
......@@ -298,7 +300,8 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
{
if ( ret != NULL )
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 )
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret );
else
......@@ -318,12 +321,6 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame )
return ret;
}
void TrackWorkflow::pause()
{
m_paused = true;
m_lastFrame = -1;
}
void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
{
QWriteLocker lock( m_clipsLock );
......@@ -399,11 +396,6 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id )
return NULL;
}
void TrackWorkflow::unpause()
{
m_paused = false;
}
void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
{
QReadLocker lock( m_clipsLock );
......
......@@ -59,11 +59,9 @@ class TrackWorkflow : public QObject
~TrackWorkflow();
void* getOutput( qint64 currentFrame,
qint64 subFrame );
qint64 subFrame, bool paused );
qint64 getLength() const;
void stop();
void pause();
void unpause();
void moveClip( const QUuid& id, qint64 startingFrame );
Clip* removeClip( const QUuid& id );
ClipWorkflow* removeClipWorkflow( const QUuid& id );
......@@ -99,7 +97,7 @@ class TrackWorkflow : public QObject
void computeLength();
void* renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start, bool needRepositioning,
bool renderOneFrame );
bool renderOneFrame, bool paused );
void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const;
......@@ -128,8 +126,6 @@ class TrackWorkflow : public QObject
QReadWriteLock* m_clipsLock;
bool m_paused;
MainWorkflow::TrackType m_trackType;
qint64 m_lastFrame;
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