2017-01-02 21:07:43 -05:00
|
|
|
// 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>
|
2017-08-13 12:49:47 -04:00
|
|
|
#include <memory>
|
2014-11-30 23:33:55 -05:00
|
|
|
#include "liquid/liquid.h"
|
|
|
|
#include "AudioThread.h"
|
2017-02-09 13:12:12 -05:00
|
|
|
#include "ThreadBlockingQueue.h"
|
2014-11-30 23:33:55 -05:00
|
|
|
#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:
|
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) :
|
2015-03-15 21:02:26 -04:00
|
|
|
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-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;
|
2021-04-04 22:14:31 -04: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:
|
2021-04-22 00:34:45 -04:00
|
|
|
enum class Type {
|
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() :
|
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) :
|
2021-04-04 22:14:31 -04:00
|
|
|
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
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2017-02-09 13:12:12 -05:00
|
|
|
typedef ThreadBlockingQueue<DemodulatorWorkerThreadCommand> DemodulatorThreadWorkerCommandQueue;
|
|
|
|
typedef ThreadBlockingQueue<DemodulatorWorkerThreadResult> DemodulatorThreadWorkerResultQueue;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
2017-08-13 12:49:47 -04: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:
|
|
|
|
|
2015-07-30 19:30:46 -04:00
|
|
|
DemodulatorWorkerThread();
|
2021-04-04 22:14:31 -04:00
|
|
|
~DemodulatorWorkerThread() override;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
2021-04-04 22:14:31 -04:00
|
|
|
void run() override;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
2017-08-13 12:49:47 -04:00
|
|
|
void setCommandQueue(DemodulatorThreadWorkerCommandQueuePtr tQueue) {
|
2014-11-30 23:33:55 -05:00
|
|
|
commandQueue = tQueue;
|
|
|
|
}
|
|
|
|
|
2017-08-13 12:49:47 -04:00
|
|
|
void setResultQueue(DemodulatorThreadWorkerResultQueuePtr tQueue) {
|
2014-11-30 23:33:55 -05:00
|
|
|
resultQueue = tQueue;
|
|
|
|
}
|
|
|
|
|
2021-04-04 22:14:31 -04:00
|
|
|
void terminate() override;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2017-08-13 12:49:47 -04:00
|
|
|
DemodulatorThreadWorkerCommandQueuePtr commandQueue;
|
|
|
|
DemodulatorThreadWorkerResultQueuePtr 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
|
|
|
};
|