Small cleanups.

This commit is contained in:
Jonathan Naylor
2020-05-24 14:26:24 +01:00
parent 12e58d5440
commit 1caffc1dad

View File

@@ -21,7 +21,7 @@
#include <string> #include <string>
#if defined(DUMP_RF_AUDIO) #if defined(DUMP_RF_AUDIO)
#include <stdio.h> #include <cstdio>
#endif #endif
const float EMPHASIS_GAIN_DB = 0.0F; //Gain needs to be the same for pre an deeemphasis const float EMPHASIS_GAIN_DB = 0.0F; //Gain needs to be the same for pre an deeemphasis
@@ -57,7 +57,6 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
if (data[0U] != TAG_DATA) if (data[0U] != TAG_DATA)
return false; return false;
m_incomingRFAudio.addData(data + 1U, length - 1U); m_incomingRFAudio.addData(data + 1U, length - 1U);
unsigned int bufferLength = m_incomingRFAudio.dataSize(); unsigned int bufferLength = m_incomingRFAudio.dataSize();
if (bufferLength > 255U) if (bufferLength > 255U)
@@ -65,9 +64,8 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
if (bufferLength >= 3U) { if (bufferLength >= 3U) {
#if defined(DUMP_RF_AUDIO) #if defined(DUMP_RF_AUDIO)
FILE * audiofile = fopen("./audiodump.bin", "ab"); FILE* audiofile = ::fopen("./audiodump.bin", "ab");
#endif #endif
bufferLength = bufferLength - bufferLength % 3U; //round down to nearest multiple of 3 bufferLength = bufferLength - bufferLength % 3U; //round down to nearest multiple of 3
unsigned char bufferData[255U]; unsigned char bufferData[255U];
m_incomingRFAudio.getData(bufferData, bufferLength); m_incomingRFAudio.getData(bufferData, bufferLength);
@@ -102,9 +100,8 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
#if defined(DUMP_RF_AUDIO) #if defined(DUMP_RF_AUDIO)
if (audiofile != NULL) if (audiofile != NULL)
fwrite(samples, sizeof(float), nSamples, audiofile); ::fwrite(samples, sizeof(float), nSamples, audiofile);
#endif #endif
unsigned short out[170U]; // 85 * 2 unsigned short out[170U]; // 85 * 2
unsigned int nOut = 0U; unsigned int nOut = 0U;
@@ -116,10 +113,11 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
} }
#if defined(DUMP_RF_AUDIO) #if defined(DUMP_RF_AUDIO)
if(audiofile != NULL) if (audiofile != NULL) {
fclose(audiofile); ::fclose(audiofile);
audiofile = NULL;
}
#endif #endif
return m_network->writeData((unsigned char*)out, nOut); return m_network->writeData((unsigned char*)out, nOut);
} }