mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00
Split HlsSampleStreamWrapper.init into two methods
As a result, onMediaChunkLoadStarted gets invoked on the loading thread, and init on the playback thread, matching the thread access comments. Issue:#6321 PiperOrigin-RevId: 289167981
This commit is contained in:
parent
01e661f21a
commit
7f7632a38f
@ -284,6 +284,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
*/
|
*/
|
||||||
public void init(HlsSampleStreamWrapper output) {
|
public void init(HlsSampleStreamWrapper output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
output.init(uid, shouldSpliceIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -306,7 +307,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
extractor = previousExtractor;
|
extractor = previousExtractor;
|
||||||
isExtractorReusable = true;
|
isExtractorReusable = true;
|
||||||
initDataLoadRequired = false;
|
initDataLoadRequired = false;
|
||||||
output.init(uid, shouldSpliceIn, /* reusingExtractor= */ true);
|
|
||||||
}
|
}
|
||||||
maybeLoadInitData();
|
maybeLoadInitData();
|
||||||
if (!loadCanceled) {
|
if (!loadCanceled) {
|
||||||
@ -418,7 +418,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
// the timestamp offset.
|
// the timestamp offset.
|
||||||
output.setSampleOffsetUs(/* sampleOffsetUs= */ 0L);
|
output.setSampleOffsetUs(/* sampleOffsetUs= */ 0L);
|
||||||
}
|
}
|
||||||
output.init(uid, shouldSpliceIn, /* reusingExtractor= */ false);
|
output.onNewExtractor();
|
||||||
extractor.init(output);
|
extractor.init(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import com.google.android.exoplayer2.drm.DrmInitData;
|
|||||||
import com.google.android.exoplayer2.drm.DrmSession;
|
import com.google.android.exoplayer2.drm.DrmSession;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
|
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
|
||||||
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorInput;
|
import com.google.android.exoplayer2.extractor.ExtractorInput;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorOutput;
|
import com.google.android.exoplayer2.extractor.ExtractorOutput;
|
||||||
import com.google.android.exoplayer2.extractor.SeekMap;
|
import com.google.android.exoplayer2.extractor.SeekMap;
|
||||||
@ -823,13 +824,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
* @param chunkUid The chunk's uid.
|
* @param chunkUid The chunk's uid.
|
||||||
* @param shouldSpliceIn Whether the samples parsed from the chunk should be spliced into any
|
* @param shouldSpliceIn Whether the samples parsed from the chunk should be spliced into any
|
||||||
* samples already queued to the wrapper.
|
* samples already queued to the wrapper.
|
||||||
* @param reusingExtractor Whether the extractor for the chunk has already been used for preceding
|
|
||||||
* chunks.
|
|
||||||
*/
|
*/
|
||||||
public void init(int chunkUid, boolean shouldSpliceIn, boolean reusingExtractor) {
|
public void init(int chunkUid, boolean shouldSpliceIn) {
|
||||||
if (!reusingExtractor) {
|
|
||||||
sampleQueueMappingDoneByType.clear();
|
|
||||||
}
|
|
||||||
this.chunkUid = chunkUid;
|
this.chunkUid = chunkUid;
|
||||||
for (SampleQueue sampleQueue : sampleQueues) {
|
for (SampleQueue sampleQueue : sampleQueues) {
|
||||||
sampleQueue.sourceId(chunkUid);
|
sampleQueue.sourceId(chunkUid);
|
||||||
@ -884,8 +880,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
* different ID, then return a {@link DummyTrackOutput} that does nothing.
|
* different ID, then return a {@link DummyTrackOutput} that does nothing.
|
||||||
*
|
*
|
||||||
* <p>If a {@link SampleQueue} for {@code type} has been created but is not mapped, then map it to
|
* <p>If a {@link SampleQueue} for {@code type} has been created but is not mapped, then map it to
|
||||||
* this {@code id} and return it. This situation can happen after a call to {@link #init} with
|
* this {@code id} and return it. This situation can happen after a call to {@link
|
||||||
* {@code reusingExtractor=false}.
|
* #onNewExtractor}.
|
||||||
*
|
*
|
||||||
* @param id The ID of the track.
|
* @param id The ID of the track.
|
||||||
* @param type The type of the track, must be one of {@link #MAPPABLE_TYPES}.
|
* @param type The type of the track, must be one of {@link #MAPPABLE_TYPES}.
|
||||||
@ -952,6 +948,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
|
|
||||||
// Called by the loading thread.
|
// Called by the loading thread.
|
||||||
|
|
||||||
|
/** Called when an {@link HlsMediaChunk} starts extracting media with a new {@link Extractor}. */
|
||||||
|
public void onNewExtractor() {
|
||||||
|
sampleQueueMappingDoneByType.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void setSampleOffsetUs(long sampleOffsetUs) {
|
public void setSampleOffsetUs(long sampleOffsetUs) {
|
||||||
this.sampleOffsetUs = sampleOffsetUs;
|
this.sampleOffsetUs = sampleOffsetUs;
|
||||||
for (SampleQueue sampleQueue : sampleQueues) {
|
for (SampleQueue sampleQueue : sampleQueues) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user