Skip to content

Conversation

@RomanLut
Copy link
Contributor

@RomanLut RomanLut commented May 7, 2022

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 RomanLut mentioned this pull request May 8, 2022
@earlephilhower
Copy link
Owner

Thanks for the contribution, but the code has diverged quite a bit and we have many merge conflicts now. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants