From 0cbecf88fb4b3e71b8b31ec519f7e614da1d89be Mon Sep 17 00:00:00 2001
From: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
Date: Fri, 2 Oct 2015 10:50:46 -0400
Subject: [PATCH] video: fix deadlock

stopDecoding was blocking when making a conference because no semaphore were
available. Semaphore shouldn't have been placed here in the first place

Issue: #81116
Change-Id: Ia686601f40c430ba716c91b2667268e4fb108446
---
 src/qtwrapper/videomanager_wrap.cpp | 12 ++----------
 src/qtwrapper/videomanager_wrap.h   |  3 ---
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/src/qtwrapper/videomanager_wrap.cpp b/src/qtwrapper/videomanager_wrap.cpp
index aede8dcb..bde73ca2 100644
--- a/src/qtwrapper/videomanager_wrap.cpp
+++ b/src/qtwrapper/videomanager_wrap.cpp
@@ -55,7 +55,7 @@ VideoManagerInterface::~VideoManagerInterface()
 }
 
 VideoManagerSignalProxy::VideoManagerSignalProxy(VideoManagerInterface* parent) : QObject(parent),
-m_pParent(parent), m_pSem(new QSemaphore(3))
+m_pParent(parent)
 {}
 
 void VideoManagerSignalProxy::slotDeviceEvent()
@@ -68,21 +68,13 @@ void VideoManagerSignalProxy::slotDeviceEvent()
 void VideoManagerSignalProxy::slotStartedDecoding(const QString &id, const QString &shmPath, int width, int height, bool isMixer)
 {
     QTimer::singleShot(0, [=] {
-        if(m_pSem->available() == 3)
-            emit m_pParent->startedDecoding(id,shmPath,width,height,isMixer);
-        else {
-            QTimer::singleShot(0, [=] {
-                slotStartedDecoding(id,shmPath,width,height,isMixer);
-            });
-        }
+        emit m_pParent->startedDecoding(id,shmPath,width,height,isMixer);
     });
 }
 
 void VideoManagerSignalProxy::slotStoppedDecoding(const QString &id, const QString &shmPath, bool isMixer)
 {
-    m_pSem->acquire(1);
     QTimer::singleShot(0, [=] {
         emit m_pParent->stoppedDecoding(id,shmPath,isMixer);
-        m_pSem->release(1);
     });
 }
diff --git a/src/qtwrapper/videomanager_wrap.h b/src/qtwrapper/videomanager_wrap.h
index 1c00aee3..beeb720c 100644
--- a/src/qtwrapper/videomanager_wrap.h
+++ b/src/qtwrapper/videomanager_wrap.h
@@ -28,7 +28,6 @@
 #include <QtCore/QThread>
 #include <QtCore/QList>
 #include <QtCore/QMap>
-#include <QtCore/QSemaphore>
 #include <QtCore/QString>
 #include <QtCore/QStringList>
 #include <QtCore/QVariant>
@@ -41,7 +40,6 @@
 #include "conversions_wrap.hpp"
 
 class VideoManagerInterface;
-class QSemaphore;
 
 class VideoManagerSignalProxy : public QObject
 {
@@ -56,7 +54,6 @@ public Q_SLOTS:
 
 private:
    VideoManagerInterface* m_pParent;
-   QSemaphore*            m_pSem;
 };
 
 class VideoManagerProxySender : public QObject
-- 
GitLab