From ad95a147d24d2a16412d70ba5981ea1f8f5fa303 Mon Sep 17 00:00:00 2001 From: hoangtc Date: Fri, 22 Dec 2017 05:33:11 -0800 Subject: [PATCH] Fix a bug that makes ClippingMediaSource not stop in some occasions. If ClippingMediaSource contains a child MediaSource with embedded metadata stream, and the embedded stream is being used, it can lead to ClippingMediaSource not be able to stop after the clipping end point. The reason being the metadata stream cannot read anymore sample, but it's also not end of source at that point. This CL fix this by changing the condition to check if the child stream cannot read anymore sample and it has read past the clipping end point. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179918038 --- .../android/exoplayer2/source/ClippingMediaPeriod.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java index 89af07a3f0..d27c329845 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java @@ -278,9 +278,10 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb formatHolder.format = format.copyWithGaplessInfo(encoderDelay, encoderPadding); return C.RESULT_FORMAT_READ; } - if (endUs != C.TIME_END_OF_SOURCE && ((result == C.RESULT_BUFFER_READ - && buffer.timeUs >= endUs) || (result == C.RESULT_NOTHING_READ - && mediaPeriod.getBufferedPositionUs() == C.TIME_END_OF_SOURCE))) { + if (endUs != C.TIME_END_OF_SOURCE + && ((result == C.RESULT_BUFFER_READ && buffer.timeUs >= endUs) + || (result == C.RESULT_NOTHING_READ + && getBufferedPositionUs() == C.TIME_END_OF_SOURCE))) { buffer.clear(); buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM); sentEos = true;