Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76ed4ddc authored by Erik Wolsheimer's avatar Erik Wolsheimer
Browse files

Fix memory leak in Ringtone

BUG: 31938615
Change-Id: Ic736f3494b4da95460bdc0cb7857cc9fcc746ab9
parent 15ece478
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -368,6 +368,7 @@ public class Ringtone {

    private void destroyLocalPlayer() {
        if (mLocalPlayer != null) {
            mLocalPlayer.setOnCompletionListener(null);
            mLocalPlayer.reset();
            mLocalPlayer.release();
            mLocalPlayer = null;
@@ -464,11 +465,14 @@ public class Ringtone {
    }

    class MyOnCompletionListener implements MediaPlayer.OnCompletionListener {
        public void onCompletion(MediaPlayer mp)
        {
        @Override
        public void onCompletion(MediaPlayer mp) {
            synchronized (sActiveRingtones) {
                sActiveRingtones.remove(Ringtone.this);
            }
            if (mLocalPlayer != null) {
                mLocalPlayer.setOnCompletionListener(null);
            }
        }
    }
}