mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Gold linker, CCache, Stats, LGTM
- Increases linker performance under Linux builds by using Gold linker, if available - ccache is used if available - removed statistic class (Stats.cpp) from project due to the missing result (sorry @Brindosch) - add LGTM bandges for code analysis overview Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
#include <hyperion/GrabberWrapper.h>
|
||||
#include <utils/Process.h>
|
||||
#include <utils/JsonUtils.h>
|
||||
#include <utils/Stats.h>
|
||||
|
||||
// bonjour wrapper
|
||||
#include <bonjour/bonjourbrowserwrapper.h>
|
||||
@@ -1052,7 +1051,7 @@ void JsonAPI::setImage(const Image<ColorRgb> & image)
|
||||
}
|
||||
}
|
||||
|
||||
void JsonAPI::incommingLogMessage(Logger::T_LOG_MESSAGE msg)
|
||||
void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
{
|
||||
QJsonObject result, message;
|
||||
QJsonArray messageArray;
|
||||
|
@@ -34,7 +34,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <utils/Logger.h>
|
||||
#include <HyperionConfig.h>
|
||||
#include <utils/Stats.h>
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
BonjourServiceRegister::BonjourServiceRegister(QObject *parent)
|
||||
: QObject(parent), dnssref(0), bonjourSocket(0)
|
||||
|
@@ -48,12 +48,12 @@ EffectEngine::~EffectEngine()
|
||||
{
|
||||
}
|
||||
|
||||
const bool EffectEngine::saveEffect(const QJsonObject& obj, QString& resultMsg)
|
||||
bool EffectEngine::saveEffect(const QJsonObject& obj, QString& resultMsg)
|
||||
{
|
||||
return _effectFileHandler->saveEffect(obj, resultMsg);
|
||||
}
|
||||
|
||||
const bool EffectEngine::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
bool EffectEngine::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
{
|
||||
return _effectFileHandler->deleteEffect(effectName, resultMsg);
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ void EffectFileHandler::handleSettingsUpdate(const settings::type& type, const Q
|
||||
}
|
||||
}
|
||||
|
||||
const bool EffectFileHandler::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
bool EffectFileHandler::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
{
|
||||
std::list<EffectDefinition> effectsDefinition = getEffects();
|
||||
std::list<EffectDefinition>::iterator it = std::find_if(effectsDefinition.begin(), effectsDefinition.end(), find_effect(effectName));
|
||||
@@ -95,7 +95,7 @@ const bool EffectFileHandler::deleteEffect(const QString& effectName, QString& r
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool EffectFileHandler::saveEffect(const QJsonObject& message, QString& resultMsg)
|
||||
bool EffectFileHandler::saveEffect(const QJsonObject& message, QString& resultMsg)
|
||||
{
|
||||
if (!message["args"].toObject().isEmpty())
|
||||
{
|
||||
|
@@ -138,9 +138,9 @@ void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image)
|
||||
return;
|
||||
}
|
||||
|
||||
Image<ColorRgb> image(width, height);
|
||||
memmove(image.memptr(), imageData->data(), imageData->size());
|
||||
_hyperion->setInputImage(_priority, image, duration);
|
||||
Image<ColorRgb> imageDest(width, height);
|
||||
memmove(imageDest.memptr(), imageData->data(), imageData->size());
|
||||
_hyperion->setInputImage(_priority, imageDest, duration);
|
||||
}
|
||||
|
||||
// send reply
|
||||
|
@@ -41,7 +41,7 @@ void QtGrabber::freeResources()
|
||||
}
|
||||
}
|
||||
|
||||
const bool QtGrabber::setupDisplay()
|
||||
bool QtGrabber::setupDisplay()
|
||||
{
|
||||
// cleanup last screen
|
||||
freeResources();
|
||||
@@ -105,7 +105,7 @@ int QtGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
QPixmap originalPixmap = _screen->grabWindow(0, _src_x, _src_y, _src_x_max, _src_y_max);
|
||||
QPixmap resizedPixmap = originalPixmap.scaled(_width,_height);
|
||||
QImage img = resizedPixmap.toImage().convertToFormat( QImage::Format_RGB888);
|
||||
memcpy(image.memptr(), img.bits(),_width*_height*3);
|
||||
memcpy(image.memptr(), img.bits(),(size_t) _width*_height*3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ void X11Grabber::setupResources()
|
||||
if(_XShmAvailable)
|
||||
{
|
||||
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _windowAttr.depth, ZPixmap, NULL, &_shminfo, _width, _height);
|
||||
_shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
|
||||
_shminfo.shmid = shmget(IPC_PRIVATE, (size_t) _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
|
||||
_xImage->data = (char*)shmat(_shminfo.shmid,0,0);
|
||||
_shminfo.shmaddr = _xImage->data;
|
||||
_shminfo.readOnly = False;
|
||||
|
@@ -14,8 +14,8 @@ Grabber::Grabber(QString grabberName, int width, int height, int cropLeft, int c
|
||||
, _enabled(true)
|
||||
, _log(Logger::getInstance(grabberName))
|
||||
{
|
||||
setVideoMode(VIDEO_2D);
|
||||
setCropping(cropLeft, cropRight, cropTop, cropBottom);
|
||||
Grabber::setVideoMode(VIDEO_2D);
|
||||
Grabber::setCropping(cropLeft, cropRight, cropTop, cropBottom);
|
||||
}
|
||||
|
||||
Grabber::~Grabber()
|
||||
|
@@ -32,7 +32,7 @@ GrabberWrapper::GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned
|
||||
|
||||
GrabberWrapper::~GrabberWrapper()
|
||||
{
|
||||
stop();
|
||||
GrabberWrapper::stop(); // TODO Is this right????????
|
||||
Debug(_log,"Close grabber: %s", QSTRING_CSTR(_grabberName));
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QHostInfo>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
// hyperion include
|
||||
#include <hyperion/Hyperion.h>
|
||||
@@ -161,6 +162,9 @@ Hyperion::Hyperion(HyperionDaemon* daemon, const quint8& instance, const QString
|
||||
// boblight, can't live in global scope as it depends on layout
|
||||
_boblightServer = new BoblightServer(this, getSetting(settings::BOBLSERVER));
|
||||
connect(this, &Hyperion::settingsChanged, _boblightServer, &BoblightServer::handleSettingsUpdate);
|
||||
|
||||
// set unique id
|
||||
_id = QString(QCryptographicHash::hash(getConfigFileName().toLocal8Bit(),QCryptographicHash::Sha1).toHex());
|
||||
}
|
||||
|
||||
Hyperion::~Hyperion()
|
||||
@@ -376,7 +380,7 @@ void Hyperion::registerInput(const int priority, const hyperion::Components& com
|
||||
_muxer.registerInput(priority, component, origin, owner, smooth_cfg);
|
||||
}
|
||||
|
||||
const bool Hyperion::setInput(const int priority, const std::vector<ColorRgb>& ledColors, int timeout_ms, const bool& clearEffect)
|
||||
bool Hyperion::setInput(const int priority, const std::vector<ColorRgb>& ledColors, int timeout_ms, const bool& clearEffect)
|
||||
{
|
||||
if(_muxer.setInput(priority, ledColors, timeout_ms))
|
||||
{
|
||||
@@ -393,7 +397,7 @@ const bool Hyperion::setInput(const int priority, const std::vector<ColorRgb>& l
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool Hyperion::setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms, const bool& clearEffect)
|
||||
bool Hyperion::setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms, const bool& clearEffect)
|
||||
{
|
||||
if(_muxer.setInputImage(priority, image, timeout_ms))
|
||||
{
|
||||
@@ -410,7 +414,7 @@ const bool Hyperion::setInputImage(const int priority, const Image<ColorRgb>& im
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool Hyperion::setInputInactive(const quint8& priority)
|
||||
bool Hyperion::setInputInactive(const quint8& priority)
|
||||
{
|
||||
return _muxer.setInputInactive(priority);
|
||||
}
|
||||
@@ -447,7 +451,7 @@ void Hyperion::adjustmentsUpdated()
|
||||
update();
|
||||
}
|
||||
|
||||
const bool Hyperion::clear(int priority)
|
||||
bool Hyperion::clear(int priority)
|
||||
{
|
||||
// send clear signal to the effect engine
|
||||
// (outside the check so the effect gets cleared even when the effect is not sending colors)
|
||||
@@ -487,12 +491,12 @@ const Hyperion::InputInfo Hyperion::getPriorityInfo(const int priority) const
|
||||
return _muxer.getInputInfo(priority);
|
||||
}
|
||||
|
||||
const bool Hyperion::saveEffect(const QJsonObject& obj, QString& resultMsg)
|
||||
bool Hyperion::saveEffect(const QJsonObject& obj, QString& resultMsg)
|
||||
{
|
||||
return _effectEngine->saveEffect(obj, resultMsg);
|
||||
}
|
||||
|
||||
const bool Hyperion::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
bool Hyperion::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
{
|
||||
return _effectEngine->deleteEffect(effectName, resultMsg);
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ ImageToLedsMap::ImageToLedsMap(
|
||||
const auto maxXLedCount = qMin(maxX_idx, xOffset+actualWidth);
|
||||
|
||||
std::vector<unsigned> ledColors;
|
||||
ledColors.reserve(maxXLedCount*maxYLedCount);
|
||||
ledColors.reserve((size_t) maxXLedCount*maxYLedCount);
|
||||
|
||||
for (unsigned y = minY_idx; y < maxYLedCount; ++y)
|
||||
{
|
||||
|
@@ -157,7 +157,7 @@ void PriorityMuxer::registerInput(const int priority, const hyperion::Components
|
||||
}
|
||||
}
|
||||
|
||||
const bool PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& ledColors, int64_t timeout_ms)
|
||||
bool PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& ledColors, int64_t timeout_ms)
|
||||
{
|
||||
if(!_activeInputs.contains(priority))
|
||||
{
|
||||
@@ -196,7 +196,7 @@ const bool PriorityMuxer::setInput(const int priority, const std::vector<ColorRg
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool PriorityMuxer::setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms)
|
||||
bool PriorityMuxer::setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms)
|
||||
{
|
||||
if(!_activeInputs.contains(priority))
|
||||
{
|
||||
@@ -235,13 +235,13 @@ const bool PriorityMuxer::setInputImage(const int priority, const Image<ColorRgb
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool PriorityMuxer::setInputInactive(const quint8& priority)
|
||||
bool PriorityMuxer::setInputInactive(const quint8& priority)
|
||||
{
|
||||
Image<ColorRgb> image;
|
||||
return setInputImage(priority, image, -100);
|
||||
}
|
||||
|
||||
const bool PriorityMuxer::clearInput(const uint8_t priority)
|
||||
bool PriorityMuxer::clearInput(const uint8_t priority)
|
||||
{
|
||||
if (priority < PriorityMuxer::LOWEST_PRIORITY && _activeInputs.remove(priority))
|
||||
{
|
||||
|
@@ -142,7 +142,7 @@ const QJsonDocument SettingsManager::getSetting(const settings::type& type)
|
||||
return QJsonDocument(_qconfig[key].toArray());
|
||||
}
|
||||
|
||||
const bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
|
||||
bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
|
||||
{
|
||||
// we need to validate data against schema
|
||||
QJsonSchemaChecker schemaChecker;
|
||||
|
@@ -53,7 +53,7 @@ bool ProviderUdp::init(const QJsonObject &deviceConfig)
|
||||
}
|
||||
|
||||
_port = deviceConfig["port"].toInt(_port);
|
||||
if ( _port<=0 || _port > 65535)
|
||||
if ( (_port <= 0) || (_port > 65535) )
|
||||
{
|
||||
throw std::runtime_error("invalid target port");
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ void SSDPServer::initServer()
|
||||
connect(_udpSocket, &QUdpSocket::readyRead, this, &SSDPServer::readPendingDatagrams);
|
||||
}
|
||||
|
||||
const bool SSDPServer::start()
|
||||
bool SSDPServer::start()
|
||||
{
|
||||
if(!_running && _udpSocket->bind(QHostAddress::AnyIPv4, SSDP_PORT, QAbstractSocket::ShareAddress))
|
||||
{
|
||||
|
@@ -164,7 +164,7 @@ LoggerManager::LoggerManager()
|
||||
{
|
||||
}
|
||||
|
||||
void LoggerManager::handleNewLogMessage(Logger::T_LOG_MESSAGE msg)
|
||||
void LoggerManager::handleNewLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
{
|
||||
_logMessageBuffer.append(msg);
|
||||
if (_logMessageBuffer.length() > _loggerMaxMsgBufferSize)
|
||||
|
@@ -1,164 +0,0 @@
|
||||
#include <utils/Stats.h>
|
||||
#include <utils/SysInfo.h>
|
||||
#include <HyperionConfig.h>
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
// qt includes
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QNetworkInterface>
|
||||
#include <QCryptographicHash>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDateTime>
|
||||
|
||||
Stats* Stats::instance = nullptr;
|
||||
|
||||
Stats::Stats(const QJsonObject& config)
|
||||
: QObject()
|
||||
, _log(Logger::getInstance("STATS"))
|
||||
, _hyperion(Hyperion::getInstance())
|
||||
{
|
||||
Stats::instance = this;
|
||||
|
||||
// generate hash
|
||||
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
||||
{
|
||||
if (!(interface.flags() & QNetworkInterface::IsLoopBack))
|
||||
{
|
||||
_hyperion->setId(QString(QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit().append(_hyperion->getConfigFileName().toLocal8Bit()),QCryptographicHash::Sha1).toHex()));
|
||||
_hash = QString(QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit(),QCryptographicHash::Sha1).toHex());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// stop reporting if not found
|
||||
if(_hash.isEmpty())
|
||||
{
|
||||
Warning(_log, "No interface found, abort");
|
||||
// fallback id
|
||||
_hyperion->setId(QString(QCryptographicHash::hash(_hyperion->getConfigFileName().toLocal8Bit(),QCryptographicHash::Sha1).toHex()));
|
||||
return;
|
||||
}
|
||||
|
||||
// prep data
|
||||
handleDataUpdate(config);
|
||||
|
||||
// QNetworkRequest Header
|
||||
_req.setRawHeader("Content-Type", "application/json");
|
||||
_req.setRawHeader("Authorization", "Basic SHlwZXJpb25YbDQ5MlZrcXA6ZDQxZDhjZDk4ZjAwYjIw");
|
||||
|
||||
connect(&_mgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(resolveReply(QNetworkReply*)));
|
||||
|
||||
// 7 days interval
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(sendHTTP()));
|
||||
timer->start(604800000);
|
||||
|
||||
// delay initial check
|
||||
QTimer::singleShot(60000, this, SLOT(initialExec()));
|
||||
}
|
||||
|
||||
Stats::~Stats()
|
||||
{
|
||||
}
|
||||
|
||||
void Stats::handleDataUpdate(const QJsonObject& config)
|
||||
{
|
||||
// prepare content
|
||||
SysInfo::HyperionSysInfo data = SysInfo::get();
|
||||
|
||||
QJsonObject system;
|
||||
system["kType" ] = data.kernelType;
|
||||
system["arch" ] = data.architecture;
|
||||
system["pType" ] = data.productType;
|
||||
system["pVersion" ] = data.productVersion;
|
||||
system["pName" ] = data.prettyName;
|
||||
system["version" ] = QString(HYPERION_VERSION);
|
||||
system["device" ] = Hyperion::getInstance()->getActiveDevice();
|
||||
system["id" ] = _hyperion->getId();
|
||||
system["hw_id" ] = _hash;
|
||||
system["ledCount" ] = QString::number(Hyperion::getInstance()->getLedCount());
|
||||
system["comp_sm" ] = config["smoothing"].toObject().take("enable");
|
||||
system["comp_bb" ] = config["blackborderdetector"].toObject().take("enable");
|
||||
system["comp_fw" ] = config["forwarder"].toObject().take("enable");
|
||||
system["comp_udpl" ] = config["udpListener"].toObject().take("enable");
|
||||
system["comp_bobl" ] = config["boblightServer"].toObject().take("enable");
|
||||
system["comp_pc" ] = config["framegrabber"].toObject().take("enable");
|
||||
system["comp_uc" ] = config["grabberV4L2"].toArray().at(0).toObject().take("enable");
|
||||
|
||||
QJsonDocument doc(system);
|
||||
_ba = doc.toJson();
|
||||
}
|
||||
|
||||
void Stats::initialExec()
|
||||
{
|
||||
if(trigger())
|
||||
{
|
||||
QTimer::singleShot(0,this, SLOT(sendHTTP()));
|
||||
}
|
||||
}
|
||||
|
||||
void Stats::sendHTTP()
|
||||
{
|
||||
_req.setUrl(QUrl("https://api.hyperion-project.org/api/stats"));
|
||||
_mgr.post(_req,_ba);
|
||||
}
|
||||
|
||||
void Stats::sendHTTPp()
|
||||
{
|
||||
_req.setUrl(QUrl("https://api.hyperion-project.org/api/stats/"+_hyperion->getId()));
|
||||
_mgr.put(_req,_ba);
|
||||
}
|
||||
|
||||
void Stats::resolveReply(QNetworkReply *reply)
|
||||
{
|
||||
if (reply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
// update file timestamp
|
||||
trigger(true);
|
||||
// already created, update entry
|
||||
if(reply->readAll().startsWith("null"))
|
||||
{
|
||||
QTimer::singleShot(0, this, SLOT(sendHTTPp()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Stats::trigger(bool set)
|
||||
{
|
||||
QString path = _hyperion->getRootPath()+"/misc/";
|
||||
QDir dir;
|
||||
QFile file(path + _hyperion->getId());
|
||||
|
||||
if(set && file.open(QIODevice::ReadWrite) )
|
||||
{
|
||||
QTextStream stream( &file );
|
||||
stream << "DO NOT DELETE" << endl;
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!dir.exists(path))
|
||||
{
|
||||
dir.mkpath(path);
|
||||
}
|
||||
if (!file.exists())
|
||||
{
|
||||
if(file.open(QIODevice::ReadWrite))
|
||||
{
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QFileInfo info(file);
|
||||
QDateTime newDate = QDateTime::currentDateTime();
|
||||
QDateTime oldDate = info.lastModified();
|
||||
int diff = oldDate.daysTo(newDate);
|
||||
return diff >= 7 ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
@@ -49,7 +49,7 @@ public:
|
||||
quint16 getServerPort (void) const;
|
||||
QString getErrorString (void) const;
|
||||
|
||||
const bool isListening(void) { return m_sockServer->isListening(); };
|
||||
bool isListening(void) { return m_sockServer->isListening(); };
|
||||
|
||||
public slots:
|
||||
void start (quint16 port = 0);
|
||||
|
@@ -23,7 +23,7 @@ StaticFileServing::StaticFileServing (QObject * parent)
|
||||
|
||||
StaticFileServing::~StaticFileServing ()
|
||||
{
|
||||
|
||||
delete _mimeDb;
|
||||
}
|
||||
|
||||
void StaticFileServing::setBaseUrl(const QString& url)
|
||||
|
Reference in New Issue
Block a user