Commit 64262085 by olly Committed by Oliver Woodman

Block when surface being replaced is non-null

A blocking call is necessary where we want to guarantee that
the player wont access the surface after the method call has
returned. We currently only do this for the case:

Surface->Null

But we should also do it for the case:

SurfaceA->SurfaceB

Since the caller may reasonably do something like destroy
SurfaceA immediately after it's been replaced.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135921296
parent f18373ee
......@@ -619,7 +619,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
}
private void setVideoSurfaceInternal(Surface surface) {
this.surface = surface;
// Note: We don't turn this method into a no-op if the surface is being replaced with itself
// so as to ensure onRenderedFirstFrame callbacks are still called in this case.
ExoPlayerMessage[] messages = new ExoPlayerMessage[videoRendererCount];
int count = 0;
for (Renderer renderer : renderers) {
......@@ -627,12 +628,13 @@ public final class SimpleExoPlayer implements ExoPlayer {
messages[count++] = new ExoPlayerMessage(renderer, C.MSG_SET_SURFACE, surface);
}
}
if (surface == null) {
// Block to ensure that the surface is not accessed after the method returns.
if (this.surface != null && this.surface != surface) {
// We're replacing a surface. Block to ensure that it's not accessed after the method returns.
player.blockingSendMessages(messages);
} else {
player.sendMessages(messages);
}
this.surface = surface;
}
private final class ComponentListener implements VideoRendererEventListener,
......
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 sign in to comment