[Android] MediaPlayer: Retain renderer in use

Geoffrey Métais git at videolan.org
Thu Feb 28 11:59:48 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 28 11:40:05 2019 +0100| [117637fb3d1b7b56febe6e2032e08e2e7b312472] | committer: Geoffrey Métais

MediaPlayer: Retain renderer in use

> https://code.videolan.org/videolan/vlc-android/commit/117637fb3d1b7b56febe6e2032e08e2e7b312472
---

 libvlc/src/org/videolan/libvlc/MediaPlayer.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 17176a766..23c5f3dba 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -378,6 +378,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
     public static final int SURFACE_SCALES_COUNT = ScaleType.values().length;
 
     private Media mMedia = null;
+    private RendererItem mRenderer = null;
     private AssetFileDescriptor mAfd = null;
     private boolean mPlaying = false;
     private boolean mPlayRequested = false;
@@ -670,6 +671,9 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
      * @param item {@link RendererItem}. if null VLC play on default output
      */
     public int setRenderer(@Nullable RendererItem item) {
+        if (mRenderer != null) mRenderer.release();
+        if (item != null) item.retain();
+        mRenderer = item;
         return nativeSetRenderer(item);
     }
 
@@ -1340,6 +1344,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
 
         if (mMedia != null)
             mMedia.release();
+        if (mRenderer != null)
+            mRenderer.release();
         mVoutCount = 0;
         nativeRelease();
     }



More information about the Android mailing list