[vlmc-devel] VLCVmemRenderer: Fix potential destruction of a locked mutex
Hugo Beauzée-Luyssen
git at videolan.org
Mon Feb 24 01:59:13 CET 2014
vlmc | branch: ibackend | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Feb 24 02:47:17 2014 +0200| [7526af1932b4107ed6a5838bbab7a265a5b15760] | committer: Hugo Beauzée-Luyssen
VLCVmemRenderer: Fix potential destruction of a locked mutex
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=7526af1932b4107ed6a5838bbab7a265a5b15760
---
src/Backend/VLC/VLCVmemRenderer.cpp | 11 +++++++++++
src/Backend/VLC/VLCVmemRenderer.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/src/Backend/VLC/VLCVmemRenderer.cpp b/src/Backend/VLC/VLCVmemRenderer.cpp
index a899751..a5aa90b 100644
--- a/src/Backend/VLC/VLCVmemRenderer.cpp
+++ b/src/Backend/VLC/VLCVmemRenderer.cpp
@@ -31,12 +31,22 @@ VmemRenderer::VmemRenderer( VLCBackend* backend, VLCSource *source , ISourceRend
: VLCSourceRenderer( backend, source, callback )
, m_snapshotRequired( false )
{
+ setName( "VmemRenderer" );
m_snapshot = new QImage( 320, 180, QImage::Format_RGB32 );
m_mediaPlayer->setupVmem( "RV32", m_snapshot->width(), m_snapshot->height(), m_snapshot->bytesPerLine() );
m_mediaPlayer->setupVmemCallbacks( &VmemRenderer::vmemLock, NULL, NULL, this );
m_mediaPlayer->setAudioOutput( "dummy" );
}
+VmemRenderer::~VmemRenderer()
+{
+ /*
+ * We need to stop the media player from here, otherwise m_mutex would be
+ * destroyed in a potentially locked state, while the vmem tries to lock/unlock.
+ */
+ stop();
+}
+
LibVLCpp::MediaPlayer*
VmemRenderer::mediaPlayer()
{
@@ -73,6 +83,7 @@ VmemRenderer::vmemUnlock(void *data, void *picture, void * const *planes)
VmemRenderer* self = reinterpret_cast<VmemRenderer*>( data );
if ( self->m_snapshotRequired == true )
{
+ self->m_snapshotRequired = false;
self->m_waitCond.wakeAll();
}
self->m_mutex.unlock();
diff --git a/src/Backend/VLC/VLCVmemRenderer.h b/src/Backend/VLC/VLCVmemRenderer.h
index 020923b..cfb161d 100644
--- a/src/Backend/VLC/VLCVmemRenderer.h
+++ b/src/Backend/VLC/VLCVmemRenderer.h
@@ -38,6 +38,7 @@ class VmemRenderer : public VLCSourceRenderer
{
public:
VmemRenderer(VLCBackend *backend, VLCSource* source, ISourceRendererEventCb* callback );
+ virtual ~VmemRenderer();
LibVLCpp::MediaPlayer* mediaPlayer();
/**
* @brief waitSnapshot Wait for a snapshot to be computed and returns it.
More information about the Vlmc-devel
mailing list