[Android] mediaplayer: hide surfaces callbacks

Thomas Guillem git at videolan.org
Fri Jul 3 14:16:50 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jul  3 14:16:33 2015 +0200| [9e250ec9c0e26e81876f646df2bc1eb7c85bec9b] | committer: Thomas Guillem

mediaplayer: hide surfaces callbacks

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9e250ec9c0e26e81876f646df2bc1eb7c85bec9b
---

 libvlc/src/org/videolan/libvlc/MediaPlayer.java |   41 +++++++++++------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 2c021b6..4ef335c 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -22,10 +22,8 @@
 
 package org.videolan.libvlc;
 
-import java.util.Map;
-
 @SuppressWarnings("unused")
-public class MediaPlayer extends VLCObject<MediaPlayer.Event> implements AWindow.SurfaceCallback {
+public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
 
     public static class Event extends VLCEvent {
         //public static final int MediaChanged        = 0x100;
@@ -263,26 +261,27 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> implements AWindow
         nativeStop();
     }
 
+    private final AWindow.SurfaceCallback mSurfaceCallback = new AWindow.SurfaceCallback() {
+        @Override
+        public synchronized void onSurfacesCreated(AWindow vout) {
+            if (!mPlaying && mPlayRequested)
+                play();
+        }
 
-    @Override
-    public synchronized void onSurfacesCreated(AWindow vout) {
-        if (!mPlaying && mPlayRequested)
-            play();
-    }
-
-    @Override
-    public synchronized void onSurfacesDestroyed(AWindow vout) {
-        if (mVoutCount > 0)
-            setVideoTrack(-1);
-        /* Wait for Vout destruction (mVoutCount = 0) in order to be sure that the surface is not
-         * used after leaving this callback. This shouldn't be needed when using MediaCodec or
-         * AndroidWindow (i.e. after Android 2.3) since the surface is ref-counted */
-        while (mVoutCount > 0) {
-            try {
-                wait();
-            } catch (InterruptedException ignored) {}
+        @Override
+        public synchronized void onSurfacesDestroyed(AWindow vout) {
+            if (mVoutCount > 0)
+                setVideoTrack(-1);
+            /* Wait for Vout destruction (mVoutCount = 0) in order to be sure that the surface is not
+             * used after leaving this callback. This shouldn't be needed when using MediaCodec or
+             * AndroidWindow (i.e. after Android 2.3) since the surface is ref-counted */
+            while (mVoutCount > 0) {
+                try {
+                    wait();
+                } catch (InterruptedException ignored) {}
+            }
         }
-    }
+    };
 
     /**
      * Set if, and how, the video title will be shown when media is played



More information about the Android mailing list