CubicSDR/src/demod/DemodulatorPreThread.h

74 lines
1.9 KiB
C
Raw Normal View History

2014-11-16 16:51:45 -05:00
#pragma once
#include <queue>
#include <vector>
#include "CubicSDRDefs.h"
2014-12-11 19:07:21 -05:00
#include "DemodDefs.h"
#include "DemodulatorWorkerThread.h"
class DemodulatorPreThread {
2014-11-16 16:51:45 -05:00
public:
DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQueue, DemodulatorThreadPostInputQueue* iqOutputQueue,
DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify);
2014-12-16 21:30:03 -05:00
~DemodulatorPreThread();
#ifdef __APPLE__
2014-12-16 21:30:03 -05:00
void *threadMain();
#else
2014-12-16 21:30:03 -05:00
void threadMain();
#endif
2014-11-16 16:51:45 -05:00
2014-12-16 21:30:03 -05:00
void setCommandQueue(DemodulatorThreadCommandQueue *tQueue) {
commandQueue = tQueue;
}
void setDemodulatorControlQueue(DemodulatorThreadControlCommandQueue *tQueue) {
threadQueueControl = tQueue;
}
2014-12-16 21:30:03 -05:00
DemodulatorThreadParameters &getParams() {
return params;
}
2014-12-16 21:30:03 -05:00
void initialize();
void terminate();
#ifdef __APPLE__
2014-12-16 21:30:03 -05:00
static void *pthread_helper(void *context) {
return ((DemodulatorPreThread *) context)->threadMain();
}
#endif
2014-11-16 16:51:45 -05:00
protected:
DemodulatorThreadInputQueue* iqInputQueue;
DemodulatorThreadPostInputQueue* iqOutputQueue;
2014-12-16 21:30:03 -05:00
DemodulatorThreadCommandQueue* commandQueue;
2014-11-16 16:51:45 -05:00
msresamp_crcf iqResampler;
double iqResampleRatio;
std::vector<liquid_float_complex> resampledData;
2014-11-16 16:51:45 -05:00
msresamp_rrrf audioResampler;
msresamp_rrrf stereoResampler;
double audioResampleRatio;
2014-11-16 16:51:45 -05:00
2014-12-16 21:30:03 -05:00
DemodulatorThreadParameters params;
DemodulatorThreadParameters lastParams;
nco_crcf freqShifter;
int shiftFrequency;
2014-12-16 21:30:03 -05:00
std::atomic<bool> terminated;
std::atomic<bool> initialized;
2014-11-30 23:33:55 -05:00
2014-12-16 21:30:03 -05:00
DemodulatorWorkerThread *workerThread;
std::thread *t_Worker;
2014-11-30 23:33:55 -05:00
2014-12-16 21:30:03 -05:00
DemodulatorThreadWorkerCommandQueue *workerQueue;
DemodulatorThreadWorkerResultQueue *workerResults;
DemodulatorThreadCommandQueue* threadQueueNotify;
DemodulatorThreadControlCommandQueue *threadQueueControl;
2014-11-16 16:51:45 -05:00
};