From 0d3f6c7ba101e9852c89d99b290fa7bfb12c2882 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Thu, 11 Aug 2016 07:13:11 +0200 Subject: [PATCH] =?UTF-8?q?made=20sure=20v4l=20code=20only=20initializes?= =?UTF-8?q?=20when=20needed=20and=20only=20errors=20when=20=E2=80=A6=20(#1?= =?UTF-8?q?62)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * made sure v4l code only initializes when needed and only errors when the module is enabled * fixed v4l2 as suggested by @redPanther --- src/hyperiond/hyperiond.cpp | 60 ++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index f88a79a4..dba8ff2f 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -536,38 +536,42 @@ void HyperionDaemon::createGrabberOsx(const QJsonObject & grabberConfig) void HyperionDaemon::createGrabberV4L2() { // construct and start the v4l2 grabber if the configuration is present -#ifdef ENABLE_V4L2 if (_qconfig.contains("grabber-v4l2")) { const QJsonObject & grabberConfig = _qconfig["grabber-v4l2"].toObject(); - _v4l2Grabber = new V4L2Wrapper( - grabberConfig["device"].toString("/dev/video0").toStdString(), - grabberConfig["input"].toInt(0), - parseVideoStandard(grabberConfig["standard"].toString("no-change").toStdString()), - parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change").toStdString()), - grabberConfig["width"].toInt(-1), - grabberConfig["height"].toInt(-1), - grabberConfig["frameDecimation"].toInt(2), - grabberConfig["sizeDecimation"].toInt(8), - grabberConfig["redSignalThreshold"].toDouble(0.0), - grabberConfig["greenSignalThreshold"].toDouble(0.0), - grabberConfig["blueSignalThreshold"].toDouble(0.0), - grabberConfig["priority"].toInt(890)); - _v4l2Grabber->set3D(parse3DMode(grabberConfig["mode"].toString("2D").toStdString())); - _v4l2Grabber->setCropping( - grabberConfig["cropLeft"].toInt(0), - grabberConfig["cropRight"].toInt(0), - grabberConfig["cropTop"].toInt(0), - grabberConfig["cropBottom"].toInt(0)); - Debug(_log, "V4L2 grabber created"); +#ifdef ENABLE_V4L2 + _v4l2Grabber = new V4L2Wrapper( + grabberConfig["device"].toString("/dev/video0").toStdString(), + grabberConfig["input"].toInt(0), + parseVideoStandard(grabberConfig["standard"].toString("no-change").toStdString()), + parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change").toStdString()), + grabberConfig["width"].toInt(-1), + grabberConfig["height"].toInt(-1), + grabberConfig["frameDecimation"].toInt(2), + grabberConfig["sizeDecimation"].toInt(8), + grabberConfig["redSignalThreshold"].toDouble(0.0), + grabberConfig["greenSignalThreshold"].toDouble(0.0), + grabberConfig["blueSignalThreshold"].toDouble(0.0), + grabberConfig["priority"].toInt(890)); + _v4l2Grabber->set3D(parse3DMode(grabberConfig["mode"].toString("2D").toStdString())); + _v4l2Grabber->setCropping( + grabberConfig["cropLeft"].toInt(0), + grabberConfig["cropRight"].toInt(0), + grabberConfig["cropTop"].toInt(0), + grabberConfig["cropBottom"].toInt(0)); + Debug(_log, "V4L2 grabber created"); - QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, const Image&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image&, const int)) ); - if (grabberConfig["enable"].toBool(true) && _v4l2Grabber->start()) - { - Info(_log, "V4L2 grabber started"); - } - } + QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, + const Image&, const int)), _protoServer, + SLOT(sendImageToProtoSlaves(int, + const Image&, const int))); + if (grabberConfig["enable"].toBool(true) && _v4l2Grabber->start()) { + Info(_log, "V4L2 grabber started"); + } #else - ErrorIf(_qconfig.contains("grabber-v4l2"), _log, "The v4l2 grabber can not be instantiated, because it has been left out from the build"); + if (grabberConfig["enable"].toBool(true)) { + Error(_log, "The v4l2 grabber can not be instantiated, because it has been left out from the build"); + } #endif + } }