fix i2saudio when file not found

This commit is contained in:
gemu2015 2020-10-03 18:31:14 +02:00
parent e2983e3f1b
commit 1cb4964a4e
1 changed files with 22 additions and 17 deletions

View File

@ -54,6 +54,8 @@ AudioFileSourceID3 *id3;
AudioGeneratorMP3 *decoder = NULL;
void *mp3ram = NULL;
#define I2SAUDIO_TASK_STACK_SIZE 8192
#ifdef ESP8266
const int preallocateBufferSize = 5*1024;
@ -189,6 +191,7 @@ void sayTime(int hour, int minutes, AudioGeneratorTalkie *talkie) {
} else {
talkie->say(spA_M_, sizeof(spA_M_));
}
out->stop();
delete talkie;
TTGO_PWR_OFF
}
@ -293,7 +296,7 @@ void Webradio(const char *url) {
retryms = millis() + 2000;
}
xTaskCreatePinnedToCore(mp3_task2, "MP3-2", 8192, NULL, 3, &mp3_task_h, 1);
xTaskCreatePinnedToCore(mp3_task2, "MP3-2", I2SAUDIO_TASK_STACK_SIZE, NULL, 3, &mp3_task_h, 1);
}
void mp3_task2(void *arg){
@ -373,6 +376,7 @@ void Play_mp3(const char *path) {
}
file = new AudioFileSourceFS(*fsp,path);
if (file->isOpen()) {
id3 = new AudioFileSourceID3(file);
if (mp3ram) {
@ -383,7 +387,7 @@ void Play_mp3(const char *path) {
mp3->begin(id3, out);
if (I2S_Task) {
xTaskCreatePinnedToCore(mp3_task, "MP3", 8192, NULL, 3, &mp3_task_h, 1);
xTaskCreatePinnedToCore(mp3_task, "MP3", I2SAUDIO_TASK_STACK_SIZE, NULL, 3, &mp3_task_h, 1);
} else {
while (mp3->isRunning()) {
if (!mp3->loop()) {
@ -394,6 +398,7 @@ void Play_mp3(const char *path) {
OsWatchLoop();
}
}
}
#endif // USE_SCRIPT
}