mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
Fixed segfault while changing center frequency or sample rate
This commit is contained in:
parent
e784cf7f7f
commit
ed0d613f10
@ -2,6 +2,7 @@
|
||||
#define INCLUDE_CHANNELIZER_H
|
||||
|
||||
#include <list>
|
||||
#include <QMutex>
|
||||
#include "dsp/samplesink.h"
|
||||
#include "util/export.h"
|
||||
#include "util/message.h"
|
||||
@ -70,6 +71,7 @@ protected:
|
||||
int m_currentOutputSampleRate;
|
||||
int m_currentCenterFrequency;
|
||||
SampleVector m_sampleBuffer;
|
||||
QMutex m_mutex;
|
||||
|
||||
void applyConfiguration();
|
||||
bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const;
|
||||
@ -81,53 +83,3 @@ signals:
|
||||
};
|
||||
|
||||
#endif // INCLUDE_CHANNELIZER_H
|
||||
|
||||
#if 0
|
||||
|
||||
#ifndef INCLUDE_CHANNELIZER_H
|
||||
#define INCLUDE_CHANNELIZER_H
|
||||
|
||||
#include "samplesink.h"
|
||||
#include "spectrum.h"
|
||||
#include "nco.h"
|
||||
#include "interpolator.h"
|
||||
#include "pidcontroller.h"
|
||||
#include "hardware/audiofifo.h"
|
||||
|
||||
class AudioOutput;
|
||||
|
||||
class Channelizer : public SampleSink {
|
||||
public:
|
||||
Channelizer();
|
||||
~Channelizer();
|
||||
|
||||
#if 0
|
||||
void setGLSpectrum(GLSpectrum* glSpectrum);
|
||||
#endif
|
||||
|
||||
size_t workUnitSize();
|
||||
size_t work(SampleVector::const_iterator begin, SampleVector::const_iterator end);
|
||||
|
||||
private:
|
||||
#if 0
|
||||
NCO m_nco;
|
||||
Interpolator m_interpolator;
|
||||
Real m_distance;
|
||||
Interpolator m_interpolator2;
|
||||
Real m_distance2;
|
||||
|
||||
SampleVector m_buffer;
|
||||
size_t m_bufferFill;
|
||||
Complex m_lastSample;
|
||||
|
||||
AudioOutput* m_audioOutput;
|
||||
AudioFifo m_audioFifo;
|
||||
Real m_resampler;
|
||||
PIDController m_resamplerCtrl;
|
||||
|
||||
Spectrum m_spectrum;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // INCLUDE_CHANNELIZER_H
|
||||
#endif
|
||||
|
@ -37,17 +37,28 @@ void Channelizer::feed(const SampleVector::const_iterator& begin, const SampleVe
|
||||
return;
|
||||
}
|
||||
|
||||
for(SampleVector::const_iterator sample = begin; sample != end; ++sample) {
|
||||
m_mutex.lock();
|
||||
|
||||
for(SampleVector::const_iterator sample = begin; sample != end; ++sample)
|
||||
{
|
||||
Sample s(*sample);
|
||||
FilterStages::iterator stage = m_filterStages.begin();
|
||||
while(stage != m_filterStages.end()) {
|
||||
|
||||
for (; stage != m_filterStages.end(); ++stage)
|
||||
{
|
||||
if(!(*stage)->work(&s))
|
||||
{
|
||||
break;
|
||||
++stage;
|
||||
}
|
||||
}
|
||||
|
||||
if(stage == m_filterStages.end())
|
||||
{
|
||||
m_sampleBuffer.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
m_mutex.unlock();
|
||||
|
||||
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
|
||||
m_sampleBuffer.clear();
|
||||
@ -125,12 +136,16 @@ void Channelizer::applyConfiguration()
|
||||
return;
|
||||
}
|
||||
|
||||
m_mutex.lock();
|
||||
|
||||
freeFilterChain();
|
||||
|
||||
m_currentCenterFrequency = createFilterChain(
|
||||
m_inputSampleRate / -2, m_inputSampleRate / 2,
|
||||
m_requestedCenterFrequency - m_requestedOutputSampleRate / 2, m_requestedCenterFrequency + m_requestedOutputSampleRate / 2);
|
||||
|
||||
m_mutex.unlock();
|
||||
|
||||
m_currentOutputSampleRate = m_inputSampleRate / (1 << m_filterStages.size());
|
||||
|
||||
qDebug() << "Channelizer::applyConfiguration in=" << m_inputSampleRate
|
||||
|
Loading…
Reference in New Issue
Block a user