CubicSDR/src/demod/DemodulatorWorkerThread.h

99 lines
2.5 KiB
C
Raw Normal View History

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"
#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() :
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) :
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;
DemodulatorThread *demodThread;
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;
ModemKit *modemKit;
std::string modemType;
std::string modemName;
2014-11-30 23:33:55 -05:00
};
class DemodulatorWorkerThreadCommand {
public:
enum DemodulatorThreadCommandEnum {
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() :
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) :
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;
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;
std::string demodType;
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:
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;
Modem *cModem;
ModemKit *cModemKit;
std::string cModemType;
std::string cModemName;
2014-11-30 23:33:55 -05:00
};