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>
#if defined(DUMP_RF_AUDIO)
#include <stdio.h>
#include <cstdio>
#endif
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)
return false;
m_incomingRFAudio.addData(data + 1U, length - 1U);
unsigned int bufferLength = m_incomingRFAudio.dataSize();
if (bufferLength > 255U)
@@ -65,9 +64,8 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
if (bufferLength >= 3U) {
#if defined(DUMP_RF_AUDIO)
FILE * audiofile = fopen("./audiodump.bin", "ab");
FILE* audiofile = ::fopen("./audiodump.bin", "ab");
#endif
bufferLength = bufferLength - bufferLength % 3U; //round down to nearest multiple of 3
unsigned char bufferData[255U];
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 (audiofile != NULL)
fwrite(samples, sizeof(float), nSamples, audiofile);
::fwrite(samples, sizeof(float), nSamples, audiofile);
#endif
unsigned short out[170U]; // 85 * 2
unsigned int nOut = 0U;
@@ -116,10 +113,11 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
}
#if defined(DUMP_RF_AUDIO)
if(audiofile != NULL)
fclose(audiofile);
if (audiofile != NULL) {
::fclose(audiofile);
audiofile = NULL;
}
#endif
return m_network->writeData((unsigned char*)out, nOut);
}