diff --git a/src/IOThread.h b/src/IOThread.h index ac3e36b..f67b81e 100644 --- a/src/IOThread.h +++ b/src/IOThread.h @@ -45,6 +45,10 @@ template class ReBuffer { public: + ReBuffer(std::string bufferId) : bufferId(bufferId) { + + } + BufferType *getBuffer() { BufferType* buf = NULL; for (outputBuffersI = outputBuffers.begin(); outputBuffersI != outputBuffers.end(); outputBuffersI++) { @@ -65,10 +69,11 @@ public: return buf; } -// if (outputBuffers.size() > 100) { -// std::cout << "Buffer over 100.." << std::endl; -// } - +#define REBUFFER_WARNING_THRESHOLD 100 + if (outputBuffers.size() > REBUFFER_WARNING_THRESHOLD) { + std::cout << "Warning: ReBuffer '" << bufferId << "' count '" << outputBuffers.size() << "' exceeds threshold of '" << REBUFFER_WARNING_THRESHOLD << "'" << std::endl; + } + buf = new BufferType(); outputBuffers.push_back(buf); @@ -83,6 +88,7 @@ public: } } private: + std::string bufferId; std::deque outputBuffers; typename std::deque::iterator outputBuffersI; }; diff --git a/src/demod/DemodulatorPreThread.cpp b/src/demod/DemodulatorPreThread.cpp index f79eebf..8175ea9 100644 --- a/src/demod/DemodulatorPreThread.cpp +++ b/src/demod/DemodulatorPreThread.cpp @@ -53,7 +53,7 @@ void DemodulatorPreThread::run() { std::cout << "Demodulator preprocessor thread started.." << std::endl; - ReBuffer buffers; + ReBuffer buffers("DemodulatorPreThreadBuffers"); iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput"); iqOutputQueue = (DemodulatorThreadPostInputQueue*)getOutputQueue("IQDataOutput"); diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index a7db28e..c04324e 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -12,7 +12,7 @@ #include #endif -DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent) : IOThread(), squelchLevel(-100), signalLevel(-100), squelchEnabled(false), cModem(nullptr), cModemKit(nullptr), iqInputQueue(NULL), audioOutputQueue(NULL), audioVisOutputQueue(NULL), threadQueueControl(NULL), threadQueueNotify(NULL) { +DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent) : IOThread(), squelchLevel(-100), signalLevel(-100), squelchEnabled(false), cModem(nullptr), cModemKit(nullptr), iqInputQueue(NULL), audioOutputQueue(NULL), audioVisOutputQueue(NULL), threadQueueControl(NULL), threadQueueNotify(NULL), outputBuffers("DemodulatorThreadBuffers") { demodInstance = parent; muted.store(false); @@ -57,7 +57,7 @@ void DemodulatorThread::run() { pthread_setschedparam(tID, SCHED_FIFO, &prio); #endif - ReBuffer audioVisBuffers; + ReBuffer audioVisBuffers("DemodulatorThreadAudioBuffers"); std::cout << "Demodulator thread started.." << std::endl; diff --git a/src/process/FFTDataDistributor.cpp b/src/process/FFTDataDistributor.cpp index db121fe..9cad4f9 100644 --- a/src/process/FFTDataDistributor.cpp +++ b/src/process/FFTDataDistributor.cpp @@ -1,6 +1,6 @@ #include "FFTDataDistributor.h" -FFTDataDistributor::FFTDataDistributor() : fftSize(DEFAULT_FFT_SIZE), linesPerSecond(DEFAULT_WATERFALL_LPS), lineRateAccum(0.0) { +FFTDataDistributor::FFTDataDistributor() : fftSize(DEFAULT_FFT_SIZE), linesPerSecond(DEFAULT_WATERFALL_LPS), lineRateAccum(0.0), outputBuffers("FFTDataDistributorBuffers") { bufferedItems = 0; } diff --git a/src/process/ScopeVisualProcessor.cpp b/src/process/ScopeVisualProcessor.cpp index 19eb794..0580c41 100644 --- a/src/process/ScopeVisualProcessor.cpp +++ b/src/process/ScopeVisualProcessor.cpp @@ -2,7 +2,7 @@ #include #include -ScopeVisualProcessor::ScopeVisualProcessor(): fftInData(NULL), fftwOutput(NULL), fftw_plan(NULL), maxScopeSamples(1024) { +ScopeVisualProcessor::ScopeVisualProcessor(): fftInData(NULL), fftwOutput(NULL), fftw_plan(NULL), maxScopeSamples(1024), outputBuffers("ScopeVisualProcessorBuffers") { scopeEnabled.store(true); spectrumEnabled.store(true); fft_average_rate = 0.65; diff --git a/src/process/SpectrumVisualProcessor.cpp b/src/process/SpectrumVisualProcessor.cpp index 4174ccf..e767c16 100644 --- a/src/process/SpectrumVisualProcessor.cpp +++ b/src/process/SpectrumVisualProcessor.cpp @@ -2,7 +2,7 @@ #include "CubicSDR.h" -SpectrumVisualProcessor::SpectrumVisualProcessor() : lastInputBandwidth(0), lastBandwidth(0), fftwInput(NULL), fftwOutput(NULL), fftInData(NULL), fftLastData(NULL), lastDataSize(0), fftw_plan(NULL), resampler(NULL), resamplerRatio(0) { +SpectrumVisualProcessor::SpectrumVisualProcessor() : lastInputBandwidth(0), lastBandwidth(0), fftwInput(NULL), fftwOutput(NULL), fftInData(NULL), fftLastData(NULL), lastDataSize(0), fftw_plan(NULL), resampler(NULL), resamplerRatio(0), outputBuffers("SpectrumVisualProcessorBuffers") { is_view.store(false); fftSize.store(0); diff --git a/src/sdr/SDRPostThread.cpp b/src/sdr/SDRPostThread.cpp index 301696c..45b7940 100644 --- a/src/sdr/SDRPostThread.cpp +++ b/src/sdr/SDRPostThread.cpp @@ -5,7 +5,7 @@ #include #include -SDRPostThread::SDRPostThread() : IOThread() { +SDRPostThread::SDRPostThread() : IOThread(), buffers("SDRPostThreadBuffers"), visualDataBuffers("SDRPostThreadVisualDataBuffers") { iqDataInQueue = NULL; iqDataOutQueue = NULL; iqVisualQueue = NULL; @@ -238,7 +238,7 @@ void SDRPostThread::run() { firpfbch_crcf_analyzer_execute(channelizer, &data_in->data[i], &dataOut[i]); } - for (int i = 0, iMax = numChannels; i < iMax; i++) { + for (int i = 0, iMax = numChannels+1; i < iMax; i++) { demodChannelActive[i] = 0; } @@ -276,6 +276,8 @@ void SDRPostThread::run() { demodDataOut->frequency = chanCenters[i]; demodDataOut->sampleRate = chanBw; +// std::cout << "Active channel(" << i << "/" << numChannels << ") nRunDemods:" << nRunDemods << ", doVis: " << doVis << ", demodVis: " << doDemodVis << std::endl; + // Calculate channel buffer size int chanDataSize = (outSize/numChannels); diff --git a/src/sdr/SoapySDRThread.cpp b/src/sdr/SoapySDRThread.cpp index 8b80dc3..73db214 100644 --- a/src/sdr/SoapySDRThread.cpp +++ b/src/sdr/SoapySDRThread.cpp @@ -5,7 +5,7 @@ #include -SDRThread::SDRThread() : IOThread() { +SDRThread::SDRThread() : IOThread(), buffers("SDRThreadBuffers") { device = NULL; deviceConfig.store(NULL);