2021-03-16 03:08:59 +08:00
|
|
|
#include "zm_decoder_thread.h"
|
|
|
|
|
|
|
|
#include "zm_monitor.h"
|
|
|
|
#include "zm_signal.h"
|
|
|
|
|
2021-03-22 06:32:22 +08:00
|
|
|
DecoderThread::DecoderThread(Monitor *monitor) :
|
2021-03-16 03:08:59 +08:00
|
|
|
monitor_(monitor), terminate_(false) {
|
|
|
|
thread_ = std::thread(&DecoderThread::Run, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
DecoderThread::~DecoderThread() {
|
|
|
|
Stop();
|
2021-04-17 23:31:36 +08:00
|
|
|
if (thread_.joinable()) thread_.join();
|
2021-03-16 03:08:59 +08:00
|
|
|
}
|
|
|
|
|
2021-04-08 08:36:38 +08:00
|
|
|
void DecoderThread::Start() {
|
2021-04-17 23:31:36 +08:00
|
|
|
if (thread_.joinable()) thread_.join();
|
2021-04-08 08:36:38 +08:00
|
|
|
terminate_ = false;
|
|
|
|
thread_ = std::thread(&DecoderThread::Run, this);
|
|
|
|
}
|
2021-03-16 03:08:59 +08:00
|
|
|
void DecoderThread::Run() {
|
|
|
|
Debug(2, "DecoderThread::Run() for %d", monitor_->Id());
|
|
|
|
|
|
|
|
while (!(terminate_ or zm_terminate)) {
|
2021-03-22 06:32:22 +08:00
|
|
|
monitor_->Decode();
|
2021-03-16 03:08:59 +08:00
|
|
|
}
|
|
|
|
}
|