ESP8266Audio icon indicating copy to clipboard operation
ESP8266Audio copied to clipboard

Finish bufferred samples

Open RomanLut opened this issue 3 years ago • 0 comments

AudioGenerator should let AudioOutput finish playing buffered samples.

Reproduction:

  • ESP32, Create AudioOutputI2S with large number of buffers: AudioOutputI2S(port, 1, 80)
  • play mp3 or WAV file => large part of sound file is not played

The common loop:

if (mp3->isRunning()) { if (!mp3->loop()) mp3->stop(); } else { Serial.printf("MP3 done\n"); delay(1000); }

stops AudioOutput as soon as last sample is pushed to output. All buferred samples are discarded.

Solution: After pushing last sample, AudioGenerator should call AudioOutput->finish() as long as it returns false. While finishing, AudioGenerator should return true from AudioGenerator->IsRunning() and AudioGenerator->loop().

Implemented for AudioOutputI2S ( and AudioOutputNoDAC effectivelly ) , and AudioGeneratorMP3 and AudioGeneratorWAV. Other classes work as before ( not affected ).

RomanLut avatar May 07 '22 14:05 RomanLut