From c6a40a96251c75e7ad32c2abd640610ab4f8e9cf Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Sun, 16 Oct 2022 09:52:25 +0200 Subject: [PATCH] Ensure proper syncronization between codec2 decode thread and output stream when the former is started --- openrtx/src/core/audio_codec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openrtx/src/core/audio_codec.c b/openrtx/src/core/audio_codec.c index 17bfbfaf..a198b371 100644 --- a/openrtx/src/core/audio_codec.c +++ b/openrtx/src/core/audio_codec.c @@ -295,6 +295,12 @@ static void *decodeFunc(void *arg) codec2 = codec2_create(CODEC2_MODE_3200); + // Ensure that thread start is correctly synchronized with the output + // stream to avoid having the decode function writing in a memory area + // being read at the same time by the output stream system causing cracking + // noises at speaker output. Behaviour observed on both Module17 and MD-UV380 + outputStream_sync(audioStream, false); + while(stopThread == false) { // Try popping data from the queue