1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 09:18:54 -05:00

Do not write tail audio samples and write to sample buffer only if necessary. May fix #1132

This commit is contained in:
f4exb 2022-02-08 00:55:31 +01:00
parent 590c4ef352
commit e4b9bc7680
9 changed files with 11 additions and 99 deletions

View File

@ -95,17 +95,6 @@ void AMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleVe
} }
} }
} }
if (m_audioBufferFill > 0)
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("AMDemodSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
} }
void AMDemodSink::processOneSample(Complex &ci) void AMDemodSink::processOneSample(Complex &ci)

View File

@ -72,7 +72,7 @@ BFMDemodSink::BFMDemodSink() :
m_deemphasisFilterY.configure(default_deemphasis * m_audioSampleRate * 1.0e-6); m_deemphasisFilterY.configure(default_deemphasis * m_audioSampleRate * 1.0e-6);
m_phaseDiscri.setFMScaling(384000/m_fmExcursion); m_phaseDiscri.setFMScaling(384000/m_fmExcursion);
m_audioBuffer.resize(16384); m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0; m_audioBufferFill = 0;
applySettings(m_settings, true); applySettings(m_settings, true);
@ -229,22 +229,11 @@ void BFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
} }
} }
if (m_audioBufferFill > 0) if (m_spectrumSink && (m_sampleBuffer.size() != 0))
{ {
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("BFMDemodSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
if (m_spectrumSink) {
m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true); m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
m_sampleBuffer.clear();
} }
m_sampleBuffer.clear();
} }
void BFMDemodSink::applyAudioSampleRate(int sampleRate) void BFMDemodSink::applyAudioSampleRate(int sampleRate)

View File

@ -211,21 +211,11 @@ void FreeDVDemodSink::feed(const SampleVector::const_iterator& begin, const Samp
} }
} }
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill); if (m_spectrumSink && (m_sampleBuffer.size() != 0))
{
if (res != m_audioBufferFill)
{
qDebug("FreeDVDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
if (m_spectrumSink)
{
m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true); m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
m_sampleBuffer.clear();
} }
m_sampleBuffer.clear();
} }
void FreeDVDemodSink::processOneSample(Complex &ci) void FreeDVDemodSink::processOneSample(Complex &ci)

View File

@ -65,7 +65,7 @@ NFMDemodSink::NFMDemodSink() :
m_squelchDelayLine(24000), m_squelchDelayLine(24000),
m_messageQueueToGUI(nullptr) m_messageQueueToGUI(nullptr)
{ {
m_audioBuffer.resize(1<<16); m_audioBuffer.resize(1<<14);
m_demodBuffer.resize(1<<12); m_demodBuffer.resize(1<<12);
m_demodBufferFill = 0; m_demodBufferFill = 0;
@ -110,17 +110,6 @@ void NFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
} }
} }
} }
if (m_audioBufferFill > 0)
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("NFMDemodSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
} }
void NFMDemodSink::processOneSample(Complex &ci) void NFMDemodSink::processOneSample(Complex &ci)

View File

@ -241,19 +241,11 @@ void SSBDemodSink::processOneSample(Complex &ci)
} }
} }
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill); if (m_spectrumSink && (m_sampleBuffer.size() != 0))
{
if (res != m_audioBufferFill) {
qDebug("SSBDemodSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
if (m_spectrumSink != 0) {
m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), !m_dsb); m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), !m_dsb);
m_sampleBuffer.clear();
} }
m_sampleBuffer.clear();
} }
void SSBDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force) void SSBDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force)

View File

@ -100,17 +100,6 @@ void VORDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
} }
} }
} }
if (m_audioBufferFill > 0)
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("VORDemodSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
} }
void VORDemodSink::processOneAudioSample(Complex &ci) void VORDemodSink::processOneAudioSample(Complex &ci)

View File

@ -89,17 +89,6 @@ void VORDemodSCSink::feed(const SampleVector::const_iterator& begin, const Sampl
} }
} }
} }
if (m_audioBufferFill > 0)
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("VORDemodSCSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
} }
void VORDemodSCSink::processOneAudioSample(Complex &ci) void VORDemodSCSink::processOneAudioSample(Complex &ci)

View File

@ -49,7 +49,7 @@ WFMDemodSink::WFMDemodSink() :
m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, m_rfFilterFftLength); m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, m_rfFilterFftLength);
m_phaseDiscri.setFMScaling(384000/75000); m_phaseDiscri.setFMScaling(384000/75000);
m_audioBuffer.resize(16384); m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0; m_audioBufferFill = 0;
m_demodBuffer.resize(1<<12); m_demodBuffer.resize(1<<12);
@ -119,7 +119,6 @@ void WFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
if (m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci)) if (m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci))
{ {
qint16 sample = (qint16)(ci.real() * 3276.8f * m_settings.m_volume); qint16 sample = (qint16)(ci.real() * 3276.8f * m_settings.m_volume);
m_sampleBuffer.push_back(Sample(sample, sample));
m_audioBuffer[m_audioBufferFill].l = sample; m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample; m_audioBuffer[m_audioBufferFill].r = sample;
@ -158,19 +157,6 @@ void WFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
} }
} }
} }
if (m_audioBufferFill > 0)
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("WFMDemodSink::feed: %u/%u tail samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
m_sampleBuffer.clear();
} }
void WFMDemodSink::applyAudioSampleRate(int sampleRate) void WFMDemodSink::applyAudioSampleRate(int sampleRate)

View File

@ -116,7 +116,6 @@ private:
uint m_audioBufferFill; uint m_audioBufferFill;
AudioFifo m_audioFifo; AudioFifo m_audioFifo;
SampleVector m_sampleBuffer;
PhaseDiscriminators m_phaseDiscri; PhaseDiscriminators m_phaseDiscri;
QVector<qint16> m_demodBuffer; QVector<qint16> m_demodBuffer;