Skip to content

Commit ce33ebc

Browse files
committed
audio_render: discard a2d audio data while audio player task is running
1 parent cb859bb commit ce33ebc

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

main/src/user/audio_render.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,38 +69,36 @@ static void audio_render_task(void *pvParameter)
6969
uint8_t *data = NULL;
7070
uint32_t size = 0;
7171

72-
data = (uint8_t *)xRingbufferReceiveUpTo(audio_buff, &size, 10 / portTICK_RATE_MS, 512);
72+
data = (uint8_t *)xRingbufferReceiveUpTo(audio_buff, &size, 1 / portTICK_RATE_MS, 512);
7373

7474
if (data == NULL || size == 0) {
7575
continue;
7676
}
7777

78+
#if defined(CONFIG_ENABLE_AUDIO_PROMPT) || !defined(CONFIG_AUDIO_INPUT_NONE) || defined(CONFIG_ENABLE_VFX)
79+
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
80+
#endif
81+
7882
#ifdef CONFIG_ENABLE_AUDIO_PROMPT
79-
xEventGroupWaitBits(
80-
user_event_group,
81-
AUDIO_PLAYER_IDLE_BIT,
82-
pdFALSE,
83-
pdFALSE,
84-
portMAX_DELAY
85-
);
83+
if (!(uxBits & AUDIO_PLAYER_IDLE_BIT)) {
84+
goto return_item;
85+
}
8686
#endif
8787

8888
set_dac_sample_rate(a2d_sample_rate);
8989

9090
size_t bytes_written = 0;
9191
i2s_write(CONFIG_AUDIO_OUTPUT_I2S_NUM, data, size, &bytes_written, portMAX_DELAY);
9292

93-
#if !defined(CONFIG_AUDIO_INPUT_NONE) || defined(CONFIG_ENABLE_VFX)
94-
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
95-
#endif
96-
9793
#ifndef CONFIG_AUDIO_INPUT_NONE
94+
uxBits = xEventGroupGetBits(user_event_group);
9895
if (uxBits & AUDIO_INPUT_RUN_BIT) {
9996
goto return_item;
10097
}
10198
#endif
10299

103100
#ifdef CONFIG_ENABLE_VFX
101+
uxBits = xEventGroupGetBits(user_event_group);
104102
if (!(uxBits & VFX_FFT_NULL_BIT)) {
105103
goto return_item;
106104
}

0 commit comments

Comments
 (0)