Skip to content

Commit 088269a

Browse files
committed
audio_render: more optimization
1 parent 255f213 commit 088269a

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

main/src/user/audio_render.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,34 @@ static void audio_render_task(void *pvParameter)
9090

9191
data = (uint8_t *)xRingbufferReceiveUpTo(audio_buff, &size, 16 / portTICK_RATE_MS, remain);
9292
} else {
93+
vTaskDelay(1 / portTICK_RATE_MS);
94+
95+
remain = sizeof(buff_data) - xRingbufferGetCurFreeSize(audio_buff);
96+
if (remain == 0) {
9397
#ifdef CONFIG_ENABLE_VFX
94-
uxBits = xEventGroupGetBits(user_event_group);
95-
if (!(uxBits & AUDIO_INPUT_RUN_BIT) && (uxBits & AUDIO_INPUT_FFT_BIT)) {
96-
memset(vfx_fft_input, 0x00, sizeof(vfx_fft_input));
97-
xEventGroupClearBits(user_event_group, VFX_FFT_NULL_BIT);
98-
}
98+
uxBits = xEventGroupGetBits(user_event_group);
99+
if (!(uxBits & AUDIO_INPUT_RUN_BIT) && (uxBits & AUDIO_INPUT_FFT_BIT)) {
100+
memset(vfx_fft_input, 0x00, sizeof(vfx_fft_input));
101+
xEventGroupClearBits(user_event_group, VFX_FFT_NULL_BIT);
102+
}
99103
#endif
100-
start = false;
104+
start = false;
105+
}
101106

102-
taskYIELD();
103107
continue;
104108
}
105109

106110
if (data == NULL) {
107-
ESP_LOGE(TAG, "receive timeout.");
108-
109111
taskYIELD();
110112
continue;
111113
}
112114
} else {
115+
vTaskDelay(1 / portTICK_RATE_MS);
116+
113117
if (xRingbufferGetCurFreeSize(audio_buff) == 0) {
114118
start = true;
115-
} else {
116-
vTaskDelay(1 / portTICK_RATE_MS);
117119
}
120+
118121
continue;
119122
}
120123

0 commit comments

Comments
 (0)