CubicSDR/src/demod/DemodulatorPreThread.h

80 lines
2.0 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:
2014-12-16 21:30:03 -05:00
DemodulatorPreThread(DemodulatorThreadInputQueue* pQueueIn, DemodulatorThreadPostInputQueue* pQueueOut,
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;
}
2014-12-16 21:30:03 -05:00
void setAudioInputQueue(AudioThreadInputQueue *tQueue) {
audioInputQueue = 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();
2014-12-16 21:30:03 -05:00
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:
2014-12-16 21:30:03 -05:00
DemodulatorThreadInputQueue* inputQueue;
DemodulatorThreadPostInputQueue* postInputQueue;
DemodulatorThreadCommandQueue* commandQueue;
AudioThreadInputQueue *audioInputQueue;
2014-11-16 16:51:45 -05:00
2014-12-16 21:30:03 -05:00
msresamp_crcf resampler;
double resample_ratio;
2014-11-16 16:51:45 -05:00
msresamp_rrrf audio_resampler;
2014-12-26 21:55:13 -05:00
msresamp_rrrf stereo_resampler;
double audio_resample_ratio;
2014-11-16 16:51:45 -05:00
2014-12-16 21:30:03 -05:00
DemodulatorThreadParameters params;
DemodulatorThreadParameters last_params;
2014-12-16 21:30:03 -05:00
freqdem fdem;
nco_crcf nco_shift;
int shift_freq;
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
};