mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-06 15:17:49 -04:00
Increase demodulator stack size on OSX
Using pthreads as a drop-in, should work since underlying is already pthreads?
This commit is contained in:
parent
86ac0c59a8
commit
e668fa2b5d
@ -50,7 +50,22 @@ void DemodulatorInstance::run() {
|
||||
}
|
||||
|
||||
t_Audio = new std::thread(&AudioThread::threadMain, audioThread);
|
||||
|
||||
#ifdef __APPLE__ // Already using pthreads, might as well do some custom init..
|
||||
pthread_attr_t attr;
|
||||
size_t size;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setstacksize(&attr, 2048000);
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
pthread_create(&t_Demod, &attr, &DemodulatorThread::pthread_helper, demodulatorThread);
|
||||
pthread_attr_destroy(&attr);
|
||||
|
||||
std::cout << "Initialized demodulator stack size of " << size << std::endl;
|
||||
|
||||
#else
|
||||
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() {
|
||||
@ -64,8 +79,11 @@ DemodulatorThreadParameters &DemodulatorInstance::getParams() {
|
||||
void DemodulatorInstance::terminate() {
|
||||
std::cout << "Terminating demodulator thread.." << std::endl;
|
||||
demodulatorThread->terminate();
|
||||
#ifdef __APPLE__
|
||||
pthread_join(t_Demod,NULL);
|
||||
#else
|
||||
t_Demod->join();
|
||||
|
||||
#endif
|
||||
std::cout << "Terminating demodulator audio thread.." << std::endl;
|
||||
audioThread->terminate();
|
||||
t_Audio->join();
|
||||
|
@ -12,7 +12,11 @@ public:
|
||||
DemodulatorThreadInputQueue* threadQueueDemod;
|
||||
DemodulatorThreadCommandQueue* threadQueueCommand;
|
||||
DemodulatorThread *demodulatorThread;
|
||||
#ifdef __APPLE__
|
||||
pthread_t t_Demod;
|
||||
#else
|
||||
std::thread *t_Demod;
|
||||
#endif
|
||||
|
||||
AudioThreadInputQueue *audioInputQueue;
|
||||
AudioThread *audioThread;
|
||||
|
@ -2,6 +2,10 @@
|
||||
#include "CubicSDRDefs.h"
|
||||
#include <vector>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
DemodulatorThread::DemodulatorThread(DemodulatorThreadInputQueue* pQueue) :
|
||||
inputQueue(pQueue), visOutQueue(NULL), terminated(false), initialized(false), audio_resampler(NULL), resample_ratio(1), audio_resample_ratio(
|
||||
1), resampler(NULL), commandQueue(NULL), fir_filter(NULL), audioInputQueue(NULL) {
|
||||
@ -76,7 +80,11 @@ DemodulatorThread::~DemodulatorThread() {
|
||||
delete workerResults;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
void *DemodulatorThread::threadMain() {
|
||||
#else
|
||||
void DemodulatorThread::threadMain() {
|
||||
#endif
|
||||
|
||||
if (!initialized) {
|
||||
initialize();
|
||||
|
@ -17,13 +17,19 @@
|
||||
#include "DemodulatorWorkerThread.h"
|
||||
|
||||
enum DemodulatorType {
|
||||
DEMOD_TYPE_NULL, DEMOD_TYPE_AM, DEMOD_TYPE_FM, DEMOD_TYPE_LSB, DEMOD_TYPE_USB
|
||||
DEMOD_TYPE_NULL,
|
||||
DEMOD_TYPE_AM,
|
||||
DEMOD_TYPE_FM,
|
||||
DEMOD_TYPE_LSB,
|
||||
DEMOD_TYPE_USB
|
||||
};
|
||||
|
||||
class DemodulatorThreadCommand {
|
||||
public:
|
||||
enum DemodulatorThreadCommandEnum {
|
||||
DEMOD_THREAD_CMD_NULL, DEMOD_THREAD_CMD_SET_BANDWIDTH, DEMOD_THREAD_CMD_SET_FREQUENCY
|
||||
DEMOD_THREAD_CMD_NULL,
|
||||
DEMOD_THREAD_CMD_SET_BANDWIDTH,
|
||||
DEMOD_THREAD_CMD_SET_FREQUENCY
|
||||
};
|
||||
|
||||
DemodulatorThreadCommand() :
|
||||
@ -51,7 +57,8 @@ public:
|
||||
|
||||
}
|
||||
|
||||
DemodulatorThreadIQData(unsigned int bandwidth, unsigned int frequency, std::vector<signed char> data) :
|
||||
DemodulatorThreadIQData(unsigned int bandwidth, unsigned int frequency,
|
||||
std::vector<signed char> data) :
|
||||
data(data), frequency(frequency), bandwidth(bandwidth) {
|
||||
|
||||
}
|
||||
@ -74,8 +81,10 @@ public:
|
||||
|
||||
}
|
||||
|
||||
DemodulatorThreadAudioData(unsigned int frequency, unsigned int sampleRate, std::vector<float> data) :
|
||||
data(data), sampleRate(sampleRate), frequency(frequency), channels(1) {
|
||||
DemodulatorThreadAudioData(unsigned int frequency, unsigned int sampleRate,
|
||||
std::vector<float> data) :
|
||||
data(data), sampleRate(sampleRate), frequency(frequency), channels(
|
||||
1) {
|
||||
|
||||
}
|
||||
|
||||
@ -94,7 +103,8 @@ public:
|
||||
DemodulatorType demodType;
|
||||
|
||||
DemodulatorThreadParameters() :
|
||||
frequency(0), inputRate(SRATE), bandwidth(200000), audioSampleRate(AUDIO_FREQUENCY), demodType(DEMOD_TYPE_FM) {
|
||||
frequency(0), inputRate(SRATE), bandwidth(200000), audioSampleRate(
|
||||
AUDIO_FREQUENCY), demodType(DEMOD_TYPE_FM) {
|
||||
|
||||
}
|
||||
|
||||
@ -107,14 +117,17 @@ typedef ThreadQueue<DemodulatorThreadIQData> DemodulatorThreadInputQueue;
|
||||
typedef ThreadQueue<AudioThreadInput> DemodulatorThreadOutputQueue;
|
||||
typedef ThreadQueue<DemodulatorThreadCommand> DemodulatorThreadCommandQueue;
|
||||
|
||||
|
||||
class DemodulatorThread {
|
||||
public:
|
||||
|
||||
DemodulatorThread(DemodulatorThreadInputQueue* pQueue);
|
||||
~DemodulatorThread();
|
||||
|
||||
#ifdef __APPLE__
|
||||
void *threadMain();
|
||||
#else
|
||||
void threadMain();
|
||||
#endif
|
||||
|
||||
void setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {
|
||||
visOutQueue = tQueue;
|
||||
@ -137,6 +150,12 @@ public:
|
||||
|
||||
void terminate();
|
||||
|
||||
#ifdef __APPLE__
|
||||
static void *pthread_helper(void *context) {
|
||||
return ((DemodulatorThread *) context)->threadMain();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
DemodulatorThreadInputQueue* inputQueue;
|
||||
DemodulatorThreadOutputQueue* visOutQueue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user