2014-11-22 22:33:32 -05:00
|
|
|
#include <DemodulatorMgr.h>
|
|
|
|
|
|
|
|
DemodulatorInstance::DemodulatorInstance() :
|
|
|
|
t_Demod(NULL), threadQueueDemod(NULL), demodulatorThread(NULL) {
|
|
|
|
}
|
2014-11-23 19:39:27 -05:00
|
|
|
|
|
|
|
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) {
|
2014-11-23 19:39:27 -05:00
|
|
|
terminate();
|
|
|
|
delete threadQueueDemod;
|
2014-11-22 22:33:32 -05:00
|
|
|
delete demodulatorThread;
|
2014-11-23 19:39:27 -05:00
|
|
|
delete t_Demod;
|
2014-11-22 22:33:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
threadQueueDemod = new DemodulatorThreadInputQueue;
|
|
|
|
demodulatorThread = new DemodulatorThread(threadQueueDemod, ¶ms);
|
|
|
|
|
|
|
|
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
|
|
|
|
}
|
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
void DemodulatorInstance::terminate() {
|
|
|
|
demodulatorThread->terminate();
|
|
|
|
t_Demod->join();
|
|
|
|
}
|
|
|
|
|
2014-11-22 22:33:32 -05:00
|
|
|
DemodulatorMgr::DemodulatorMgr() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorMgr::~DemodulatorMgr() {
|
2014-11-23 19:39:27 -05:00
|
|
|
terminateAll();
|
2014-11-22 22:33:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorInstance *DemodulatorMgr::newThread() {
|
|
|
|
DemodulatorInstance *newDemod = new DemodulatorInstance;
|
|
|
|
demods.push_back(newDemod);
|
|
|
|
return newDemod;
|
|
|
|
}
|
2014-11-23 19:39:27 -05:00
|
|
|
|
|
|
|
void DemodulatorMgr::terminateAll() {
|
|
|
|
while (demods.size()) {
|
|
|
|
DemodulatorInstance *d = demods.back();
|
|
|
|
demods.pop_back();
|
|
|
|
d->terminate();
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
}
|