Commit 4853aaaa authored by Thomas Guillem's avatar Thomas Guillem

MediaPlayer: move SurfaceListener from AWindow

To allow other rendering class to use it, like the future GLRenderer.
parent 2280b0b0
......@@ -42,13 +42,6 @@ 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;
......@@ -191,7 +184,7 @@ public class AWindow implements IVLCVout {
private final static int SURFACE_STATE_READY = 2;
private final SurfaceHelper[] mSurfaceHelpers;
private final SurfaceCallback mSurfaceCallback;
private final MediaPlayer.SurfaceListener mSurfaceCallback;
private final AtomicInteger mSurfacesState = new AtomicInteger(SURFACE_STATE_INIT);
private OnNewVideoLayoutListener mOnNewVideoLayoutListener = null;
private ArrayList<IVLCVout.Callback> mIVLCVoutCallbacks = new ArrayList<IVLCVout.Callback>();
......@@ -211,7 +204,7 @@ public class AWindow implements IVLCVout {
* MediaPlayer class).
* @param surfaceCallback
*/
public AWindow(SurfaceCallback surfaceCallback) {
public AWindow(MediaPlayer.SurfaceListener surfaceCallback) {
mSurfaceCallback = surfaceCallback;
mSurfaceHelpers = new SurfaceHelper[ID_MAX];
mSurfaceHelpers[ID_VIDEO] = null;
......@@ -354,7 +347,7 @@ public class AWindow implements IVLCVout {
for (IVLCVout.Callback cb : mIVLCVoutCallbacks)
cb.onSurfacesDestroyed(this);
if (mSurfaceCallback != null)
mSurfaceCallback.onSurfacesDestroyed(this);
mSurfaceCallback.onSurfaceDestroyed();
mSurfaceTextureThread.release();
}
......@@ -379,7 +372,7 @@ public class AWindow implements IVLCVout {
for (IVLCVout.Callback cb : mIVLCVoutCallbacks)
cb.onSurfacesCreated(this);
if (mSurfaceCallback != null)
mSurfaceCallback.onSurfacesCreated(this);
mSurfaceCallback.onSurfaceCreated();
}
}
......
......@@ -374,12 +374,18 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
private boolean mCanDoPassthrough;
private final AWindow mWindow = new AWindow(new AWindow.SurfaceCallback() {
interface SurfaceListener {
void onSurfaceCreated();
void onSurfaceDestroyed();
}
private final SurfaceListener mSurfaceListener = new SurfaceListener() {
@Override
public void onSurfacesCreated(AWindow vout) {
public void onSurfaceCreated() {
boolean play = false;
boolean enableVideo = false;
synchronized (MediaPlayer.this) {
if (!mPlaying && mPlayRequested)
play = true;
else if (mVoutCount == 0)
......@@ -392,7 +398,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
}
@Override
public void onSurfacesDestroyed(AWindow vout) {
public void onSurfaceDestroyed() {
boolean disableVideo = false;
synchronized (MediaPlayer.this) {
if (mVoutCount > 0)
......@@ -401,7 +407,9 @@ 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