mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 21:58:37 -05:00
Merge pull request #212 from cjcliffe/memory_leak1
Add ReBuffer buffer count warning, fix SDRPostThread off-by-one error
This commit is contained in:
commit
4b53dab47f
@ -45,6 +45,10 @@ template<class BufferType = ReferenceCounter>
|
|||||||
class ReBuffer {
|
class ReBuffer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ReBuffer(std::string bufferId) : bufferId(bufferId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
BufferType *getBuffer() {
|
BufferType *getBuffer() {
|
||||||
BufferType* buf = NULL;
|
BufferType* buf = NULL;
|
||||||
for (outputBuffersI = outputBuffers.begin(); outputBuffersI != outputBuffers.end(); outputBuffersI++) {
|
for (outputBuffersI = outputBuffers.begin(); outputBuffersI != outputBuffers.end(); outputBuffersI++) {
|
||||||
@ -65,9 +69,10 @@ public:
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (outputBuffers.size() > 100) {
|
#define REBUFFER_WARNING_THRESHOLD 100
|
||||||
// std::cout << "Buffer over 100.." << std::endl;
|
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();
|
buf = new BufferType();
|
||||||
outputBuffers.push_back(buf);
|
outputBuffers.push_back(buf);
|
||||||
@ -83,6 +88,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
std::string bufferId;
|
||||||
std::deque<BufferType*> outputBuffers;
|
std::deque<BufferType*> outputBuffers;
|
||||||
typename std::deque<BufferType*>::iterator outputBuffersI;
|
typename std::deque<BufferType*>::iterator outputBuffersI;
|
||||||
};
|
};
|
||||||
|
@ -53,7 +53,7 @@ void DemodulatorPreThread::run() {
|
|||||||
|
|
||||||
std::cout << "Demodulator preprocessor thread started.." << std::endl;
|
std::cout << "Demodulator preprocessor thread started.." << std::endl;
|
||||||
|
|
||||||
ReBuffer<DemodulatorThreadPostIQData> buffers;
|
ReBuffer<DemodulatorThreadPostIQData> buffers("DemodulatorPreThreadBuffers");
|
||||||
|
|
||||||
iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput");
|
iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput");
|
||||||
iqOutputQueue = (DemodulatorThreadPostInputQueue*)getOutputQueue("IQDataOutput");
|
iqOutputQueue = (DemodulatorThreadPostInputQueue*)getOutputQueue("IQDataOutput");
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#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;
|
demodInstance = parent;
|
||||||
muted.store(false);
|
muted.store(false);
|
||||||
@ -57,7 +57,7 @@ void DemodulatorThread::run() {
|
|||||||
pthread_setschedparam(tID, SCHED_FIFO, &prio);
|
pthread_setschedparam(tID, SCHED_FIFO, &prio);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ReBuffer<AudioThreadInput> audioVisBuffers;
|
ReBuffer<AudioThreadInput> audioVisBuffers("DemodulatorThreadAudioBuffers");
|
||||||
|
|
||||||
std::cout << "Demodulator thread started.." << std::endl;
|
std::cout << "Demodulator thread started.." << std::endl;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "FFTDataDistributor.h"
|
#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;
|
bufferedItems = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
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);
|
scopeEnabled.store(true);
|
||||||
spectrumEnabled.store(true);
|
spectrumEnabled.store(true);
|
||||||
fft_average_rate = 0.65;
|
fft_average_rate = 0.65;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "CubicSDR.h"
|
#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);
|
is_view.store(false);
|
||||||
fftSize.store(0);
|
fftSize.store(0);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
SDRPostThread::SDRPostThread() : IOThread() {
|
SDRPostThread::SDRPostThread() : IOThread(), buffers("SDRPostThreadBuffers"), visualDataBuffers("SDRPostThreadVisualDataBuffers") {
|
||||||
iqDataInQueue = NULL;
|
iqDataInQueue = NULL;
|
||||||
iqDataOutQueue = NULL;
|
iqDataOutQueue = NULL;
|
||||||
iqVisualQueue = NULL;
|
iqVisualQueue = NULL;
|
||||||
@ -238,7 +238,7 @@ void SDRPostThread::run() {
|
|||||||
firpfbch_crcf_analyzer_execute(channelizer, &data_in->data[i], &dataOut[i]);
|
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;
|
demodChannelActive[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +276,8 @@ void SDRPostThread::run() {
|
|||||||
demodDataOut->frequency = chanCenters[i];
|
demodDataOut->frequency = chanCenters[i];
|
||||||
demodDataOut->sampleRate = chanBw;
|
demodDataOut->sampleRate = chanBw;
|
||||||
|
|
||||||
|
// std::cout << "Active channel(" << i << "/" << numChannels << ") nRunDemods:" << nRunDemods << ", doVis: " << doVis << ", demodVis: " << doDemodVis << std::endl;
|
||||||
|
|
||||||
// Calculate channel buffer size
|
// Calculate channel buffer size
|
||||||
int chanDataSize = (outSize/numChannels);
|
int chanDataSize = (outSize/numChannels);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
SDRThread::SDRThread() : IOThread() {
|
SDRThread::SDRThread() : IOThread(), buffers("SDRThreadBuffers") {
|
||||||
device = NULL;
|
device = NULL;
|
||||||
|
|
||||||
deviceConfig.store(NULL);
|
deviceConfig.store(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user