|
|
@ -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) { |
|
|
|
AudioGenerator *decoder = nullptr; |
|
|
|
AudioFileSourceICYStream *file = nullptr; |
|
|
@ -90,9 +95,10 @@ void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
|
file = new AudioFileSourceICYStream(URL); |
|
|
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); |
|
|
|
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); |
|
|
|
audiobuffer = buff; |
|
|
|
buff->RegisterStatusCB(StatusCallback, (void*)"buffer"); |
|
|
|
if (out == NULL) { |
|
|
|
out = new AudioOutputI2S(I2S_NUM_0, false, 0); |
|
|
|
out = new AudioOutputI2S(I2S_NUM_0, false); |
|
|
|
out->SetPinout(12, 13, 25); |
|
|
|
} |
|
|
|
decoder = new AudioGeneratorMP3(preallocateCodec, preallocateCodecSize); |
|
|
@ -130,6 +136,7 @@ void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
|
buff->close(); |
|
|
|
delete buff; |
|
|
|
buff = nullptr; |
|
|
|
audiobuffer = nullptr; |
|
|
|
} |
|
|
|
if (file) { |
|
|
|
file->close(); |
|
|
|