Skip to content

Commit d2b3c85

Browse files
committed
bt_app_av: optimize audio quality
1 parent 1eb5123 commit d2b3c85

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

main/inc/core/os.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ typedef enum user_event_group_bits {
1616
VFX_FFT_EXEC_BIT = BIT1,
1717
VFX_FFT_FULL_BIT = BIT2,
1818
KEY_SCAN_RUN_BIT = BIT3,
19-
BT_OTA_LOCKED_BIT = BIT4,
20-
AUDIO_MP3_RUN_BIT = BIT5,
21-
AUDIO_MP3_IDLE_BIT = BIT6,
22-
AUDIO_INPUT_RUN_BIT = BIT7,
23-
AUDIO_INPUT_LOOP_BIT = BIT8,
19+
BT_A2DP_IDLE_BIT = BIT4,
20+
BT_OTA_LOCKED_BIT = BIT5,
21+
AUDIO_MP3_RUN_BIT = BIT6,
22+
AUDIO_MP3_IDLE_BIT = BIT7,
23+
AUDIO_INPUT_RUN_BIT = BIT8,
24+
AUDIO_INPUT_LOOP_BIT = BIT9,
2425
} user_event_group_bits_t;
2526

2627
extern EventGroupHandle_t user_event_group;

main/src/user/audio_mp3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,5 @@ void audio_mp3_play(uint8_t filename_index)
115115

116116
void audio_mp3_init(void)
117117
{
118-
xTaskCreatePinnedToCore(audio_mp3_task_handle, "AudioMp3T", 8448, NULL, 8, NULL, 0);
118+
xTaskCreatePinnedToCore(audio_mp3_task_handle, "AudioMp3T", 8448, NULL, 8, NULL, 1);
119119
}

main/src/user/bt_app_av.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
8383
#endif
8484

8585
#ifdef CONFIG_ENABLE_AUDIO_PROMPT
86-
if (uxBits & AUDIO_MP3_RUN_BIT) {
86+
if (uxBits & BT_A2DP_IDLE_BIT || uxBits & AUDIO_MP3_RUN_BIT) {
8787
return;
8888
}
8989
#endif
@@ -179,8 +179,9 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
179179
audio_mp3_play(1);
180180
led_set_mode(3);
181181

182-
xEventGroupSetBits(user_event_group, VFX_FFT_FULL_BIT);
183182
xEventGroupSetBits(user_event_group, VFX_RELOAD_BIT);
183+
xEventGroupSetBits(user_event_group, VFX_FFT_FULL_BIT);
184+
xEventGroupSetBits(user_event_group, BT_A2DP_IDLE_BIT);
184185
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_CONNECTED) {
185186
xEventGroupSetBits(user_event_group, BT_OTA_LOCKED_BIT);
186187

@@ -208,13 +209,15 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
208209
if (a2d->audio_cfg.mcc.type == ESP_A2D_MCT_SBC) {
209210
int sample_rate = 16000;
210211
char oct0 = a2d->audio_cfg.mcc.cie.sbc[0];
212+
211213
if (oct0 & (0x01 << 6)) {
212214
sample_rate = 32000;
213215
} else if (oct0 & (0x01 << 5)) {
214216
sample_rate = 44100;
215217
} else if (oct0 & (0x01 << 4)) {
216218
sample_rate = 48000;
217219
}
220+
218221
i2s_set_output_sample_rate(sample_rate);
219222

220223
ESP_LOGI(BT_A2D_TAG, "configure audio player %x-%x-%x-%x",
@@ -224,6 +227,9 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
224227
a2d->audio_cfg.mcc.cie.sbc[3]);
225228
ESP_LOGI(BT_A2D_TAG, "audio player configured, sample rate=%d", sample_rate);
226229
}
230+
231+
xEventGroupClearBits(user_event_group, BT_A2DP_IDLE_BIT);
232+
227233
break;
228234
}
229235
default:

0 commit comments

Comments
 (0)