Skip to content

Commit b6cee62

Browse files
committed
bt_av: clear vfx fft buffer when audio is suspended or stopped
1 parent 111f7ea commit b6cee62

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

main/src/user/bt_av.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,15 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
198198
#ifdef CONFIG_ENABLE_AUDIO_PROMPT
199199
audio_player_play_file(1);
200200
#endif
201-
202-
if (!(uxBits & OS_PWR_SLEEP_BIT)) {
203-
if (!(uxBits & BT_A2DP_IDLE_BIT)) {
204201
#ifdef CONFIG_ENABLE_VFX
205-
if (!(uxBits & AUDIO_INPUT_RUN_BIT) && (uxBits & AUDIO_INPUT_FFT_BIT)) {
206-
memset(vfx_fft_input, 0x00, sizeof(vfx_fft_input));
207-
xEventGroupClearBits(user_event_group, VFX_FFT_NULL_BIT);
208-
}
202+
if (!(uxBits & AUDIO_INPUT_RUN_BIT) && (uxBits & AUDIO_INPUT_FFT_BIT)) {
203+
memset(vfx_fft_input, 0x00, sizeof(vfx_fft_input));
204+
xEventGroupClearBits(user_event_group, VFX_FFT_NULL_BIT);
205+
}
209206
#endif
210-
}
211-
if (!(uxBits & OS_PWR_RESTART_BIT)) {
212207
#ifdef CONFIG_ENABLE_LED
213-
led_set_mode(3);
208+
led_set_mode(3);
214209
#endif
215-
}
216-
}
217210

218211
xEventGroupSetBits(user_event_group, BT_A2DP_IDLE_BIT);
219212
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_CONNECTED) {
@@ -238,13 +231,23 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
238231
}
239232
case ESP_A2D_AUDIO_STATE_EVT: {
240233
ESP_LOGI(BT_A2D_TAG, "A2DP audio state: %s", s_a2d_audio_state_str[a2d->audio_stat.state]);
241-
#ifdef CONFIG_ENABLE_LED
234+
242235
if (a2d->audio_stat.state == ESP_A2D_AUDIO_STATE_STARTED) {
236+
#ifdef CONFIG_ENABLE_LED
243237
led_set_mode(1);
238+
#endif
244239
} else {
240+
#ifdef CONFIG_ENABLE_VFX
241+
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
242+
if (!(uxBits & AUDIO_INPUT_RUN_BIT) && (uxBits & AUDIO_INPUT_FFT_BIT)) {
243+
memset(vfx_fft_input, 0x00, sizeof(vfx_fft_input));
244+
xEventGroupClearBits(user_event_group, VFX_FFT_NULL_BIT);
245+
}
246+
#endif
247+
#ifdef CONFIG_ENABLE_LED
245248
led_set_mode(2);
246-
}
247249
#endif
250+
}
248251
break;
249252
}
250253
case ESP_A2D_AUDIO_CFG_EVT: {

0 commit comments

Comments
 (0)