[vlmc-devel] Renderers: Simplify play/pause
Hugo Beauzée-Luyssen
git at videolan.org
Mon Feb 24 20:09:43 CET 2014
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Feb 24 19:22:46 2014 +0200| [80bcdae820009cc3b63552e6e0619d69f1c5443c] | committer: Hugo Beauzée-Luyssen
Renderers: Simplify play/pause
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=80bcdae820009cc3b63552e6e0619d69f1c5443c
---
src/Renderer/ClipRenderer.cpp | 23 +++++++----------------
src/Renderer/ClipRenderer.h | 2 +-
src/Renderer/GenericRenderer.h | 8 +++-----
src/Renderer/WorkflowRenderer.cpp | 26 +++-----------------------
src/Renderer/WorkflowRenderer.h | 7 +------
5 files changed, 15 insertions(+), 51 deletions(-)
diff --git a/src/Renderer/ClipRenderer.cpp b/src/Renderer/ClipRenderer.cpp
index 45a601e..b1e114d 100644
--- a/src/Renderer/ClipRenderer.cpp
+++ b/src/Renderer/ClipRenderer.cpp
@@ -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 );
diff --git a/src/Renderer/ClipRenderer.h b/src/Renderer/ClipRenderer.h
index cc3241a..90f9b10 100644
--- a/src/Renderer/ClipRenderer.h
+++ b/src/Renderer/ClipRenderer.h
@@ -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;
diff --git a/src/Renderer/GenericRenderer.h b/src/Renderer/GenericRenderer.h
index 4bec740..75291d3 100644
--- a/src/Renderer/GenericRenderer.h
+++ b/src/Renderer/GenericRenderer.h
@@ -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
diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index 0d8c670..dd8411f 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -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
diff --git a/src/Renderer/WorkflowRenderer.h b/src/Renderer/WorkflowRenderer.h
index 5711b6d..fc51d19 100644
--- a/src/Renderer/WorkflowRenderer.h
+++ b/src/Renderer/WorkflowRenderer.h
@@ -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.
*
@@ -142,11 +142,6 @@ class WorkflowRenderer : public GenericRenderer
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
*
* It starts the render by launching the media player that will query the
* lock and unlock callbacks, thus querying the MainWorkflow for frames and
More information about the Vlmc-devel
mailing list