Skip to content

Instantly share code, notes, and snippets.

@jumblies
Created September 1, 2019 21:16
Show Gist options
  • Save jumblies/ed1c370c9587c40157dbe434970368fa to your computer and use it in GitHub Desktop.
Save jumblies/ed1c370c9587c40157dbe434970368fa to your computer and use it in GitHub Desktop.
Possible memory leak fix
bool stopPlaying() {
bool stopped = false;
if (rtttl) {
rtttl->stop();
delete rtttl;
rtttl = nullptr;
stopped = true;
}
if (mp3) {
mp3->stop();
delete mp3;
mp3 = nullptr;
stopped = true;
}
if (buff) {
buff->close();
delete buff;
buff = nullptr;
}
if (file) {
file->close();
delete file;
file = nullptr;
}
if (stream) {
stream->close();
delete stream;
stream = nullptr;
}
return stopped;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment