Commit 80bcdae8 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Renderers: Simplify play/pause

parent d99643bc
......@@ -121,7 +121,7 @@ ClipRenderer::stop()
}
void
ClipRenderer::togglePlayPause( bool forcePause )
ClipRenderer::togglePlayPause()
{
if ( m_clipLoaded == false )
{
......@@ -129,22 +129,10 @@ ClipRenderer::togglePlayPause( bool forcePause )
startPreview();
return ;
}
if ( m_paused == false && m_isRendering == true )
if ( m_isRendering == true )
{
m_sourceRenderer->playPause();
m_paused = true;
}
else if ( forcePause == false )
{
if ( m_isRendering == false )
{
m_sourceRenderer->start();
m_sourceRenderer->setPosition( m_begin / ( m_end - m_begin ) );
m_isRendering = true;
}
else
m_sourceRenderer->playPause();
m_paused = false;
m_paused = !m_paused;
}
}
......@@ -175,7 +163,10 @@ ClipRenderer::previousFrame()
if ( m_isRendering == true )
{
if ( m_paused == false )
togglePlayPause( true );
{
togglePlayPause();
Q_ASSERT( m_paused == true );
}
/* FIXME: Implement a better way to render previous frame */
qint64 interval = static_cast<qint64>( qCeil(1000.0f * 2.0f / m_selectedClip->getMedia()->source()->fps() ) );
m_sourceRenderer->setTime( m_sourceRenderer->time() - interval );
......
......@@ -39,7 +39,7 @@ public:
explicit ClipRenderer();
virtual ~ClipRenderer();
virtual void togglePlayPause( bool forcePause );
virtual void togglePlayPause();
virtual void stop();
virtual void setVolume( int volume );
virtual int getVolume() const;
......
......@@ -73,15 +73,13 @@ public:
* This method is renderer dependant. It has to be implemented in the
* underlying renderer implementation.
* When this method is called :
* - if the render has not started and forcePause is false, the render is started
* - if the render has not started and forcePause is true, nothing happens.
* - if the render has not started the render is started
* - if the render has started and is not paused, the render will pause
* - if the render has started, and is paused, the render will unpause if
* forcePause is false.
* - if the render has started and is paused, the render will unpause
* \param forcePause Will force the pause if true.
* \sa stop()
*/
virtual void togglePlayPause( bool forcePause = false ) = 0;
virtual void togglePlayPause() = 0;
/**
* \brief Render the next frame
......
......@@ -247,32 +247,12 @@ WorkflowRenderer::previousFrame()
}
void
WorkflowRenderer::togglePlayPause( bool forcePause )
WorkflowRenderer::togglePlayPause()
{
if ( m_isRendering == false && forcePause == false )
if ( m_isRendering == false )
startPreview();
else
internalPlayPause( forcePause );
}
void
WorkflowRenderer::internalPlayPause( bool forcePause )
{
//If force pause is true, we just ensure that this render is paused... no need to start it.
if ( m_isRendering == true )
{
if ( m_paused == true && forcePause == false )
{
m_paused = false;
}
else
{
if ( m_paused == false )
{
m_paused = true;
}
}
}
m_paused = !m_paused;
}
void
......
......@@ -81,7 +81,7 @@ class WorkflowRenderer : public GenericRenderer
* \warning Do NOT call this method from a constructor as it calls some
* virtual methods.
*/
virtual void togglePlayPause( bool forcePause );
virtual void togglePlayPause();
/**
* \brief Stop the mainworkflow, but not the renderer.
*
......@@ -140,11 +140,6 @@ class WorkflowRenderer : public GenericRenderer
void saveProject( QXmlStreamWriter &project ) const;
void loadProject( const QDomElement& project );
private:
/**
* \brief This is a subpart of the togglePlayPause( bool ) method
* \sa togglePlayPause( bool );
*/
void internalPlayPause( bool forcePause );
/**
* \brief This is a subpart of the togglePlayPause( bool ) method
*
......
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