mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-07 07:38:00 -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);
|
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);
|
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() {
|
DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() {
|
||||||
@ -64,8 +79,11 @@ DemodulatorThreadParameters &DemodulatorInstance::getParams() {
|
|||||||
void DemodulatorInstance::terminate() {
|
void DemodulatorInstance::terminate() {
|
||||||
std::cout << "Terminating demodulator thread.." << std::endl;
|
std::cout << "Terminating demodulator thread.." << std::endl;
|
||||||
demodulatorThread->terminate();
|
demodulatorThread->terminate();
|
||||||
|
#ifdef __APPLE__
|
||||||
|
pthread_join(t_Demod,NULL);
|
||||||
|
#else
|
||||||
t_Demod->join();
|
t_Demod->join();
|
||||||
|
#endif
|
||||||
std::cout << "Terminating demodulator audio thread.." << std::endl;
|
std::cout << "Terminating demodulator audio thread.." << std::endl;
|
||||||
audioThread->terminate();
|
audioThread->terminate();
|
||||||
t_Audio->join();
|
t_Audio->join();
|
||||||
|
@ -12,7 +12,11 @@ public:
|
|||||||
DemodulatorThreadInputQueue* threadQueueDemod;
|
DemodulatorThreadInputQueue* threadQueueDemod;
|
||||||
DemodulatorThreadCommandQueue* threadQueueCommand;
|
DemodulatorThreadCommandQueue* threadQueueCommand;
|
||||||
DemodulatorThread *demodulatorThread;
|
DemodulatorThread *demodulatorThread;
|
||||||
|
#ifdef __APPLE__
|
||||||
|
pthread_t t_Demod;
|
||||||
|
#else
|
||||||
std::thread *t_Demod;
|
std::thread *t_Demod;
|
||||||
|
#endif
|
||||||
|
|
||||||
AudioThreadInputQueue *audioInputQueue;
|
AudioThreadInputQueue *audioInputQueue;
|
||||||
AudioThread *audioThread;
|
AudioThread *audioThread;
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#include "CubicSDRDefs.h"
|
#include "CubicSDRDefs.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
DemodulatorThread::DemodulatorThread(DemodulatorThreadInputQueue* pQueue) :
|
DemodulatorThread::DemodulatorThread(DemodulatorThreadInputQueue* pQueue) :
|
||||||
inputQueue(pQueue), visOutQueue(NULL), terminated(false), initialized(false), audio_resampler(NULL), resample_ratio(1), audio_resample_ratio(
|
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) {
|
1), resampler(NULL), commandQueue(NULL), fir_filter(NULL), audioInputQueue(NULL) {
|
||||||
@ -76,7 +80,11 @@ DemodulatorThread::~DemodulatorThread() {
|
|||||||
delete workerResults;
|
delete workerResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
void *DemodulatorThread::threadMain() {
|
||||||
|
#else
|
||||||
void DemodulatorThread::threadMain() {
|
void DemodulatorThread::threadMain() {
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialize();
|
initialize();
|
||||||
|
@ -17,13 +17,19 @@
|
|||||||
#include "DemodulatorWorkerThread.h"
|
#include "DemodulatorWorkerThread.h"
|
||||||
|
|
||||||
enum DemodulatorType {
|
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 {
|
class DemodulatorThreadCommand {
|
||||||
public:
|
public:
|
||||||
enum DemodulatorThreadCommandEnum {
|
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() :
|
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) {
|
data(data), frequency(frequency), bandwidth(bandwidth) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -74,8 +81,10 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorThreadAudioData(unsigned int frequency, unsigned int sampleRate, std::vector<float> data) :
|
DemodulatorThreadAudioData(unsigned int frequency, unsigned int sampleRate,
|
||||||
data(data), sampleRate(sampleRate), frequency(frequency), channels(1) {
|
std::vector<float> data) :
|
||||||
|
data(data), sampleRate(sampleRate), frequency(frequency), channels(
|
||||||
|
1) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +103,8 @@ public:
|
|||||||
DemodulatorType demodType;
|
DemodulatorType demodType;
|
||||||
|
|
||||||
DemodulatorThreadParameters() :
|
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<AudioThreadInput> DemodulatorThreadOutputQueue;
|
||||||
typedef ThreadQueue<DemodulatorThreadCommand> DemodulatorThreadCommandQueue;
|
typedef ThreadQueue<DemodulatorThreadCommand> DemodulatorThreadCommandQueue;
|
||||||
|
|
||||||
|
|
||||||
class DemodulatorThread {
|
class DemodulatorThread {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DemodulatorThread(DemodulatorThreadInputQueue* pQueue);
|
DemodulatorThread(DemodulatorThreadInputQueue* pQueue);
|
||||||
~DemodulatorThread();
|
~DemodulatorThread();
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
void *threadMain();
|
||||||
|
#else
|
||||||
void threadMain();
|
void threadMain();
|
||||||
|
#endif
|
||||||
|
|
||||||
void setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {
|
void setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {
|
||||||
visOutQueue = tQueue;
|
visOutQueue = tQueue;
|
||||||
@ -137,6 +150,12 @@ public:
|
|||||||
|
|
||||||
void terminate();
|
void terminate();
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static void *pthread_helper(void *context) {
|
||||||
|
return ((DemodulatorThread *) context)->threadMain();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DemodulatorThreadInputQueue* inputQueue;
|
DemodulatorThreadInputQueue* inputQueue;
|
||||||
DemodulatorThreadOutputQueue* visOutQueue;
|
DemodulatorThreadOutputQueue* visOutQueue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user