-the debug code from the previous commit help narrow down what
 function is causing the crash but that's it, I need more. decided
 add the debug build type to cmake and will use gdb to help with
 debugging.

-decided to remove the debug code since I'll use gdb as the long
 term solution going forward.
This commit is contained in:
Zii 2023-06-11 07:41:57 -04:00
parent 9e7d8ee1ee
commit 510bdda64c
5 changed files with 13 additions and 77 deletions

View File

@ -11,6 +11,8 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE Debug)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)

View File

@ -97,15 +97,11 @@ 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;
} }
@ -117,8 +113,6 @@ 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);
@ -127,14 +121,10 @@ 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;
@ -172,39 +162,27 @@ 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());
@ -218,14 +196,10 @@ 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();
@ -240,14 +214,10 @@ 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);
@ -260,8 +230,6 @@ 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();
} }
@ -269,8 +237,6 @@ 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");
@ -297,8 +263,6 @@ 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();
} }
@ -311,17 +275,15 @@ 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();
if (!vidList.size() > 1) if (vidList.size() > 1)
{ {
recLog("attempting write out of event: " + name, shared); recLog("attempting write out of event: " + name, shared);
if (wrOutVod(name, vidList)) if (wrOutVod())
{ {
genHTMLvod(name); genHTMLvod(name);
@ -346,11 +308,10 @@ bool EventLoop::exec()
{ {
cycles += 1; cycles += 1;
while (!shared->recList.isEmpty()) shared->recMutex.lock();
{
shared->recMutex.lock();
auto event = shared->recList[0]; for (auto &&event : shared->recList)
{
auto maxFiles = shared->evMaxSecs / 2; auto maxFiles = shared->evMaxSecs / 2;
// there's 2 secs in each hls segment // there's 2 secs in each hls segment
@ -364,21 +325,17 @@ bool EventLoop::exec()
vidList.append(backwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); vidList.append(backwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2));
vidList.removeLast(); vidList.removeLast();
vidList.append(forwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); vidList.append(forwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2));
shared->recList.removeFirst();
shared->recMutex.unlock();
} }
}
funcMsg("exit: EventLoop::exec()"); shared->recList.clear();
shared->recMutex.unlock();
}
return Loop::exec(); return Loop::exec();
} }
bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) bool EventLoop::wrOutVod()
{ {
funcMsg("enter: EventLoop::wrOutVod()");
auto cnt = 0; auto cnt = 0;
auto concat = name + ".tmp"; auto concat = name + ".tmp";
auto ret = false; auto ret = false;
@ -387,7 +344,7 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids)
file.open(QFile::WriteOnly); file.open(QFile::WriteOnly);
for (auto &&vid : vids) for (auto &&vid : vidList)
{ {
recLog("event_src: " + vid, shared); recLog("event_src: " + vid, shared);
@ -436,8 +393,6 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids)
QFile::remove(concat); QFile::remove(concat);
} }
funcMsg("exit: EventLoop::wrOutVod()");
return ret; return ret;
} }
@ -452,15 +407,12 @@ 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();
} }
@ -472,8 +424,6 @@ 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);
@ -492,15 +442,11 @@ 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;
@ -558,7 +504,5 @@ bool DetectLoop::exec()
} }
} }
funcMsg("exit: DetectLoop::exec()");
return Loop::exec(); return Loop::exec();
} }

View File

@ -107,7 +107,7 @@ private:
float highScore; float highScore;
uint cycles; uint cycles;
bool wrOutVod(const QString &name, const QStringList &vids); bool wrOutVod();
public: public:

View File

@ -12,14 +12,6 @@
#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,7 +39,6 @@ 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
{ {
@ -86,7 +85,6 @@ 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
{ {