From cb5c78917c3a45b613dd03bfe2b38eb218098dff Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 7 Sep 2018 05:20:20 -0700 Subject: [PATCH] Simplify notification of downstream format change for embedded track - There's no particular need to read or skip a sample before notifying - Add missing isPendingReset check Issue: #4533 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=211959762 --- .../source/chunk/ChunkSampleStream.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java index 383f3dfc15..6fc37ff501 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java @@ -753,6 +753,10 @@ public class ChunkSampleStream implements SampleStream, S @Override public int skipData(long positionUs) { + if (isPendingReset()) { + return 0; + } + maybeNotifyTrackFormatChanged(); int skipCount; if (loadingFinished && positionUs > sampleQueue.getLargestQueuedTimestampUs()) { skipCount = sampleQueue.advanceToEnd(); @@ -762,9 +766,6 @@ public class ChunkSampleStream implements SampleStream, S skipCount = 0; } } - if (skipCount > 0) { - maybeNotifyTrackFormatChanged(); - } return skipCount; } @@ -779,13 +780,9 @@ public class ChunkSampleStream implements SampleStream, S if (isPendingReset()) { return C.RESULT_NOTHING_READ; } - int result = - sampleQueue.read( - formatHolder, buffer, formatRequired, loadingFinished, decodeOnlyUntilPositionUs); - if (result == C.RESULT_BUFFER_READ) { - maybeNotifyTrackFormatChanged(); - } - return result; + maybeNotifyTrackFormatChanged(); + return sampleQueue.read( + formatHolder, buffer, formatRequired, loadingFinished, decodeOnlyUntilPositionUs); } public void release() {