2014-11-30 23:33:55 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/thread.h"
|
|
|
|
|
|
|
|
#include "liquid/liquid.h"
|
|
|
|
#include "AudioThread.h"
|
|
|
|
#include "ThreadQueue.h"
|
|
|
|
#include "CubicSDRDefs.h"
|
|
|
|
|
|
|
|
class DemodulatorWorkerThreadResult {
|
|
|
|
public:
|
|
|
|
enum DemodulatorThreadResultEnum {
|
|
|
|
DEMOD_WORKER_THREAD_RESULT_NULL, DEMOD_WORKER_THREAD_RESULT_FILTERS
|
|
|
|
};
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadResult() :
|
2015-01-11 17:08:16 -05:00
|
|
|
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(NULL), iqResampleRatio(0), audioResampler(NULL), stereoResampler(NULL), audioResamplerRatio(
|
|
|
|
0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadResult(DemodulatorThreadResultEnum cmd) :
|
2015-01-11 17:08:16 -05:00
|
|
|
cmd(cmd), iqResampler(NULL), iqResampleRatio(0), audioResampler(NULL), stereoResampler(NULL), audioResamplerRatio(0), sampleRate(0), bandwidth(
|
2014-12-24 01:28:33 -05:00
|
|
|
0), audioSampleRate(0) {
|
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-01-03 17:07:39 -05:00
|
|
|
msresamp_rrrf audioResampler;
|
|
|
|
msresamp_rrrf stereoResampler;
|
|
|
|
double audioResamplerRatio;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DemodulatorWorkerThreadCommand {
|
|
|
|
public:
|
|
|
|
enum DemodulatorThreadCommandEnum {
|
|
|
|
DEMOD_WORKER_THREAD_CMD_NULL, DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS
|
|
|
|
};
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadCommand() :
|
2015-01-11 17:08:16 -05:00
|
|
|
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
2014-11-30 23:33:55 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
2015-01-11 17:08:16 -05:00
|
|
|
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef ThreadQueue<DemodulatorWorkerThreadCommand> DemodulatorThreadWorkerCommandQueue;
|
|
|
|
typedef ThreadQueue<DemodulatorWorkerThreadResult> DemodulatorThreadWorkerResultQueue;
|
|
|
|
|
|
|
|
class DemodulatorWorkerThread {
|
|
|
|
public:
|
|
|
|
|
|
|
|
DemodulatorWorkerThread(DemodulatorThreadWorkerCommandQueue* in, DemodulatorThreadWorkerResultQueue* out);
|
|
|
|
~DemodulatorWorkerThread();
|
|
|
|
|
|
|
|
void threadMain();
|
|
|
|
|
|
|
|
void setCommandQueue(DemodulatorThreadWorkerCommandQueue *tQueue) {
|
|
|
|
commandQueue = tQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setResultQueue(DemodulatorThreadWorkerResultQueue *tQueue) {
|
|
|
|
resultQueue = tQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void terminate();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
DemodulatorThreadWorkerCommandQueue *commandQueue;
|
|
|
|
DemodulatorThreadWorkerResultQueue *resultQueue;
|
|
|
|
|
|
|
|
std::atomic<bool> terminated;
|
|
|
|
};
|