|
@ -79,6 +79,11 @@ void MP3::setVolume(int volume) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint32_t MP3::getBuffFill() { |
|
|
|
|
|
if (audiobuffer) return ((100U*audiobuffer->getFillLevel())/(8*1024)); |
|
|
|
|
|
else return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
AudioGenerator *decoder = nullptr; |
|
|
AudioGenerator *decoder = nullptr; |
|
|
AudioFileSourceICYStream *file = nullptr; |
|
|
AudioFileSourceICYStream *file = nullptr; |
|
@ -90,9 +95,10 @@ void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
file = new AudioFileSourceICYStream(URL); |
|
|
file = new AudioFileSourceICYStream(URL); |
|
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); |
|
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); |
|
|
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); |
|
|
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); |
|
|
|
|
|
audiobuffer = buff; |
|
|
buff->RegisterStatusCB(StatusCallback, (void*)"buffer"); |
|
|
buff->RegisterStatusCB(StatusCallback, (void*)"buffer"); |
|
|
if (out == NULL) { |
|
|
if (out == NULL) { |
|
|
out = new AudioOutputI2S(I2S_NUM_0, false, 0); |
|
|
out = new AudioOutputI2S(I2S_NUM_0, false); |
|
|
out->SetPinout(12, 13, 25); |
|
|
out->SetPinout(12, 13, 25); |
|
|
} |
|
|
} |
|
|
decoder = new AudioGeneratorMP3(preallocateCodec, preallocateCodecSize); |
|
|
decoder = new AudioGeneratorMP3(preallocateCodec, preallocateCodecSize); |
|
@ -130,6 +136,7 @@ void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
buff->close(); |
|
|
buff->close(); |
|
|
delete buff; |
|
|
delete buff; |
|
|
buff = nullptr; |
|
|
buff = nullptr; |
|
|
|
|
|
audiobuffer = nullptr; |
|
|
} |
|
|
} |
|
|
if (file) { |
|
|
if (file) { |
|
|
file->close(); |
|
|
file->close(); |
|
|