mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix merging of selected streams.
Playback would fail if a renderer is toggled from consuming from one child to another in a single step. Issue: #1900 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135270356
This commit is contained in:
parent
053dc27a3e
commit
d334dfdcba
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
* Fixes for MergingMediaSource and sideloaded subtitles.
|
* Fixes for MergingMediaSource and sideloaded subtitles.
|
||||||
([#1882](https://github.com/google/ExoPlayer/issues/1882),
|
([#1882](https://github.com/google/ExoPlayer/issues/1882),
|
||||||
[#1854](https://github.com/google/ExoPlayer/issues/1854)).
|
[#1854](https://github.com/google/ExoPlayer/issues/1854),
|
||||||
|
[#1900](https://github.com/google/ExoPlayer/issues/1900)).
|
||||||
* Reduced effect of application code leaking player references
|
* Reduced effect of application code leaking player references
|
||||||
([#1855](https://github.com/google/ExoPlayer/issues/1855)).
|
([#1855](https://github.com/google/ExoPlayer/issues/1855)).
|
||||||
* Initial support for fragmented MP4 in HLS.
|
* Initial support for fragmented MP4 in HLS.
|
||||||
|
@ -85,7 +85,8 @@ import java.util.IdentityHashMap;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
streamPeriodIndices.clear();
|
streamPeriodIndices.clear();
|
||||||
// Select tracks for each child, copying the resulting streams back into the streams array.
|
// Select tracks for each child, copying the resulting streams back into a new streams array.
|
||||||
|
SampleStream[] newStreams = new SampleStream[selections.length];
|
||||||
SampleStream[] childStreams = new SampleStream[selections.length];
|
SampleStream[] childStreams = new SampleStream[selections.length];
|
||||||
TrackSelection[] childSelections = new TrackSelection[selections.length];
|
TrackSelection[] childSelections = new TrackSelection[selections.length];
|
||||||
ArrayList<MediaPeriod> enabledPeriodsList = new ArrayList<>(periods.length);
|
ArrayList<MediaPeriod> enabledPeriodsList = new ArrayList<>(periods.length);
|
||||||
@ -106,22 +107,20 @@ import java.util.IdentityHashMap;
|
|||||||
if (selectionChildIndices[j] == i) {
|
if (selectionChildIndices[j] == i) {
|
||||||
// Assert that the child provided a stream for the selection.
|
// Assert that the child provided a stream for the selection.
|
||||||
Assertions.checkState(childStreams[j] != null);
|
Assertions.checkState(childStreams[j] != null);
|
||||||
streams[j] = childStreams[j];
|
newStreams[j] = childStreams[j];
|
||||||
periodEnabled = true;
|
periodEnabled = true;
|
||||||
streamPeriodIndices.put(childStreams[j], i);
|
streamPeriodIndices.put(childStreams[j], i);
|
||||||
} else if (streamChildIndices[j] == i) {
|
} else if (streamChildIndices[j] == i) {
|
||||||
// Assert that the child cleared any previous stream.
|
// Assert that the child cleared any previous stream.
|
||||||
Assertions.checkState(childStreams[j] == null);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (periodEnabled) {
|
if (periodEnabled) {
|
||||||
enabledPeriodsList.add(periods[i]);
|
enabledPeriodsList.add(periods[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Copy the new streams back into the streams array.
|
||||||
|
System.arraycopy(newStreams, 0, streams, 0, newStreams.length);
|
||||||
// Update the local state.
|
// Update the local state.
|
||||||
enabledPeriods = new MediaPeriod[enabledPeriodsList.size()];
|
enabledPeriods = new MediaPeriod[enabledPeriodsList.size()];
|
||||||
enabledPeriodsList.toArray(enabledPeriods);
|
enabledPeriodsList.toArray(enabledPeriods);
|
||||||
|
@ -39,6 +39,7 @@ import com.google.android.exoplayer2.upstream.Allocator;
|
|||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.Loader;
|
import com.google.android.exoplayer2.upstream.Loader;
|
||||||
import com.google.android.exoplayer2.upstream.ParsingLoadable;
|
import com.google.android.exoplayer2.upstream.ParsingLoadable;
|
||||||
|
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;
|
||||||
@ -154,7 +155,8 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
boolean selectedNewTracks = false;
|
boolean selectedNewTracks = false;
|
||||||
streamWrapperIndices.clear();
|
streamWrapperIndices.clear();
|
||||||
// Select tracks for each child, copying the resulting streams back into the streams array.
|
// Select tracks for each child, copying the resulting streams back into a new streams array.
|
||||||
|
SampleStream[] newStreams = new SampleStream[selections.length];
|
||||||
SampleStream[] childStreams = new SampleStream[selections.length];
|
SampleStream[] childStreams = new SampleStream[selections.length];
|
||||||
TrackSelection[] childSelections = new TrackSelection[selections.length];
|
TrackSelection[] childSelections = new TrackSelection[selections.length];
|
||||||
ArrayList<HlsSampleStreamWrapper> enabledSampleStreamWrapperList = new ArrayList<>(
|
ArrayList<HlsSampleStreamWrapper> enabledSampleStreamWrapperList = new ArrayList<>(
|
||||||
@ -168,19 +170,23 @@ import java.util.List;
|
|||||||
mayRetainStreamFlags, childStreams, streamResetFlags, !seenFirstTrackSelection);
|
mayRetainStreamFlags, childStreams, streamResetFlags, !seenFirstTrackSelection);
|
||||||
boolean wrapperEnabled = false;
|
boolean wrapperEnabled = 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) {
|
||||||
|| (selectionChildIndices[j] == C.INDEX_UNSET && streamChildIndices[j] == i)) {
|
// Assert that the child provided a stream for the selection.
|
||||||
streams[j] = childStreams[j];
|
Assertions.checkState(childStreams[j] != null);
|
||||||
if (childStreams[j] != null) {
|
newStreams[j] = childStreams[j];
|
||||||
wrapperEnabled = true;
|
wrapperEnabled = true;
|
||||||
streamWrapperIndices.put(childStreams[j], i);
|
streamWrapperIndices.put(childStreams[j], i);
|
||||||
}
|
} else if (streamChildIndices[j] == i) {
|
||||||
|
// Assert that the child cleared any previous stream.
|
||||||
|
Assertions.checkState(childStreams[j] == null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wrapperEnabled) {
|
if (wrapperEnabled) {
|
||||||
enabledSampleStreamWrapperList.add(sampleStreamWrappers[i]);
|
enabledSampleStreamWrapperList.add(sampleStreamWrappers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Copy the new streams back into the streams array.
|
||||||
|
System.arraycopy(newStreams, 0, streams, 0, newStreams.length);
|
||||||
// Update the local state.
|
// Update the local state.
|
||||||
enabledSampleStreamWrappers = new HlsSampleStreamWrapper[enabledSampleStreamWrapperList.size()];
|
enabledSampleStreamWrappers = new HlsSampleStreamWrapper[enabledSampleStreamWrapperList.size()];
|
||||||
enabledSampleStreamWrapperList.toArray(enabledSampleStreamWrappers);
|
enabledSampleStreamWrapperList.toArray(enabledSampleStreamWrappers);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user