Fix failure to read ambe files

master
Geoffrey Merck 4 years ago
parent d15525df2c
commit 0180dcd2e0

@ -355,15 +355,15 @@ bool CAudioUnit::readAMBE(const std::string& dir, const std::string& name)
unsigned char buffer[VOICE_FRAME_LENGTH_BYTES]; unsigned char buffer[VOICE_FRAME_LENGTH_BYTES];
size_t n = fread(buffer, 4, 1, file); size_t n = fread(buffer, sizeof(unsigned char), 4, file);
if (n != 4) { if (n != 4) {
CLog::logInfo("Unable to read the header from %s\n", fileName.c_str()); CLog::logError("Unable to read the header from %s\n", fileName.c_str());
fclose(file); fclose(file);
return false; return false;
} }
if (memcmp(buffer, "AMBE", 4)) { if (memcmp(buffer, "AMBE", 4)) {
CLog::logInfo("Invalid header from %s\n", fileName.c_str()); CLog::logError("Invalid header from %s\n", fileName.c_str());
fclose(file); fclose(file);
return false; return false;
} }
@ -380,9 +380,9 @@ bool CAudioUnit::readAMBE(const std::string& dir, const std::string& name)
for (unsigned int i = 0U; i < SILENCE_LENGTH; i++, p += VOICE_FRAME_LENGTH_BYTES) for (unsigned int i = 0U; i < SILENCE_LENGTH; i++, p += VOICE_FRAME_LENGTH_BYTES)
memcpy(p, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES); memcpy(p, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);
n = fread(p, length, 1, file); n = fread(p, 1, length, file);
if (n != length) { if (n != length) {
CLog::logInfo("Unable to read the AMBE data from %s\n", fileName.c_str()); CLog::logError("Unable to read the AMBE data from %s\n", fileName.c_str());
fclose(file); fclose(file);
delete[] m_ambe; delete[] m_ambe;
m_ambe = NULL; m_ambe = NULL;

Loading…
Cancel
Save

Powered by TurnKey Linux.