Commit 2f4fa4fd authored by Alexandre Lision's avatar Alexandre Lision Committed by Guillaume Roguez
Browse files

video: resynchronize start and stop render signals

make sure start and stop decoding are always fired to the client in the same
than the daemon as fired them.

Refs #70681

(cherry picked from commit 60706c02)
parent d83bcfcf
......@@ -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;
}
......
#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);
});
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment