2014-11-16 16:51:45 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-11-22 22:17:33 -05:00
|
|
|
#include "CubicSDRDefs.h"
|
2014-12-11 19:07:21 -05:00
|
|
|
#include "DemodDefs.h"
|
2014-12-16 18:27:02 -05:00
|
|
|
#include "DemodulatorWorkerThread.h"
|
2014-11-22 22:17:33 -05:00
|
|
|
|
2014-12-16 18:27:02 -05:00
|
|
|
class DemodulatorPreThread {
|
2014-11-16 16:51:45 -05:00
|
|
|
public:
|
2014-11-17 22:58:56 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
DemodulatorPreThread(DemodulatorThreadInputQueue* pQueueIn, DemodulatorThreadPostInputQueue* pQueueOut,
|
2014-12-21 16:08:32 -05:00
|
|
|
DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify);
|
2014-12-16 21:30:03 -05:00
|
|
|
~DemodulatorPreThread();
|
2014-12-01 18:59:07 -05:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2014-12-16 21:30:03 -05:00
|
|
|
void *threadMain();
|
2014-12-01 18:59:07 -05:00
|
|
|
#else
|
2014-12-16 21:30:03 -05:00
|
|
|
void threadMain();
|
2014-12-01 18:59:07 -05:00
|
|
|
#endif
|
2014-11-16 16:51:45 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
void setCommandQueue(DemodulatorThreadCommandQueue *tQueue) {
|
|
|
|
commandQueue = tQueue;
|
|
|
|
}
|
2014-11-22 22:17:33 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
void setAudioInputQueue(AudioThreadInputQueue *tQueue) {
|
|
|
|
audioInputQueue = tQueue;
|
|
|
|
}
|
2014-11-26 21:05:19 -05:00
|
|
|
|
2014-12-21 16:08:32 -05:00
|
|
|
void setDemodulatorControlQueue(DemodulatorThreadControlCommandQueue *tQueue) {
|
|
|
|
threadQueueControl = tQueue;
|
|
|
|
}
|
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
DemodulatorThreadParameters &getParams() {
|
|
|
|
return params;
|
|
|
|
}
|
2014-11-30 17:11:29 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
void initialize();
|
2014-11-26 21:05:19 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
void terminate();
|
2014-11-26 21:05:19 -05:00
|
|
|
|
2014-12-01 18:59:07 -05:00
|
|
|
#ifdef __APPLE__
|
2014-12-16 21:30:03 -05:00
|
|
|
static void *pthread_helper(void *context) {
|
|
|
|
return ((DemodulatorPreThread *) context)->threadMain();
|
|
|
|
}
|
2014-12-01 18:59:07 -05:00
|
|
|
#endif
|
2014-11-23 19:39:27 -05:00
|
|
|
|
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;
|
2014-12-29 00:24:10 -05:00
|
|
|
double resample_ratio;
|
2014-11-16 16:51:45 -05:00
|
|
|
|
2014-12-21 17:37:41 -05:00
|
|
|
msresamp_rrrf audio_resampler;
|
2014-12-26 21:55:13 -05:00
|
|
|
msresamp_rrrf stereo_resampler;
|
2014-12-29 00:24:10 -05:00
|
|
|
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-11-26 22:29:23 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
freqdem fdem;
|
|
|
|
nco_crcf nco_shift;
|
|
|
|
int shift_freq;
|
2014-11-27 22:13:21 -05:00
|
|
|
|
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;
|
2014-12-21 16:08:32 -05:00
|
|
|
DemodulatorThreadControlCommandQueue *threadQueueControl;
|
2014-11-16 16:51:45 -05:00
|
|
|
};
|