2014-11-30 23:33:55 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "liquid/liquid.h"
|
|
|
|
#include "AudioThread.h"
|
|
|
|
#include "ThreadQueue.h"
|
|
|
|
#include "CubicSDRDefs.h"
|
2015-11-17 18:57:42 -05:00
|
|
|
#include "Modem.h"
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
class DemodulatorWorkerThreadResult {
|
|
|
|
public:
|
|
|
|
enum DemodulatorThreadResultEnum {
|
|
|
|
DEMOD_WORKER_THREAD_RESULT_NULL, DEMOD_WORKER_THREAD_RESULT_FILTERS
|
|
|
|
};
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadResult() :
|
2015-11-17 21:49:02 -05:00
|
|
|
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr), modemType("") {
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadResult(DemodulatorThreadResultEnum cmd) :
|
2015-03-15 21:02:26 -04:00
|
|
|
DemodulatorWorkerThreadResult() {
|
|
|
|
this->cmd = cmd;
|
2014-11-30 23:33:55 -05:00
|
|
|
}
|
|
|
|
|
2014-12-23 01:12:14 -05:00
|
|
|
DemodulatorThreadResultEnum cmd;
|
|
|
|
|
2015-01-11 17:08:16 -05:00
|
|
|
msresamp_crcf iqResampler;
|
|
|
|
double iqResampleRatio;
|
2015-11-16 23:49:54 -05:00
|
|
|
|
|
|
|
DemodulatorThread *demodThread;
|
2015-03-15 21:02:26 -04:00
|
|
|
|
2015-01-11 17:08:16 -05:00
|
|
|
long long sampleRate;
|
2014-11-30 23:33:55 -05:00
|
|
|
unsigned int bandwidth;
|
2015-11-17 19:32:47 -05:00
|
|
|
Modem *modem;
|
2015-11-17 18:57:42 -05:00
|
|
|
ModemKit *modemKit;
|
2015-11-17 21:49:02 -05:00
|
|
|
std::string modemType;
|
2015-11-29 13:35:12 -05:00
|
|
|
std::string modemName;
|
2014-11-30 23:33:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemodulatorWorkerThreadCommand {
|
|
|
|
public:
|
|
|
|
enum DemodulatorThreadCommandEnum {
|
2015-11-17 20:20:12 -05:00
|
|
|
DEMOD_WORKER_THREAD_CMD_NULL, DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS, DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD
|
2014-11-30 23:33:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadCommand() :
|
2015-11-17 20:20:12 -05:00
|
|
|
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
2015-11-17 20:20:12 -05:00
|
|
|
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-23 01:12:14 -05:00
|
|
|
DemodulatorThreadCommandEnum cmd;
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
long long frequency;
|
2015-01-11 17:08:16 -05:00
|
|
|
long long sampleRate;
|
2014-11-30 23:33:55 -05:00
|
|
|
unsigned int bandwidth;
|
|
|
|
unsigned int audioSampleRate;
|
2015-11-17 20:20:12 -05:00
|
|
|
std::string demodType;
|
2015-11-26 01:54:54 -05:00
|
|
|
ModemSettings settings;
|
2014-11-30 23:33:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef ThreadQueue<DemodulatorWorkerThreadCommand> DemodulatorThreadWorkerCommandQueue;
|
|
|
|
typedef ThreadQueue<DemodulatorWorkerThreadResult> DemodulatorThreadWorkerResultQueue;
|
|
|
|
|
2015-07-29 20:57:02 -04:00
|
|
|
class DemodulatorWorkerThread : public IOThread {
|
2014-11-30 23:33:55 -05:00
|
|
|
public:
|
|
|
|
|
2015-07-30 19:30:46 -04:00
|
|
|
DemodulatorWorkerThread();
|
2014-11-30 23:33:55 -05:00
|
|
|
~DemodulatorWorkerThread();
|
|
|
|
|
2015-07-29 20:57:02 -04:00
|
|
|
void run();
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
void setCommandQueue(DemodulatorThreadWorkerCommandQueue *tQueue) {
|
|
|
|
commandQueue = tQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setResultQueue(DemodulatorThreadWorkerResultQueue *tQueue) {
|
|
|
|
resultQueue = tQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void terminate();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
DemodulatorThreadWorkerCommandQueue *commandQueue;
|
|
|
|
DemodulatorThreadWorkerResultQueue *resultQueue;
|
2015-11-17 20:20:12 -05:00
|
|
|
Modem *cModem;
|
|
|
|
ModemKit *cModemKit;
|
2015-11-17 21:49:02 -05:00
|
|
|
std::string cModemType;
|
2015-11-29 13:35:12 -05:00
|
|
|
std::string cModemName;
|
2014-11-30 23:33:55 -05:00
|
|
|
};
|