Skip to content
Snippets Groups Projects
Commit 6bafbf16 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

video: Fix nullptr dereference

Refs #69012
parent 839d7af8
Branches
Tags
No related merge requests found
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "private/shmrenderer.h" #include "private/shmrenderer.h"
#endif #endif
constexpr static const char LOCAL_DEVICE[] = "local";
//Static member //Static member
VideoRendererManager* VideoRendererManager::m_spInstance = nullptr; VideoRendererManager* VideoRendererManager::m_spInstance = nullptr;
...@@ -108,26 +109,32 @@ Video::Renderer* VideoRendererManager::getRenderer(const Call* call) const ...@@ -108,26 +109,32 @@ Video::Renderer* VideoRendererManager::getRenderer(const Call* call) const
///Get the video preview Renderer ///Get the video preview Renderer
Video::Renderer* VideoRendererManager::previewRenderer() Video::Renderer* VideoRendererManager::previewRenderer()
{ {
if (!d_ptr->m_lRenderers["local"]) { if (!d_ptr->m_lRenderers[LOCAL_DEVICE]) {
if ((!Video::DeviceModel::instance()->activeDevice()) || (!Video::DeviceModel::instance()->activeDevice()->activeChannel())) {
qWarning() << "No device found";
return nullptr;
}
Video::Resolution* res = Video::DeviceModel::instance()->activeDevice()->activeChannel()->activeResolution(); Video::Resolution* res = Video::DeviceModel::instance()->activeDevice()->activeChannel()->activeResolution();
if (!res) { if (!res) {
qWarning() << "Misconfigured video device"; qWarning() << "Misconfigured video device";
return nullptr; return nullptr;
} }
#if defined(Q_OS_DARWIN)
d_ptr->m_lRenderers["local"] = new Video::DirectRenderer("local", res->size());
#if defined(Q_OS_DARWIN)
d_ptr->m_lRenderers[LOCAL_DEVICE] = new Video::DirectRenderer(LOCAL_DEVICE, res->size());
#else #else
d_ptr->m_lRenderers["local"] = new Video::ShmRenderer("local","",res->size()); d_ptr->m_lRenderers[LOCAL_DEVICE] = new Video::ShmRenderer(LOCAL_DEVICE,"",res->size());
#endif #endif
} }
return d_ptr->m_lRenderers["local"]; return d_ptr->m_lRenderers[LOCAL_DEVICE];
} }
///Stop video preview ///Stop video preview
void VideoRendererManager::stopPreview() void VideoRendererManager::stopPreview()
{ {
//d_ptr->stoppedDecoding("local",""); //d_ptr->stoppedDecoding(LOCAL_DEVICE,"");
VideoManagerInterface& interface = DBus::VideoManager::instance(); VideoManagerInterface& interface = DBus::VideoManager::instance();
interface.stopCamera(); interface.stopCamera();
d_ptr->m_PreviewState = false; d_ptr->m_PreviewState = false;
...@@ -136,8 +143,7 @@ void VideoRendererManager::stopPreview() ...@@ -136,8 +143,7 @@ void VideoRendererManager::stopPreview()
///Start video preview ///Start video preview
void VideoRendererManager::startPreview() void VideoRendererManager::startPreview()
{ {
qWarning() << "STARTING PREVIEW"; // d_ptr->startedDecoding(LOCAL_DEVICE,"",500,500);
// d_ptr->startedDecoding("local","",500,500);
if (d_ptr->m_PreviewState) return; if (d_ptr->m_PreviewState) return;
VideoManagerInterface& interface = DBus::VideoManager::instance(); VideoManagerInterface& interface = DBus::VideoManager::instance();
...@@ -204,7 +210,7 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -204,7 +210,7 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
if (dev) { if (dev) {
emit dev->renderingStarted(m_lRenderers[rid]); emit dev->renderingStarted(m_lRenderers[rid]);
} }
if (id != "local") { if (id != LOCAL_DEVICE) {
qDebug() << "Starting video for call" << id; qDebug() << "Starting video for call" << id;
Call* c = CallModel::instance()->getCall(id); Call* c = CallModel::instance()->getCall(id);
if (c) if (c)
...@@ -232,7 +238,7 @@ void VideoRendererManagerPrivate::stoppedDecoding(const QString& id, const QStri ...@@ -232,7 +238,7 @@ void VideoRendererManagerPrivate::stoppedDecoding(const QString& id, const QStri
if (dev) { if (dev) {
emit dev->renderingStopped(r); emit dev->renderingStopped(r);
} }
if (id == "local") { if (id == LOCAL_DEVICE) {
m_PreviewState = false; m_PreviewState = false;
emit q_ptr->previewStateChanged(false); emit q_ptr->previewStateChanged(false);
emit q_ptr->previewStopped(r); emit q_ptr->previewStopped(r);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment