Added a 50ms startup delay to voiceprompts. This provides a workaround to fix cracking sounds when changing rtx parameters on MD-UV3x0.

This commit is contained in:
Silvano Seva 2022-10-19 11:53:58 +02:00
parent f24699f14e
commit dd30c899df
1 changed files with 21 additions and 4 deletions

View File

@ -19,6 +19,7 @@
***************************************************************************/ ***************************************************************************/
#include <interfaces/platform.h> #include <interfaces/platform.h>
#include <interfaces/keyboard.h> #include <interfaces/keyboard.h>
#include <interfaces/delays.h>
#include <voicePromptUtils.h> #include <voicePromptUtils.h>
#include <ui/ui_strings.h> #include <ui/ui_strings.h>
#include <voicePrompts.h> #include <voicePrompts.h>
@ -107,6 +108,7 @@ static uint8_t beepSeriesIndex = 0;
static bool delayBeepUntilTick = false; static bool delayBeepUntilTick = false;
static pathId vpAudioPath; static pathId vpAudioPath;
static long long vpStartTime;
#ifdef VP_USE_FILESYSTEM #ifdef VP_USE_FILESYSTEM
static FILE *vpFile = NULL; static FILE *vpFile = NULL;
@ -562,10 +564,9 @@ void vp_play()
if (vpCurrentSequence.length <= 0) if (vpCurrentSequence.length <= 0)
return; return;
voicePromptActive = true; // TODO: remove this once switching to hardware-based I2C driver for AT1846S
// management.
codec_startDecode(SINK_SPK); vpStartTime = getTick();
enableSpkOutput();
} }
void vp_tick() void vp_tick()
@ -575,9 +576,25 @@ void vp_tick()
vp_stop(); vp_stop();
return; return;
} }
if (beep_tick()) if (beep_tick())
return; return;
// Temporary fix for the following bug: on MD-UV3x0 the configuration of
// the AT1846S chip may take more than 20ms, making the codec2 thread miss
// the syncronization point with the output stream. By delaying the start
// of the voice prompt by 50ms, a time span almost not noticeable, we avoid
// to incur in such a problem.
// TODO: remove this once switched to hardware-based I2C driver for AT1846S
// management.
if((vpStartTime > 0) && ((getTick() - vpStartTime) > 50))
{
vpStartTime = 0;
voicePromptActive = true;
codec_startDecode(SINK_SPK);
enableSpkOutput();
}
if (voicePromptActive == false) if (voicePromptActive == false)
return; return;