From 9e7d8ee1ee157974784c68fb066d5120e5ec5076 Mon Sep 17 00:00:00 2001 From: Zii Date: Sat, 10 Jun 2023 22:44:38 -0400 Subject: [PATCH] v3.0.t16 -the app is still crashing, adding a bunch of console output to help with debug. --- src/camera.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++---- src/common.cpp | 8 +++++++ src/common.h | 2 ++ 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/camera.cpp b/src/camera.cpp index 481cbd1..e5c41c1 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -97,11 +97,15 @@ void Loop::loopSlot() bool Loop::exec() { + funcMsg("enter: Loop::exec()"); + if (loopTimer->interval() != heartBeat * 1000) { loopTimer->start(heartBeat * 1000); } + funcMsg("enter: Loop::exit()"); + return shared->retCode == 0; } @@ -113,6 +117,8 @@ RecLoop::RecLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(shar void RecLoop::init() { + funcMsg("enter: RecLoop::init()"); + recProc = new QProcess(this); imgProc = new QProcess(this); @@ -121,10 +127,14 @@ void RecLoop::init() updateCmd(); Loop::init(); + + funcMsg("exit: RecLoop::init()"); } void RecLoop::updateCmd() { + funcMsg("enter: RecLoop::updateCmd()"); + QStringList recArgs; QStringList imgArgs; @@ -162,27 +172,39 @@ void RecLoop::updateCmd() recLog("img_args: " + imgArgs.join(" "), shared); curUrl = shared->recordUrl; + + funcMsg("exit: RecLoop::updateCmd()"); } void RecLoop::term() { + funcMsg("enter: RecLoop::term()"); + recProc->kill(); recProc->waitForFinished(); imgProc->kill(); imgProc->waitForFinished(); + + funcMsg("exit: RecLoop::term()"); } void RecLoop::reset() { + funcMsg("enter: RecLoop::reset()"); + recLog("--rec_and_img_cmds_resetting--", shared); term(); updateCmd(); + + funcMsg("exit: RecLoop::reset()"); } void RecLoop::procError(const QString &desc, QProcess *proc) { + funcMsg("enter: RecLoop::procError()"); + if (proc->isOpen() && proc->state() == QProcess::NotRunning) { auto errBlob = QString(proc->readAllStandardError()); @@ -196,10 +218,14 @@ void RecLoop::procError(const QString &desc, QProcess *proc) } } } + + funcMsg("exit: RecLoop::procError()"); } void RecLoop::startProc(const QString &desc, QProcess *proc) { + funcMsg("enter: RecLoop::startProc()"); + if (proc->state() == QProcess::NotRunning) { proc->start(); @@ -214,10 +240,14 @@ void RecLoop::startProc(const QString &desc, QProcess *proc) procError(desc, proc); } } + + funcMsg("exit: RecLoop::startProc()"); } bool RecLoop::exec() { + funcMsg("enter: RecLoop::exec()"); + procError("img", imgProc); procError("rec", recProc); @@ -230,6 +260,8 @@ bool RecLoop::exec() startProc("img", imgProc); startProc("rec", recProc); + funcMsg("exit: RecLoop::exec()"); + return Loop::exec(); } @@ -237,6 +269,8 @@ Upkeep::Upkeep(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(shared bool Upkeep::exec() { + funcMsg("enter: Upkeep::exec()"); + QDir().mkdir("live"); QDir().mkdir("events"); QDir().mkdir("logs"); @@ -263,6 +297,8 @@ bool Upkeep::exec() genCSS(shared); genHTMLul(shared->webRoot, QString(APP_NAME) + " " + QString(APP_VER), shared); + funcMsg("exit: Upkeep::exec()"); + return Loop::exec(); } @@ -275,6 +311,8 @@ EventLoop::EventLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop( bool EventLoop::exec() { + funcMsg("enter: EventLoop::exec()"); + if (cycles * 2 >= shared->evMaxSecs) { vidList.removeDuplicates(); @@ -332,13 +370,18 @@ bool EventLoop::exec() } } + funcMsg("exit: EventLoop::exec()"); + return Loop::exec(); } bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) { + funcMsg("enter: EventLoop::wrOutVod()"); + auto cnt = 0; auto concat = name + ".tmp"; + auto ret = false; QFile file(concat); @@ -360,7 +403,7 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) { recLog("err: none of the event hls clips exists, canceling write out.", shared); - QFile::remove(concat); return false; + QFile::remove(concat); } else { @@ -378,8 +421,6 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) proc.setArguments(args); proc.start(); - auto ret = false; - if (proc.waitForStarted()) { recLog("concat_cmd_start: ok", shared); @@ -393,9 +434,11 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) } QFile::remove(concat); - - return ret; } + + funcMsg("exit: EventLoop::wrOutVod()"); + + return ret; } DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent) @@ -409,12 +452,15 @@ DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loo void DetectLoop::init() { + funcMsg("enter: DetectLoop::init()"); + pcTimer = new QTimer(this); mod = false; connect(pcTimer, &QTimer::timeout, this, &DetectLoop::pcBreak); resetTimers(); + funcMsg("exit: DetectLoop::init()"); Loop::init(); } @@ -426,6 +472,8 @@ void DetectLoop::resetTimers() void DetectLoop::pcBreak() { + funcMsg("enter: DetectLoop::pcBreak()"); + if (!shared->postCmd.isEmpty()) { detLog("---POST_BREAK---", shared); @@ -444,11 +492,15 @@ void DetectLoop::pcBreak() } } + funcMsg("exit: DetectLoop::pcBreak()"); + mod = false; } bool DetectLoop::exec() { + funcMsg("enter: DetectLoop::exec()"); + if (delayCycles > 0) { delayCycles -= 1; @@ -506,5 +558,7 @@ bool DetectLoop::exec() } } + funcMsg("exit: DetectLoop::exec()"); + return Loop::exec(); } diff --git a/src/common.cpp b/src/common.cpp index c57b72f..9c5846e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -12,6 +12,14 @@ #include "common.h" +void funcMsg(const QString &line) +{ + if (DEBUG == 1) + { + QTextStream(stdout) << line << Qt::endl; + } +} + QString getParam(const QString &key, const QStringList &args) { // this can be used by command objects to pick out parameters diff --git a/src/common.h b/src/common.h index e0b4868..1dcb53f 100644 --- a/src/common.h +++ b/src/common.h @@ -39,6 +39,7 @@ using namespace std; #define STRFTIME_FMT "%Y%m%d%H%M%S" #define MAX_IMAGES 1000 #define MAX_VIDEOS 1000 +#define DEBUG 1 struct evt_t { @@ -85,6 +86,7 @@ void rdLine(const QString ¶m, const QString &line, int *value); void enforceMaxEvents(shared_t *share); void enforceMaxImages(); void enforceMaxVids(); +void funcMsg(const QString &line); class MultiInstance : public QObject {