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

Commit fdc44dc7 authored by Erik Wolsheimer's avatar Erik Wolsheimer Committed by android-build-merger
Browse files

Fix memory leak in Ringtone am: 76ed4ddc

am: 8d135d53

Change-Id: Ieed5a2e27ba53142ceb02a4e6812509beaabb414
parents 9011f8f9 8d135d53
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -371,6 +371,7 @@ public class Ringtone {

    private void destroyLocalPlayer() {
        if (mLocalPlayer != null) {
            mLocalPlayer.setOnCompletionListener(null);
            mLocalPlayer.reset();
            mLocalPlayer.release();
            mLocalPlayer = null;
@@ -467,11 +468,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);
            }
        }
    }
}