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