MergingMediaPeriod + subtitle fixes
- Correctly null out streams[j] in the case that a renderer is being disabled. - Read discontinuities from all children, not just enabled ones. This fixes a failure when reading a discontinuity with all renderers disabled. - Add in some assertions to make incorrect stream selection failures obvious and immediate. - Relocate subtitles so they're above the shutter (needed so they continue to be visible when video is disabled but text is still enabled). Issue: #1854 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135089944
This commit is contained in:
parent
6306c26988
commit
b29b4f7e1a
@ -1264,11 +1264,14 @@ import java.io.IOException;
|
|||||||
sampleStreams, streamResetFlags, positionUs);
|
sampleStreams, streamResetFlags, positionUs);
|
||||||
periodTrackSelections = trackSelections;
|
periodTrackSelections = trackSelections;
|
||||||
|
|
||||||
|
// Update whether we have enabled tracks and sanity check the expected streams are non-null.
|
||||||
hasEnabledTracks = false;
|
hasEnabledTracks = false;
|
||||||
for (int i = 0; i < sampleStreams.length; i++) {
|
for (int i = 0; i < sampleStreams.length; i++) {
|
||||||
if (sampleStreams[i] != null) {
|
if (sampleStreams[i] != null) {
|
||||||
|
Assertions.checkState(trackSelections.get(i) != null);
|
||||||
hasEnabledTracks = true;
|
hasEnabledTracks = true;
|
||||||
break;
|
} else {
|
||||||
|
Assertions.checkState(trackSelections.get(i) == null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
|
|||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||||
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
@ -103,10 +104,17 @@ import java.util.IdentityHashMap;
|
|||||||
boolean periodEnabled = false;
|
boolean periodEnabled = false;
|
||||||
for (int j = 0; j < selections.length; j++) {
|
for (int j = 0; j < selections.length; j++) {
|
||||||
if (selectionChildIndices[j] == i) {
|
if (selectionChildIndices[j] == i) {
|
||||||
|
// Assert that the child provided a stream for the selection.
|
||||||
|
Assertions.checkState(childStreams[j] != null);
|
||||||
streams[j] = childStreams[j];
|
streams[j] = childStreams[j];
|
||||||
if (childStreams[j] != null) {
|
|
||||||
periodEnabled = true;
|
periodEnabled = true;
|
||||||
streamPeriodIndices.put(childStreams[j], i);
|
streamPeriodIndices.put(childStreams[j], i);
|
||||||
|
} else if (streamChildIndices[j] == i) {
|
||||||
|
// Assert that the child cleared any previous stream.
|
||||||
|
Assertions.checkState(childStreams[j] == null);
|
||||||
|
if (selectionChildIndices[j] == C.INDEX_UNSET) {
|
||||||
|
// No other child will be setting the stream at index j, so clear it.
|
||||||
|
streams[j] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,21 +141,22 @@ import java.util.IdentityHashMap;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long readDiscontinuity() {
|
public long readDiscontinuity() {
|
||||||
long positionUs = enabledPeriods[0].readDiscontinuity();
|
long positionUs = periods[0].readDiscontinuity();
|
||||||
|
// Periods other than the first one are not allowed to report discontinuities.
|
||||||
|
for (int i = 1; i < periods.length; i++) {
|
||||||
|
if (periods[i].readDiscontinuity() != C.TIME_UNSET) {
|
||||||
|
throw new IllegalStateException("Child reported discontinuity");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// It must be possible to seek enabled periods to the new position, if there is one.
|
||||||
if (positionUs != C.TIME_UNSET) {
|
if (positionUs != C.TIME_UNSET) {
|
||||||
// It must be possible to seek additional periods to the new position.
|
for (int i = 0; i < enabledPeriods.length; i++) {
|
||||||
for (int i = 1; i < enabledPeriods.length; i++) {
|
if (enabledPeriods[i] != periods[0]
|
||||||
if (enabledPeriods[i].seekToUs(positionUs) != positionUs) {
|
&& enabledPeriods[i].seekToUs(positionUs) != positionUs) {
|
||||||
throw new IllegalStateException("Children seeked to different positions");
|
throw new IllegalStateException("Children seeked to different positions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Additional periods are not allowed to report discontinuities.
|
|
||||||
for (int i = 1; i < enabledPeriods.length; i++) {
|
|
||||||
if (enabledPeriods[i].readDiscontinuity() != C.TIME_UNSET) {
|
|
||||||
throw new IllegalStateException("Child reported discontinuity");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return positionUs;
|
return positionUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center">
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<View android:id="@+id/shutter"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/black"/>
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.SubtitleView android:id="@+id/subtitles"
|
<com.google.android.exoplayer2.ui.SubtitleView android:id="@+id/subtitles"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
|
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
|
||||||
|
|
||||||
<View android:id="@+id/shutter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@android:color/black"/>
|
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.PlaybackControlView android:id="@+id/control"
|
<com.google.android.exoplayer2.ui.PlaybackControlView android:id="@+id/control"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user