Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish bufferred samples #520

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

RomanLut
Copy link

@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
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.

None yet

1 participant