CubicSDR/src/demod/DemodulatorWorkerThread.h

103 lines
2.8 KiB
C
Raw Normal View History

// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+
2014-11-30 23:33:55 -05:00
#pragma once
#include <queue>
#include <vector>
#include <memory>
2014-11-30 23:33:55 -05:00
#include "liquid/liquid.h"
#include "AudioThread.h"
#include "ThreadBlockingQueue.h"
2014-11-30 23:33:55 -05:00
#include "CubicSDRDefs.h"
#include "Modem.h"
2014-11-30 23:33:55 -05:00
class DemodulatorWorkerThreadResult {
public:
2021-04-22 00:34:45 -04:00
enum class Type {
2014-11-30 23:33:55 -05:00
DEMOD_WORKER_THREAD_RESULT_NULL, DEMOD_WORKER_THREAD_RESULT_FILTERS
};
DemodulatorWorkerThreadResult() :
2021-04-22 00:34:45 -04:00
cmd(DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
2014-11-30 23:33:55 -05:00
}
2021-04-22 00:34:45 -04:00
explicit DemodulatorWorkerThreadResult(DemodulatorWorkerThreadResult::Type cmd) :
DemodulatorWorkerThreadResult() {
this->cmd = cmd;
2014-11-30 23:33:55 -05:00
}
2021-04-22 00:34:45 -04:00
DemodulatorWorkerThreadResult::Type cmd;
2014-12-23 01:12:14 -05:00
2015-01-11 17:08:16 -05:00
msresamp_crcf iqResampler;
double iqResampleRatio;
2015-01-11 17:08:16 -05:00
long long sampleRate;
2014-11-30 23:33:55 -05:00
unsigned int bandwidth;
Modem *modem{};
ModemKit *modemKit;
std::string modemType;
std::string modemName;
2014-11-30 23:33:55 -05:00
};
class DemodulatorWorkerThreadCommand {
public:
2021-04-22 00:34:45 -04:00
enum class Type {
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() :
2021-04-22 00:34:45 -04:00
cmd(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
2014-11-30 23:33:55 -05:00
}
2021-04-22 00:34:45 -04:00
explicit DemodulatorWorkerThreadCommand(DemodulatorWorkerThreadCommand::Type cmd) :
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
2014-11-30 23:33:55 -05:00
}
2021-04-22 00:34:45 -04:00
DemodulatorWorkerThreadCommand::Type cmd;
2014-12-23 01:12:14 -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;
std::string demodType;
ModemSettings settings;
2014-11-30 23:33:55 -05:00
};
typedef ThreadBlockingQueue<DemodulatorWorkerThreadCommand> DemodulatorThreadWorkerCommandQueue;
typedef ThreadBlockingQueue<DemodulatorWorkerThreadResult> DemodulatorThreadWorkerResultQueue;
2014-11-30 23:33:55 -05:00
typedef std::shared_ptr<DemodulatorThreadWorkerCommandQueue> DemodulatorThreadWorkerCommandQueuePtr;
typedef std::shared_ptr<DemodulatorThreadWorkerResultQueue> DemodulatorThreadWorkerResultQueuePtr;
2015-07-29 20:57:02 -04:00
class DemodulatorWorkerThread : public IOThread {
2014-11-30 23:33:55 -05:00
public:
DemodulatorWorkerThread();
~DemodulatorWorkerThread() override;
2014-11-30 23:33:55 -05:00
void run() override;
2014-11-30 23:33:55 -05:00
void setCommandQueue(DemodulatorThreadWorkerCommandQueuePtr tQueue) {
2014-11-30 23:33:55 -05:00
commandQueue = tQueue;
}
void setResultQueue(DemodulatorThreadWorkerResultQueuePtr tQueue) {
2014-11-30 23:33:55 -05:00
resultQueue = tQueue;
}
void terminate() override;
2014-11-30 23:33:55 -05:00
protected:
DemodulatorThreadWorkerCommandQueuePtr commandQueue;
DemodulatorThreadWorkerResultQueuePtr resultQueue;
Modem *cModem;
ModemKit *cModemKit;
std::string cModemType;
std::string cModemName;
2014-11-30 23:33:55 -05:00
};