[Android] Revert 4853aaaa: MediaPlayer: move SurfaceListener from AWindow

Martin Finkel git at videolan.org
Tue Mar 26 16:25:40 CET 2019


vlc-android | branch: master | Martin Finkel <martin at videolabs.io> | Thu Mar 21 16:45:58 2019 +0100| [33d8feb93b21d5f8416a267cd9be7bca8bd7422d] | committer: Geoffrey Métais

Revert 4853aaaa: MediaPlayer: move SurfaceListener from AWindow

The SurfaceListener interface should be uncoupled from the mediaplayer.

> https://code.videolan.org/videolan/vlc-android/commit/33d8feb93b21d5f8416a267cd9be7bca8bd7422d
---

 libvlc/src/org/videolan/libvlc/AWindow.java     | 15 +++++++++++----
 libvlc/src/org/videolan/libvlc/MediaPlayer.java | 16 ++++------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index 45b40e521..1f08fc4f8 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -42,6 +42,13 @@ public class AWindow implements IVLCVout {
     private static final int ID_SUBTITLES = 1;
     private static final int ID_MAX = 2;
 
+    public interface SurfaceCallback {
+        @MainThread
+        void onSurfacesCreated(AWindow vout);
+        @MainThread
+        void onSurfacesDestroyed(AWindow vout);
+    }
+
     private class SurfaceHelper {
         private final int mId;
         private final SurfaceView mSurfaceView;
@@ -184,7 +191,7 @@ public class AWindow implements IVLCVout {
     private final static int SURFACE_STATE_READY = 2;
 
     private final SurfaceHelper[] mSurfaceHelpers;
-    private final MediaPlayer.SurfaceListener mSurfaceCallback;
+    private final SurfaceCallback mSurfaceCallback;
     private final AtomicInteger mSurfacesState = new AtomicInteger(SURFACE_STATE_INIT);
     private OnNewVideoLayoutListener mOnNewVideoLayoutListener = null;
     private ArrayList<IVLCVout.Callback> mIVLCVoutCallbacks = new ArrayList<IVLCVout.Callback>();
@@ -204,7 +211,7 @@ public class AWindow implements IVLCVout {
      * MediaPlayer class).
      * @param surfaceCallback
      */
-    public AWindow(MediaPlayer.SurfaceListener surfaceCallback) {
+    public AWindow(SurfaceCallback surfaceCallback) {
         mSurfaceCallback = surfaceCallback;
         mSurfaceHelpers = new SurfaceHelper[ID_MAX];
         mSurfaceHelpers[ID_VIDEO] = null;
@@ -347,7 +354,7 @@ public class AWindow implements IVLCVout {
         for (IVLCVout.Callback cb : mIVLCVoutCallbacks)
             cb.onSurfacesDestroyed(this);
         if (mSurfaceCallback != null)
-            mSurfaceCallback.onSurfaceDestroyed();
+            mSurfaceCallback.onSurfacesDestroyed(this);
         mSurfaceTextureThread.release();
     }
 
@@ -372,7 +379,7 @@ public class AWindow implements IVLCVout {
             for (IVLCVout.Callback cb : mIVLCVoutCallbacks)
                 cb.onSurfacesCreated(this);
             if (mSurfaceCallback != null)
-                mSurfaceCallback.onSurfaceCreated();
+                mSurfaceCallback.onSurfacesCreated(this);
         }
     }
 
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 23c5f3dba..8827a8f11 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -397,18 +397,12 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
     // Video tools
     private VideoHelper mVideoHelper = null;
 
-    interface SurfaceListener {
-        void onSurfaceCreated();
-        void onSurfaceDestroyed();
-    }
-
-    private final SurfaceListener mSurfaceListener = new SurfaceListener() {
+    private final AWindow mWindow = new AWindow(new AWindow.SurfaceCallback() {
         @Override
-        public void onSurfaceCreated() {
+        public void onSurfacesCreated(AWindow vout) {
             boolean play = false;
             boolean enableVideo = false;
             synchronized (MediaPlayer.this) {
-
                 if (!mPlaying && mPlayRequested)
                     play = true;
                 else if (mVoutCount == 0)
@@ -421,7 +415,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
         }
 
         @Override
-        public void onSurfaceDestroyed() {
+        public void onSurfacesDestroyed(AWindow vout) {
             boolean disableVideo = false;
             synchronized (MediaPlayer.this) {
                 if (mVoutCount > 0)
@@ -430,9 +424,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
             if (disableVideo)
                 setVideoTrackEnabled(false);
         }
-    };
-
-    private final AWindow mWindow = new AWindow(mSurfaceListener);
+    });
 
     private synchronized void updateAudioOutputDevice(long encodingFlags, String defaultDevice) {
         mCanDoPassthrough = encodingFlags != 0;



More information about the Android mailing list