From 0692bea2692fe02fa7ec130891be685cfa64ae50 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Thu, 6 Oct 2022 07:48:26 +0200 Subject: [PATCH] Partial fix for speaker pop when a voiceprompt begins --- openrtx/src/core/voicePrompts.c | 14 ++++++++------ platform/drivers/audio/audio_MDx.c | 2 ++ platform/drivers/audio/outputStream_MDx.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index 9c1ee8b5..4d787f82 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -411,15 +411,17 @@ void vp_terminate() void vp_stop() { - voicePromptActive = false; + voicePromptActive = false; + disableSpkOutput(); + codec_stop(); + + // Clear voice prompt sequence data vpCurrentSequence.pos = 0; vpCurrentSequence.c2DataIndex = 0; vpCurrentSequence.c2DataLength = 0; - codec_stop(); // If any beep is playing, immediately stop it. beep_flush(); - disableSpkOutput(); } void vp_flush() @@ -562,8 +564,8 @@ void vp_play() voicePromptActive = true; - enableSpkOutput(); codec_startDecode(SINK_SPK); + enableSpkOutput(); } void vp_tick() @@ -619,11 +621,11 @@ void vp_tick() // see if we've finished. if(vpCurrentSequence.pos == vpCurrentSequence.length) { + disableSpkOutput(); voicePromptActive = false; vpCurrentSequence.pos = 0; vpCurrentSequence.c2DataIndex = 0; vpCurrentSequence.c2DataLength = 0; - disableSpkOutput(); codec_stop(); } } @@ -657,8 +659,8 @@ void vp_beep(uint16_t freq, uint16_t duration) beepSeriesBuffer[1].duration = 0; currentBeepDuration = duration; beepSeriesIndex = 0; - enableSpkOutput(); platform_beepStart(freq); + enableSpkOutput(); } void vp_beepSeries(const uint16_t* beepSeries) diff --git a/platform/drivers/audio/audio_MDx.c b/platform/drivers/audio/audio_MDx.c index 32780490..862577d6 100644 --- a/platform/drivers/audio/audio_MDx.c +++ b/platform/drivers/audio/audio_MDx.c @@ -51,6 +51,8 @@ void audio_init() #endif #endif + gpio_setMode(BEEP_OUT, INPUT); + gpio_setPin(SPK_MUTE); // Speaker muted #ifndef PLATFORM_MD9600 gpio_clearPin(AUDIO_AMP_EN); // Audio PA off diff --git a/platform/drivers/audio/outputStream_MDx.cpp b/platform/drivers/audio/outputStream_MDx.cpp index a248218c..ffd5e4d7 100644 --- a/platform/drivers/audio/outputStream_MDx.cpp +++ b/platform/drivers/audio/outputStream_MDx.cpp @@ -178,7 +178,7 @@ streamId outputStream_start(const enum AudioSink destination, NVIC_EnableIRQ(DMA1_Stream2_IRQn); // Enable compare channel - TIM3->CCR3 = 0; + TIM3->CCR3 = buf[0]; TIM3->CCER |= TIM_CCER_CC3E; TIM3->CR1 |= TIM_CR1_CEN;