Really fix TX Buffer ovrflows,, reduce delay buffer memory footprint

This commit is contained in:
Geoffrey Merck 2020-05-14 09:10:11 +02:00
parent b245be464f
commit cfcb7ed852
1 changed files with 21 additions and 4 deletions

25
FM.cpp
View File

@ -54,7 +54,7 @@ m_extAudioBoost(1U),
m_downsampler(400U),// 100 ms of audio m_downsampler(400U),// 100 ms of audio
m_extEnabled(false), m_extEnabled(false),
m_rxLevel(1), m_rxLevel(1),
m_inputRFRB(4800U), // 200ms of audio m_inputRFRB(2401U), // 100ms of audio + 1 sample
m_outputRFRB(2400U), // 100ms of audio m_outputRFRB(2400U), // 100ms of audio
m_inputExtRB(2400U) // 100ms of Audio m_inputExtRB(2400U) // 100ms of Audio
{ {
@ -152,9 +152,26 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length)
void CFM::process() void CFM::process()
{ {
q15_t sample; uint16_t space = io.getSpace();
while (io.getSpace() >= 3U && m_outputRFRB.get(sample)) { uint16_t length = m_outputRFRB.getData();
io.write(STATE_FM, &sample, 1); if (space > FM_TX_BLOCK_SIZE && length >= FM_TX_BLOCK_SIZE ) {
if(length > FM_TX_BLOCK_SIZE)
length = FM_TX_BLOCK_SIZE;
if(space > FM_TX_BLOCK_SIZE)
space = FM_TX_BLOCK_SIZE;
if(length > space)
length = space;
q15_t samples[FM_TX_BLOCK_SIZE];
for (uint16_t i = 0U; i < length; i++) {
q15_t sample = 0;
m_outputRFRB.get(sample);
samples[i] = sample;
}
io.write(STATE_FM, samples, length);
} }
if(m_extEnabled) { if(m_extEnabled) {