[Android] Fix leak in audio player

Nicolas Pomepuy git at videolan.org
Thu Sep 7 08:21:02 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jul 25 15:14:23 2023 +0200| [838ee698a747f6b3ecb7396b62e66b1119ec3ae3] | committer: Nicolas Pomepuy

Fix leak in audio player

> https://code.videolan.org/videolan/vlc-android/commit/838ee698a747f6b3ecb7396b62e66b1119ec3ae3
---

 application/tools/src/main/java/org/videolan/tools/Settings.kt       | 4 ++++
 .../vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt        | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 2e2a14ea5d..cb91441392 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -72,6 +72,10 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
         audioControlsChangeListener = listener
     }
 
+    fun removeAudioControlsChangeListener() {
+        audioControlsChangeListener = null
+    }
+
     val showTvUi : Boolean
         get() = !overrideTvUI && device.isTv || tvUI
 }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 9af2659738..81b0eeb2b2 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -263,6 +263,11 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
         setBottomMargin()
     }
 
+    override fun onDestroy() {
+        Settings.removeAudioControlsChangeListener()
+        super.onDestroy()
+    }
+
     fun setBottomMargin() {
         (binding.playPause.layoutParams as? ConstraintLayout.LayoutParams)?.let {
             val audioPlayerContainerActivity = (requireActivity() as AudioPlayerContainerActivity)



More information about the Android mailing list