Commit 679e3751 by ibaker Committed by bachinger

Fix bug in MCVR where dummySurface is released but surface isn't nulled

The fix for Issue: #8776 was to release and null-out dummySurface if
it doesn't match the security level of the decoder. But it's possible
that this.surface is already set to this.dummySurface, in which case we
must also null out this.surface otherwise we will later try and re-use
the old, released DummySurface instance.

This logic already exists in MCVR#onReset, so I pulled it into a
releaseDummySurface() helper function.

Issue: #9476
#minor-release
PiperOrigin-RevId: 399420476
parent 3e7b2d06
......@@ -13,6 +13,10 @@
`GlUtil.glAssertionsEnabled` instead.
* Move `Player.addListener(EventListener)` and
`Player.removeListener(EventListener)` out of `Player` into subclasses.
* Video:
* Fix bug in `MediaCodecVideoRenderer` that resulted in re-using a
released `Surface` when playing without an app-provided `Surface`
([#9476](https://github.com/google/ExoPlayer/issues/9476)).
* Android 12 compatibility:
* Keep `DownloadService` started and in the foreground whilst waiting for
requirements to be met on Android 12. This is necessary due to new
......
......@@ -495,11 +495,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
super.onReset();
} finally {
if (dummySurface != null) {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
releaseDummySurface();
}
}
}
......@@ -618,8 +614,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
float codecOperatingRate) {
if (dummySurface != null && dummySurface.secure != codecInfo.secure) {
// We can't re-use the current DummySurface instance with the new decoder.
dummySurface.release();
dummySurface = null;
releaseDummySurface();
}
String codecMimeType = codecInfo.codecMimeType;
codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
......@@ -1178,6 +1173,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
&& (!codecInfo.secure || DummySurface.isSecureSupported(context));
}
private void releaseDummySurface() {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
}
private void setJoiningDeadlineMs() {
joiningDeadlineMs =
allowedJoiningTimeMs > 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 sign in to comment