CubicSDR/src/demod/DemodulatorMgr.cpp

58 lines
1.3 KiB
C++
Raw Normal View History

2014-11-22 22:33:32 -05:00
#include <DemodulatorMgr.h>
DemodulatorInstance::DemodulatorInstance() :
t_Demod(NULL), threadQueueDemod(NULL), demodulatorThread(NULL) {
}
DemodulatorInstance::~DemodulatorInstance() {
delete threadQueueDemod;
delete demodulatorThread;
delete t_Demod;
}
2014-11-22 22:33:32 -05:00
void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {
demodulatorThread->setVisualOutputQueue(tQueue);
}
void DemodulatorInstance::init() {
if (demodulatorThread) {
terminate();
delete threadQueueDemod;
2014-11-22 22:33:32 -05:00
delete demodulatorThread;
delete t_Demod;
2014-11-22 22:33:32 -05:00
}
threadQueueDemod = new DemodulatorThreadInputQueue;
demodulatorThread = new DemodulatorThread(threadQueueDemod, &params);
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
}
void DemodulatorInstance::terminate() {
demodulatorThread->terminate();
t_Demod->join();
}
2014-11-22 22:33:32 -05:00
DemodulatorMgr::DemodulatorMgr() {
}
DemodulatorMgr::~DemodulatorMgr() {
terminateAll();
2014-11-22 22:33:32 -05:00
}
DemodulatorInstance *DemodulatorMgr::newThread() {
DemodulatorInstance *newDemod = new DemodulatorInstance;
demods.push_back(newDemod);
return newDemod;
}
void DemodulatorMgr::terminateAll() {
while (demods.size()) {
DemodulatorInstance *d = demods.back();
demods.pop_back();
d->terminate();
delete d;
}
}