1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

AM and NFM demod: sanitize tail fill audio sink FIFO

This commit is contained in:
f4exb 2018-02-18 14:46:36 +01:00
parent 1e23bb4ec6
commit 28a4649e2f
4 changed files with 14 additions and 3 deletions

View File

@ -41,6 +41,7 @@ AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_inputSampleRate(48000),
m_inputFrequencyOffset(0),
m_running(false),
m_squelchOpen(false),
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
@ -110,7 +111,7 @@ void AMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector
}
}
if (m_audioBufferFill > 0)
if (m_running && (m_audioBufferFill > 0))
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
@ -131,10 +132,13 @@ void AMDemod::start()
m_squelchCount = 0;
m_audioFifo.clear();
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);
m_running = true;
}
void AMDemod::stop()
{
qDebug("AMDemod::stop");
m_running = false;
}
bool AMDemod::handleMessage(const Message& cmd)

View File

@ -129,6 +129,7 @@ private:
int m_inputSampleRate;
int m_inputFrequencyOffset;
AMDemodSettings m_settings;
bool m_running;
NCO m_nco;
Interpolator m_interpolator;
@ -227,7 +228,8 @@ private:
if (res != m_audioBufferFill)
{
qDebug("AMDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
qDebug("AMDemod::processOneSample: %u/%u audio samples written", res, m_audioBufferFill);
m_audioFifo.clear();
}
m_audioBufferFill = 0;

View File

@ -50,6 +50,7 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
m_deviceAPI(devieAPI),
m_inputSampleRate(48000),
m_inputFrequencyOffset(0),
m_running(false),
m_ctcssIndex(0),
m_sampleCount(0),
m_squelchCount(0),
@ -307,7 +308,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
}
}
if (m_audioBufferFill > 0)
if (m_running && (m_audioBufferFill > 0))
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
@ -329,10 +330,13 @@ void NFMDemod::start()
m_audioFifo.clear();
m_phaseDiscri.reset();
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);
m_running = true;
}
void NFMDemod::stop()
{
qDebug() << "NFMDemod::stop";
m_running = false;
}
bool NFMDemod::handleMessage(const Message& cmd)

View File

@ -175,6 +175,7 @@ private:
int m_inputSampleRate;
int m_inputFrequencyOffset;
NFMDemodSettings m_settings;
bool m_running;
NCO m_nco;
Interpolator m_interpolator;