From befc89206827e663d7014630316fe7202bdaa2d4 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Tue, 5 Jul 2022 10:16:36 +1000 Subject: [PATCH] When reading codec2 data, pad out to a multiple of 8 bytes with 0s so that when frames are pushed from the buffer, we don't get garbage at the ends of prompts which are not an exact multiple of 8 bytes. --- openrtx/src/core/voicePrompts.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index 4826b169..133f5ecc 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -154,6 +154,13 @@ static void GetCodec2Data(int offset, int length) fseek(voice_prompt_file, vpDataOffset+offset, SEEK_SET); fread((void*)&Codec2Data, length, 1, voice_prompt_file); + // zero buffer from length to the next multiple of 8 to avoid garbage + // being played back, since codec2 frames are pushed in lots of 8 bytes. + if ((length % 8) != 0) + { + int bytesToZero = length % 8; + memset(Codec2Data+length, 0, bytesToZero); + } } void vpTerminate(void)