Skip to content

Commit 1927dc5

Browse files
committed
audio_player: minor update
1 parent 44672bb commit 1927dc5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main/src/user/audio_player.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ static void audio_player_task(void *pvParameters)
6262
mad_frame_init(frame);
6363
mad_synth_init(synth);
6464

65-
mad_stream_buffer(stream, (const unsigned char *)mp3_file_ptr[mp3_file_index][0],
66-
mp3_file_ptr[mp3_file_index][1] - mp3_file_ptr[mp3_file_index][0]
65+
mad_stream_buffer(
66+
stream, (const unsigned char *)mp3_file_ptr[mp3_file_index][0],
67+
mp3_file_ptr[mp3_file_index][1] - mp3_file_ptr[mp3_file_index][0]
6768
);
6869

6970
while (1) {
@@ -105,6 +106,9 @@ void audio_player_play_file(uint8_t idx)
105106
ESP_LOGE(TAG, "invalid file index");
106107
return;
107108
}
109+
if (mp3_file_ptr[idx][0] == NULL || mp3_file_ptr[idx][1] == NULL) {
110+
return;
111+
}
108112
mp3_file_index = idx;
109113
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
110114
if (uxBits & AUDIO_PLAYER_RUN_BIT) {

0 commit comments

Comments
 (0)