From d08e8aea1742836a200f088c9b5f85364f5f68bd Mon Sep 17 00:00:00 2001 From: Ian Baker Date: Fri, 20 May 2022 14:35:47 +0100 Subject: [PATCH] Ensure DRAIN_ACTION_FLUSH_AND_UPDATE_DRM_SESSION is executed There's a potential sequence of calls (starting at onPositionReset) that can set codecDrainAction back to NONE without actioning the 'UPDATE_DRM_SESSION' bit. This change ensures that if the action requests a DRM session update we do it before flushing the codec. --- .../exoplayer2/mediacodec/MediaCodecRenderer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index 8c5b081b51..7c722230b6 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -854,6 +854,19 @@ public abstract class MediaCodecRenderer extends BaseRenderer { releaseCodec(); return true; } + if (codecDrainAction == DRAIN_ACTION_FLUSH_AND_UPDATE_DRM_SESSION) { + checkState(Util.SDK_INT >= 23); // Implied by DRAIN_ACTION_FLUSH_AND_UPDATE_DRM_SESSION + // Needed to keep lint happy (it doesn't understand the checkState call alone) + if (Util.SDK_INT >= 23) { + try { + updateDrmSessionV23(); + } catch (ExoPlaybackException e) { + Log.w(TAG, "Failed to update the DRM session, releasing the codec instead.", e); + releaseCodec(); + return true; + } + } + } flushCodec(); return false; } -- 2.36.1.124.g0e6072fb45-goog