diff --git a/src/account.cpp b/src/account.cpp index 67b17a3a56745503584eb39d473110d9f7fdad8d..ea70795f7a96dc7b9451250a9a3264435eb90bb9 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -1067,7 +1067,7 @@ void Account::save() m_CurrentState = READY; } #ifdef ENABLE_VIDEO - m_pVideoCodecs->save(); + videoCodecModel()->save(); #endif saveAudioCodecs(); emit changed(this); diff --git a/src/videomodel.cpp b/src/videomodel.cpp index 7c9344809e7be76639cdaea618a50b647d69b2d0..75ee6a97437f5199fdc63c13c56d04747dcc33a4 100644 --- a/src/videomodel.cpp +++ b/src/videomodel.cpp @@ -28,7 +28,7 @@ VideoModel* VideoModel::m_spInstance = nullptr; ///Constructor -VideoModel::VideoModel():QThread(),m_BufferSize(0),m_ShmKey(0),m_SemKey(0),m_PreviewState(false) +VideoModel::VideoModel():QObject(),m_BufferSize(0),m_ShmKey(0),m_SemKey(0),m_PreviewState(false),m_Thread(this) { VideoInterface& interface = DBus::VideoManager::instance(); connect( &interface , SIGNAL(deviceEvent()) , this, SLOT(deviceEvent()) ); @@ -104,15 +104,15 @@ void VideoModel::startedDecoding(const QString& id, const QString& shmPath, int if (m_lRenderers[id] == nullptr ) { m_lRenderers[id] = new VideoRenderer(id,shmPath,Resolution(width,height)); - m_lRenderers[id]->moveToThread(this); - if (!isRunning()) - start(); + m_lRenderers[id]->moveToThread(&m_Thread); } else { VideoRenderer* renderer = m_lRenderers[id]; renderer->setShmPath(shmPath); renderer->setResolution(QSize(width,height)); } + if (!m_Thread.isRunning()) + m_Thread.start(); m_lRenderers[id]->startRendering(); if (id != "local") { @@ -127,15 +127,10 @@ void VideoModel::stoppedDecoding(const QString& id, const QString& shmPath) Q_UNUSED(shmPath) VideoRenderer* r = m_lRenderers[id]; if ( r ) { - r->mutex()->lock(); r->stopRendering(); - r->mutex()->unlock(); } + m_lRenderers[id] = nullptr; + delete r; qDebug() << "Video stopped for call" << id << "Renderer found:" << (m_lRenderers[id] != nullptr); emit videoStopped(); } - -void VideoModel::run() -{ - exec(); -} diff --git a/src/videomodel.h b/src/videomodel.h index d6fe21b330efff22ec88a426de7e69ebeebcaa9b..9dd62132a62defca9a1573313db5fd027a8ff135 100644 --- a/src/videomodel.h +++ b/src/videomodel.h @@ -31,7 +31,7 @@ class Call; struct SHMHeader; ///VideoModel: Video event dispatcher -class LIB_EXPORT VideoModel : public QThread { +class LIB_EXPORT VideoModel : public QObject { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT @@ -48,9 +48,6 @@ public: //Setters void setBufferSize(uint size); -protected: - void run(); - private: //Constructor VideoModel(); @@ -63,6 +60,7 @@ private: uint m_BufferSize ; uint m_ShmKey ; uint m_SemKey ; + QThread m_Thread ; QHash<QString,VideoRenderer*> m_lRenderers; public Q_SLOTS: diff --git a/src/videorenderer.cpp b/src/videorenderer.cpp index d7a93e0804bccaefccc876e43c56a0bd51de42eb..85b470cb687f4e3b7c41f8595222c01a3b0a7549 100644 --- a/src/videorenderer.cpp +++ b/src/videorenderer.cpp @@ -244,7 +244,6 @@ timespec VideoRenderer::createTimeout() void VideoRenderer::timedEvents() { bool ok = true; - sync(); m_pMutex->lock(); renderToBitmap(m_Frame,ok); m_pMutex->unlock(); @@ -260,6 +259,7 @@ void VideoRenderer::timedEvents() ///Start the rendering loop void VideoRenderer::startRendering() { + QMutexLocker locker(m_pMutex); startShm(); if (!m_pTimer) { m_pTimer = new QTimer(this); @@ -273,6 +273,7 @@ void VideoRenderer::startRendering() ///Stop the rendering loop void VideoRenderer::stopRendering() { + QMutexLocker locker(m_pMutex); m_isRendering = false; qDebug() << "Stopping rendering on" << m_Id; if (m_pTimer)