From 04968a6da511374e393a6becd34ac473fa9f2370 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Tue, 3 Jan 2017 05:06:01 -0800 Subject: [PATCH] Fix condition for re-enabling renderers to handle reading ahead. Issue: #2252 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143433510 --- .../android/exoplayer2/ExoPlayerImplInternal.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index afae56f1aa9..21f3a425a2e 100644 --- a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -1319,7 +1319,6 @@ private void setPlayingPeriodHolder(MediaPeriodHolder periodHolder) throws ExoPl return; } - playingPeriodHolder = periodHolder; int enabledRendererCount = 0; boolean[] rendererWasEnabledFlags = new boolean[renderers.length]; for (int i = 0; i < renderers.length; i++) { @@ -1329,10 +1328,12 @@ private void setPlayingPeriodHolder(MediaPeriodHolder periodHolder) throws ExoPl if (newSelection != null) { enabledRendererCount++; } - if (rendererWasEnabledFlags[i] && (newSelection == null || renderer.isCurrentStreamFinal())) { + if (rendererWasEnabledFlags[i] && (newSelection == null + || (renderer.isCurrentStreamFinal() + && renderer.getStream() == playingPeriodHolder.sampleStreams[i]))) { // The renderer should be disabled before playing the next period, either because it's not - // needed to play the next period, or because we need to disable and re-enable it because - // the renderer thinks that its current stream is final. + // needed to play the next period, or because we need to re-enable it as its current stream + // is final and it's not reading ahead. if (renderer == rendererMediaClockSource) { // Sync standaloneMediaClock so that it can take over timing responsibilities. standaloneMediaClock.setPositionUs(rendererMediaClock.getPositionUs()); @@ -1344,6 +1345,7 @@ private void setPlayingPeriodHolder(MediaPeriodHolder periodHolder) throws ExoPl } } + playingPeriodHolder = periodHolder; eventHandler.obtainMessage(MSG_TRACKS_CHANGED, periodHolder.getTrackInfo()).sendToTarget(); enableRenderers(rendererWasEnabledFlags, enabledRendererCount); }