Commit 33d8feb9 authored by Martin Finkel's avatar Martin Finkel Committed by Geoffrey Métais

Revert 4853aaaa: MediaPlayer: move SurfaceListener from AWindow

The SurfaceListener interface should be uncoupled from the mediaplayer.
parent c64c8fb0
......@@ -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);
}
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment