diff --git a/src/private/videorenderermanager.cpp b/src/private/videorenderermanager.cpp index 309beb52f7a5410a26da006a3c5f9bd6d6b1b113..f054cb214956facf15615ba44f5fd82269478408 100644 --- a/src/private/videorenderermanager.cpp +++ b/src/private/videorenderermanager.cpp @@ -36,7 +36,6 @@ #include <video/resolution.h> #include "private/videorate_p.h" #include "private/call_p.h" -#include "private/videorenderer_p.h" #ifdef ENABLE_LIBWRAP #include "private/directrenderer.h" @@ -205,6 +204,7 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri r = new Video::DirectRenderer(rid, res); qWarning() << "Calling registerFrameListener"; + m_hRenderers[rid] = r; DBus::VideoManager::instance().registerSinkTarget(id, [this, id, width, height] (const unsigned char* frame) { static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame( @@ -215,10 +215,10 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri #else //ENABLE_LIBWRAP r = new Video::ShmRenderer(rid,shmPath,res); + m_hRenderers[rid] = r; #endif - m_hRenderers[rid] = r; QThread* t = new QThread(this); m_hThreads[r] = t; @@ -280,7 +280,7 @@ void VideoRendererManagerPrivate::stoppedDecoding(const QString& id, const QStri //Quit if for some reasons the renderer is not found if ( !r ) { - qWarning() << "Cannot stop renrering, renderer" << id << "not found"; + qWarning() << "Cannot stop rendering, renderer" << id << "not found"; return; } diff --git a/src/qtwrapper/videomanager_wrap.cpp b/src/qtwrapper/videomanager_wrap.cpp index 6cd758caf7873ca684d78a275eb85efdf062e6db..aede8dcb3e173323fc774118e98aa2d50145e927 100644 --- a/src/qtwrapper/videomanager_wrap.cpp +++ b/src/qtwrapper/videomanager_wrap.cpp @@ -1,4 +1,22 @@ -#include "videomanager_wrap.h" +/****************************************************************************** + * Copyright (C) 2014 by Savoir-Faire Linux * + * Author : Philippe Groarke <philippe.groarke@savoirfairelinux.com> * + * Author : Alexandre Lision <alexandre.lision@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the Lesser GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + *****************************************************************************/ + #include "videomanager_wrap.h" VideoManagerInterface::VideoManagerInterface() { @@ -36,7 +54,8 @@ VideoManagerInterface::~VideoManagerInterface() } -VideoManagerSignalProxy::VideoManagerSignalProxy(VideoManagerInterface* parent) : QObject(parent), m_pParent(parent) +VideoManagerSignalProxy::VideoManagerSignalProxy(VideoManagerInterface* parent) : QObject(parent), +m_pParent(parent), m_pSem(new QSemaphore(3)) {} void VideoManagerSignalProxy::slotDeviceEvent() @@ -49,13 +68,21 @@ void VideoManagerSignalProxy::slotDeviceEvent() void VideoManagerSignalProxy::slotStartedDecoding(const QString &id, const QString &shmPath, int width, int height, bool isMixer) { QTimer::singleShot(0, [=] { - emit m_pParent->startedDecoding(id,shmPath,width,height,isMixer); + if(m_pSem->available() == 3) + emit m_pParent->startedDecoding(id,shmPath,width,height,isMixer); + else { + QTimer::singleShot(0, [=] { + slotStartedDecoding(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 e1056c0922f1c84210e07892add8c9498868b859..622921c7a506adcd0cbc5aaec2e5dd77cf13c10a 100644 --- a/src/qtwrapper/videomanager_wrap.h +++ b/src/qtwrapper/videomanager_wrap.h @@ -29,17 +29,20 @@ #include <QtCore/QThread> #include <QtCore/QList> #include <QtCore/QMap> +#include <QtCore/QSemaphore> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QVariant> #include <QtCore/QTimer> +// Ring #include <videomanager_interface.h> #include "typedefs.h" #include "conversions_wrap.hpp" class VideoManagerInterface; +class QSemaphore; class VideoManagerSignalProxy : public QObject { @@ -54,6 +57,7 @@ public Q_SLOTS: private: VideoManagerInterface* m_pParent; + QSemaphore* m_pSem; }; class VideoManagerProxySender : public QObject