[vlmc-devel] commit: ClipWorkflow: Fixing a race condition when stopping the clip. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Fri Jun 11 14:02:32 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri Jun 11 13:51:03 2010 +0200| [7a38171d1c9f27ee8191d1745dc198b85ab1c18a] | committer: Hugo Beauzée-Luyssen
ClipWorkflow: Fixing a race condition when stopping the clip.
At some point, a clip could be stopped by two differents threads : the
gui thread, due to the clip's EndReached signal, and the renderer thread, that
would have stopped the entire render, due to the Workflow's EndReached
signal
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=7a38171d1c9f27ee8191d1745dc198b85ab1c18a
---
src/Workflow/ClipWorkflow.cpp | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/Workflow/ClipWorkflow.cpp b/src/Workflow/ClipWorkflow.cpp
index 51e30e0..b2b4219 100644
--- a/src/Workflow/ClipWorkflow.cpp
+++ b/src/Workflow/ClipWorkflow.cpp
@@ -121,9 +121,15 @@ ClipWorkflow::stop()
void
ClipWorkflow::stopRenderer()
{
- if ( m_mediaPlayer )
+ QWriteLocker lockState( m_stateLock );
+
+ //Let's make sure the ClipWorkflow isn't beeing stopped from another thread.
+ if ( m_mediaPlayer &&
+ m_state != Stopping && m_state != Stopped )
{
- setState( Stopping );
+ //Set a specific state to avoid operation (getOutput beeing called actually, as it
+ //would freeze the render waiting for a frame) while the stopping process occurs.
+ m_state = Stopping;
{
QMutexLocker lock( m_initWaitCond->getMutex() );
m_initWaitCond->wake();
@@ -133,11 +139,11 @@ ClipWorkflow::stopRenderer()
m_renderWaitCond->wakeAll();
}
m_mediaPlayer->stop();
- disconnect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ) );
+ m_mediaPlayer->disconnect();
MemoryPool<LibVLCpp::MediaPlayer>::getInstance()->release( m_mediaPlayer );
m_mediaPlayer = NULL;
delete m_vlcMedia;
- setState( Stopped );
+ m_state = Stopped;
}
}
More information about the Vlmc-devel
mailing list