[Android] Revert 4853aaaa: MediaPlayer: move SurfaceListener from AWindow
Martin Finkel
git at videolan.org
Thu Mar 28 14:29:01 CET 2019
vlc-android | branch: 3.1.x | Martin Finkel <martin at videolabs.io> | Thu Mar 21 16:45:58 2019 +0100| [dd483d5f47a54adf91b8926a558ae76575e8ab8f] | 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/dd483d5f47a54adf91b8926a558ae76575e8ab8f
---
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