[Android] Release media after use

Robert Stone git at videolan.org
Fri Aug 13 05:37:57 UTC 2021


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Thu Aug 12 22:02:07 2021 -0700| [598f2ed2e83d6ab578d6cc051d9c1a901ffb5c8d] | committer: Robert Stone

Release media after use

> https://code.videolan.org/videolan/vlc-android/commit/598f2ed2e83d6ab578d6cc051d9c1a901ffb5c8d
---

 application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 8e2472905..d4707e45f 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -343,6 +343,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
             mediaFactory.getFromUri(libVlc, mediaWrapper.uri).apply { parse() }
         }
         val tracks = media.getAudioTracks()
+        media.release()
         return if (tracks.size == 1) tracks.first().formatTrackInfoString(this) else null
     }
 
@@ -353,6 +354,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
             mediaFactory.getFromUri(libVlc, mediaWrapper.uri).apply { parse() }
         }
         val tracks = media.getAudioTracks()
+        media.release()
         return if (tracks.size == 1) tracks.first().formatTrackInfoString(this) else null
     }
 
@@ -363,10 +365,10 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
             mediaFactory.getFromUri(libVlc, mediaWrapper.uri).apply { parse() }
         }
         val tracks = media.getAudioTracks()
+        media.release()
         return if (tracks.size == 1) tracks.first().formatTrackInfoString(this) else null
     }
 
-
     fun IMedia.AudioTrack.formatTrackInfoString(context: Context) = (context.getString(R.string.track_bitrate_info, bitrate.toLong().readableSize()) +
             " ยท " +
             context.getString(R.string.track_codec_info, codec) +



More information about the Android mailing list