Commit 1c6abc8b by olly Committed by Oliver Woodman

Set output on surface in all states

setSurface only sets the output surface on the codec if the
renderer is enabled or started. This was fine in the past
because the codec was always null in other states, however
the recent codec reuse work means this is no longer the case.

The output surface should always be set if the codec is
non-null. If setting the surface requires releasing the codec
instance, we should only instantiate the new instance if
enabled or started. This is in line with what onDisabled does
if flushing requires releasing the codec

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217676434
parent 05a98a7b
...@@ -415,16 +415,17 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -415,16 +415,17 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
if (this.surface != surface) { if (this.surface != surface) {
this.surface = surface; this.surface = surface;
@State int state = getState(); @State int state = getState();
if (state == STATE_ENABLED || state == STATE_STARTED) {
MediaCodec codec = getCodec(); MediaCodec codec = getCodec();
if (Util.SDK_INT >= 23 && codec != null && surface != null if (codec != null) {
&& !codecNeedsSetOutputSurfaceWorkaround) { if (Util.SDK_INT >= 23 && surface != null && !codecNeedsSetOutputSurfaceWorkaround) {
setOutputSurfaceV23(codec, surface); setOutputSurfaceV23(codec, surface);
} else { } else {
releaseCodec(); releaseCodec();
if (state == STATE_ENABLED || state == STATE_STARTED) {
maybeInitCodec(); maybeInitCodec();
} }
} }
}
if (surface != null && surface != dummySurface) { if (surface != null && surface != dummySurface) {
// If we know the video size, report it again immediately. // If we know the video size, report it again immediately.
maybeRenotifyVideoSizeChanged(); maybeRenotifyVideoSizeChanged();
......
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