2014-11-17 22:58:56 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2014-11-30 17:11:29 -05:00
|
|
|
#include <thread>
|
2014-11-17 22:58:56 -05:00
|
|
|
|
|
|
|
#include "DemodulatorThread.h"
|
|
|
|
|
|
|
|
class DemodulatorInstance {
|
|
|
|
public:
|
2014-11-22 22:17:33 -05:00
|
|
|
|
|
|
|
DemodulatorThreadInputQueue* threadQueueDemod;
|
2014-11-26 21:05:19 -05:00
|
|
|
DemodulatorThreadCommandQueue* threadQueueCommand;
|
2014-12-11 19:07:21 -05:00
|
|
|
DemodulatorThreadCommandQueue* threadQueueNotify;
|
2014-11-30 17:11:29 -05:00
|
|
|
DemodulatorThread *demodulatorThread;
|
2014-12-01 18:59:07 -05:00
|
|
|
#ifdef __APPLE__
|
|
|
|
pthread_t t_Demod;
|
|
|
|
#else
|
2014-11-30 17:11:29 -05:00
|
|
|
std::thread *t_Demod;
|
2014-12-01 18:59:07 -05:00
|
|
|
#endif
|
2014-11-30 17:11:29 -05:00
|
|
|
|
|
|
|
AudioThreadInputQueue *audioInputQueue;
|
|
|
|
AudioThread *audioThread;
|
|
|
|
std::thread *t_Audio;
|
2014-11-17 22:58:56 -05:00
|
|
|
|
2014-11-22 22:33:32 -05:00
|
|
|
DemodulatorInstance();
|
2014-11-23 19:39:27 -05:00
|
|
|
~DemodulatorInstance();
|
2014-11-30 17:11:29 -05:00
|
|
|
|
2014-11-22 22:33:32 -05:00
|
|
|
void setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue);
|
2014-11-30 17:11:29 -05:00
|
|
|
|
2014-11-26 21:05:19 -05:00
|
|
|
DemodulatorThreadCommandQueue *getCommandQueue();
|
|
|
|
DemodulatorThreadParameters &getParams();
|
|
|
|
|
|
|
|
void run();
|
2014-11-23 19:39:27 -05:00
|
|
|
void terminate();
|
2014-12-10 00:34:27 -05:00
|
|
|
std::string getLabel();
|
|
|
|
void setLabel(std::string labelStr);
|
|
|
|
|
2014-12-11 19:07:21 -05:00
|
|
|
bool isTerminated();
|
|
|
|
|
2014-12-10 00:34:27 -05:00
|
|
|
private:
|
|
|
|
std::string label;
|
2014-12-11 19:07:21 -05:00
|
|
|
bool terminated;
|
|
|
|
bool demodTerminated;
|
|
|
|
bool audioTerminated;
|
2014-11-17 22:58:56 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemodulatorMgr {
|
|
|
|
public:
|
2014-11-22 22:33:32 -05:00
|
|
|
DemodulatorMgr();
|
|
|
|
~DemodulatorMgr();
|
2014-11-17 22:58:56 -05:00
|
|
|
|
2014-11-22 22:33:32 -05:00
|
|
|
DemodulatorInstance *newThread();
|
2014-11-26 21:05:19 -05:00
|
|
|
std::vector<DemodulatorInstance *> &getDemodulators();
|
2014-11-30 18:54:13 -05:00
|
|
|
std::vector<DemodulatorInstance *> *getDemodulatorsAt(int freq, int bandwidth);
|
2014-12-10 21:22:13 -05:00
|
|
|
void deleteThread(DemodulatorInstance *);
|
2014-11-17 22:58:56 -05:00
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
void terminateAll();
|
2014-12-10 00:34:27 -05:00
|
|
|
|
|
|
|
void setActiveDemodulator(DemodulatorInstance *demod, bool temporary = true);
|
|
|
|
DemodulatorInstance *getActiveDemodulator();
|
|
|
|
DemodulatorInstance *getLastActiveDemodulator();
|
|
|
|
|
2014-11-22 22:33:32 -05:00
|
|
|
private:
|
2014-12-11 19:07:21 -05:00
|
|
|
void garbageCollect();
|
|
|
|
|
2014-11-17 22:58:56 -05:00
|
|
|
std::vector<DemodulatorInstance *> demods;
|
2014-12-11 19:07:21 -05:00
|
|
|
std::vector<DemodulatorInstance *> demods_deleted;
|
2014-12-10 00:34:27 -05:00
|
|
|
DemodulatorInstance *activeDemodulator;
|
|
|
|
DemodulatorInstance *lastActiveDemodulator;
|
2014-12-10 21:22:13 -05:00
|
|
|
DemodulatorInstance *activeVisualDemodulator;
|
2014-12-11 19:07:21 -05:00
|
|
|
|
2014-11-17 22:58:56 -05:00
|
|
|
};
|