Skip to content

Commit 76a4d15

Browse files
committed
bt_av: audio_render: check more bits before processing the data
1 parent 088269a commit 76a4d15

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

main/src/user/audio_render.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ void set_dac_sample_rate(int rate)
6060
static void audio_render_task(void *pvParameter)
6161
{
6262
bool start = false;
63-
EventBits_t uxBits = 0;
6463

6564
ESP_LOGI(TAG, "started.");
6665

@@ -121,11 +120,20 @@ static void audio_render_task(void *pvParameter)
121120
continue;
122121
}
123122

123+
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
124+
124125
if ((uxBits & BT_A2DP_IDLE_BIT) || (uxBits & OS_PWR_SLEEP_BIT) || (uxBits & OS_PWR_RESTART_BIT)) {
125126
vRingbufferReturnItem(audio_buff, (void *)data);
126127
continue;
127128
}
128129

130+
#ifdef CONFIG_ENABLE_AUDIO_PROMPT
131+
if (!(uxBits & AUDIO_PLAYER_IDLE_BIT)) {
132+
vRingbufferReturnItem(audio_buff, (void *)data);
133+
continue;
134+
}
135+
#endif
136+
129137
set_dac_sample_rate(a2d_sample_rate);
130138

131139
size_t bytes_written = 0;

main/src/user/bt_av.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ void bt_app_a2d_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
6666

6767
void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
6868
{
69-
#ifdef CONFIG_ENABLE_AUDIO_PROMPT
7069
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
7170

71+
if ((uxBits & BT_A2DP_IDLE_BIT) || (uxBits & OS_PWR_SLEEP_BIT) || (uxBits & OS_PWR_RESTART_BIT)) {
72+
return;
73+
}
74+
75+
#ifdef CONFIG_ENABLE_AUDIO_PROMPT
7276
if (!(uxBits & AUDIO_PLAYER_IDLE_BIT)) {
7377
return;
7478
}

0 commit comments

Comments
 (0)