-the app is still crashing, adding a bunch of console output to
 help with debug.
This commit is contained in:
Zii 2023-06-10 22:44:38 -04:00
parent 09a0f030ac
commit 9e7d8ee1ee
3 changed files with 69 additions and 5 deletions

View File

@ -97,11 +97,15 @@ void Loop::loopSlot()
bool Loop::exec() bool Loop::exec()
{ {
funcMsg("enter: Loop::exec()");
if (loopTimer->interval() != heartBeat * 1000) if (loopTimer->interval() != heartBeat * 1000)
{ {
loopTimer->start(heartBeat * 1000); loopTimer->start(heartBeat * 1000);
} }
funcMsg("enter: Loop::exit()");
return shared->retCode == 0; return shared->retCode == 0;
} }
@ -113,6 +117,8 @@ RecLoop::RecLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(shar
void RecLoop::init() void RecLoop::init()
{ {
funcMsg("enter: RecLoop::init()");
recProc = new QProcess(this); recProc = new QProcess(this);
imgProc = new QProcess(this); imgProc = new QProcess(this);
@ -121,10 +127,14 @@ void RecLoop::init()
updateCmd(); updateCmd();
Loop::init(); Loop::init();
funcMsg("exit: RecLoop::init()");
} }
void RecLoop::updateCmd() void RecLoop::updateCmd()
{ {
funcMsg("enter: RecLoop::updateCmd()");
QStringList recArgs; QStringList recArgs;
QStringList imgArgs; QStringList imgArgs;
@ -162,27 +172,39 @@ void RecLoop::updateCmd()
recLog("img_args: " + imgArgs.join(" "), shared); recLog("img_args: " + imgArgs.join(" "), shared);
curUrl = shared->recordUrl; curUrl = shared->recordUrl;
funcMsg("exit: RecLoop::updateCmd()");
} }
void RecLoop::term() void RecLoop::term()
{ {
funcMsg("enter: RecLoop::term()");
recProc->kill(); recProc->kill();
recProc->waitForFinished(); recProc->waitForFinished();
imgProc->kill(); imgProc->kill();
imgProc->waitForFinished(); imgProc->waitForFinished();
funcMsg("exit: RecLoop::term()");
} }
void RecLoop::reset() void RecLoop::reset()
{ {
funcMsg("enter: RecLoop::reset()");
recLog("--rec_and_img_cmds_resetting--", shared); recLog("--rec_and_img_cmds_resetting--", shared);
term(); term();
updateCmd(); updateCmd();
funcMsg("exit: RecLoop::reset()");
} }
void RecLoop::procError(const QString &desc, QProcess *proc) void RecLoop::procError(const QString &desc, QProcess *proc)
{ {
funcMsg("enter: RecLoop::procError()");
if (proc->isOpen() && proc->state() == QProcess::NotRunning) if (proc->isOpen() && proc->state() == QProcess::NotRunning)
{ {
auto errBlob = QString(proc->readAllStandardError()); 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) void RecLoop::startProc(const QString &desc, QProcess *proc)
{ {
funcMsg("enter: RecLoop::startProc()");
if (proc->state() == QProcess::NotRunning) if (proc->state() == QProcess::NotRunning)
{ {
proc->start(); proc->start();
@ -214,10 +240,14 @@ void RecLoop::startProc(const QString &desc, QProcess *proc)
procError(desc, proc); procError(desc, proc);
} }
} }
funcMsg("exit: RecLoop::startProc()");
} }
bool RecLoop::exec() bool RecLoop::exec()
{ {
funcMsg("enter: RecLoop::exec()");
procError("img", imgProc); procError("img", imgProc);
procError("rec", recProc); procError("rec", recProc);
@ -230,6 +260,8 @@ bool RecLoop::exec()
startProc("img", imgProc); startProc("img", imgProc);
startProc("rec", recProc); startProc("rec", recProc);
funcMsg("exit: RecLoop::exec()");
return Loop::exec(); return Loop::exec();
} }
@ -237,6 +269,8 @@ Upkeep::Upkeep(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(shared
bool Upkeep::exec() bool Upkeep::exec()
{ {
funcMsg("enter: Upkeep::exec()");
QDir().mkdir("live"); QDir().mkdir("live");
QDir().mkdir("events"); QDir().mkdir("events");
QDir().mkdir("logs"); QDir().mkdir("logs");
@ -263,6 +297,8 @@ bool Upkeep::exec()
genCSS(shared); genCSS(shared);
genHTMLul(shared->webRoot, QString(APP_NAME) + " " + QString(APP_VER), shared); genHTMLul(shared->webRoot, QString(APP_NAME) + " " + QString(APP_VER), shared);
funcMsg("exit: Upkeep::exec()");
return Loop::exec(); return Loop::exec();
} }
@ -275,6 +311,8 @@ EventLoop::EventLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(
bool EventLoop::exec() bool EventLoop::exec()
{ {
funcMsg("enter: EventLoop::exec()");
if (cycles * 2 >= shared->evMaxSecs) if (cycles * 2 >= shared->evMaxSecs)
{ {
vidList.removeDuplicates(); vidList.removeDuplicates();
@ -332,13 +370,18 @@ bool EventLoop::exec()
} }
} }
funcMsg("exit: EventLoop::exec()");
return Loop::exec(); return Loop::exec();
} }
bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) bool EventLoop::wrOutVod(const QString &name, const QStringList &vids)
{ {
funcMsg("enter: EventLoop::wrOutVod()");
auto cnt = 0; auto cnt = 0;
auto concat = name + ".tmp"; auto concat = name + ".tmp";
auto ret = false;
QFile file(concat); 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); recLog("err: none of the event hls clips exists, canceling write out.", shared);
QFile::remove(concat); return false; QFile::remove(concat);
} }
else else
{ {
@ -378,8 +421,6 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids)
proc.setArguments(args); proc.setArguments(args);
proc.start(); proc.start();
auto ret = false;
if (proc.waitForStarted()) if (proc.waitForStarted())
{ {
recLog("concat_cmd_start: ok", shared); recLog("concat_cmd_start: ok", shared);
@ -393,9 +434,11 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids)
} }
QFile::remove(concat); QFile::remove(concat);
}
funcMsg("exit: EventLoop::wrOutVod()");
return ret; return ret;
}
} }
DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent) 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() void DetectLoop::init()
{ {
funcMsg("enter: DetectLoop::init()");
pcTimer = new QTimer(this); pcTimer = new QTimer(this);
mod = false; mod = false;
connect(pcTimer, &QTimer::timeout, this, &DetectLoop::pcBreak); connect(pcTimer, &QTimer::timeout, this, &DetectLoop::pcBreak);
resetTimers(); resetTimers();
funcMsg("exit: DetectLoop::init()");
Loop::init(); Loop::init();
} }
@ -426,6 +472,8 @@ void DetectLoop::resetTimers()
void DetectLoop::pcBreak() void DetectLoop::pcBreak()
{ {
funcMsg("enter: DetectLoop::pcBreak()");
if (!shared->postCmd.isEmpty()) if (!shared->postCmd.isEmpty())
{ {
detLog("---POST_BREAK---", shared); detLog("---POST_BREAK---", shared);
@ -444,11 +492,15 @@ void DetectLoop::pcBreak()
} }
} }
funcMsg("exit: DetectLoop::pcBreak()");
mod = false; mod = false;
} }
bool DetectLoop::exec() bool DetectLoop::exec()
{ {
funcMsg("enter: DetectLoop::exec()");
if (delayCycles > 0) if (delayCycles > 0)
{ {
delayCycles -= 1; delayCycles -= 1;
@ -506,5 +558,7 @@ bool DetectLoop::exec()
} }
} }
funcMsg("exit: DetectLoop::exec()");
return Loop::exec(); return Loop::exec();
} }

View File

@ -12,6 +12,14 @@
#include "common.h" #include "common.h"
void funcMsg(const QString &line)
{
if (DEBUG == 1)
{
QTextStream(stdout) << line << Qt::endl;
}
}
QString getParam(const QString &key, const QStringList &args) QString getParam(const QString &key, const QStringList &args)
{ {
// this can be used by command objects to pick out parameters // this can be used by command objects to pick out parameters

View File

@ -39,6 +39,7 @@ using namespace std;
#define STRFTIME_FMT "%Y%m%d%H%M%S" #define STRFTIME_FMT "%Y%m%d%H%M%S"
#define MAX_IMAGES 1000 #define MAX_IMAGES 1000
#define MAX_VIDEOS 1000 #define MAX_VIDEOS 1000
#define DEBUG 1
struct evt_t struct evt_t
{ {
@ -85,6 +86,7 @@ void rdLine(const QString &param, const QString &line, int *value);
void enforceMaxEvents(shared_t *share); void enforceMaxEvents(shared_t *share);
void enforceMaxImages(); void enforceMaxImages();
void enforceMaxVids(); void enforceMaxVids();
void funcMsg(const QString &line);
class MultiInstance : public QObject class MultiInstance : public QObject
{ {