Check if codec still exists before handling tunneling events

The tunneling callbacks are sent via Handler messages and may be
handled after the codec/surface was changed or released.

We already guard against the codec/surface change condition by
creating a new listener and verifying that the current callback
happens for the correct listener instance, but we don't guard
against a released codec yet.

PiperOrigin-RevId: 495882353
(cherry picked from commit 5e23b8bfd5a9a9542c2ab8d23ae51c1689d8ff51)
This commit is contained in:
tonihei 2022-12-16 16:39:12 +00:00 committed by christosts
parent f1784862e0
commit 0ab7c752d7

View File

@ -2047,7 +2047,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
private void handleFrameRendered(long presentationTimeUs) {
if (this != tunnelingOnFrameRenderedListener) {
if (this != tunnelingOnFrameRenderedListener || getCodec() == null) {
// Stale event.
return;
}