Add common prefix to loader thread names

All threads created by ExoPlayer should now have the prefix "ExoPlayer:".

PiperOrigin-RevId: 356518037
This commit is contained in:
andrewlewis 2021-02-09 17:23:58 +00:00 committed by Ian Baker
parent 50db2ee172
commit e28332ff82
8 changed files with 14 additions and 10 deletions

View File

@ -538,7 +538,7 @@ public final class Util {
* @param threadName The name of the thread.
* @return The executor.
*/
public static ExecutorService newSingleThreadExecutor(final String threadName) {
public static ExecutorService newSingleThreadExecutor(String threadName) {
return Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, threadName));
}

View File

@ -187,7 +187,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
this.allocator = allocator;
this.customCacheKey = customCacheKey;
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
loader = new Loader("Loader:ProgressiveMediaPeriod");
loader = new Loader("ProgressiveMediaPeriod");
this.progressiveMediaExtractor = new BundledExtractorsAdapter(extractorsFactory);
loadCondition = new ConditionVariable();
maybeFinishPrepareRunnable = this::maybeFinishPrepare;

View File

@ -88,7 +88,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
tracks = new TrackGroupArray(new TrackGroup(format));
sampleStreams = new ArrayList<>();
loader = new Loader("Loader:SingleSampleMediaPeriod");
loader = new Loader("SingleSampleMediaPeriod");
}
public void release() {

View File

@ -133,7 +133,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
this.callback = callback;
this.mediaSourceEventDispatcher = mediaSourceEventDispatcher;
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
loader = new Loader("Loader:ChunkSampleStream");
loader = new Loader("ChunkSampleStream");
nextChunkHolder = new ChunkHolder();
mediaChunks = new ArrayList<>();
readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);

View File

@ -152,6 +152,8 @@ public final class Loader implements LoaderErrorThrower {
}
private static final String THREAD_NAME_PREFIX = "ExoPlayer:Loader:";
/** Types of action that can be taken in response to a load error. */
@Documented
@Retention(RetentionPolicy.SOURCE)
@ -210,10 +212,12 @@ public final class Loader implements LoaderErrorThrower {
@Nullable private IOException fatalError;
/**
* @param threadName A name for the loader's thread.
* @param threadNameSuffix A name suffix for the loader's thread. This should be the name of the
* component using the loader.
*/
public Loader(String threadName) {
this.downloadExecutorService = Util.newSingleThreadExecutor(threadName);
public Loader(String threadNameSuffix) {
this.downloadExecutorService =
Util.newSingleThreadExecutor(THREAD_NAME_PREFIX + threadNameSuffix);
}
/**

View File

@ -7392,7 +7392,7 @@ public final class ExoPlayerTest {
drmSessionManager,
drmEventDispatcher,
/* deferOnPrepared= */ false) {
private Loader loader = new Loader("oomLoader");
private final Loader loader = new Loader("ExoPlayerTest");
@Override
public boolean continueLoading(long positionUs) {

View File

@ -562,7 +562,7 @@ public final class DashMediaSource extends BaseMediaSource {
processManifest(false);
} else {
dataSource = manifestDataSourceFactory.createDataSource();
loader = new Loader("Loader:DashMediaSource");
loader = new Loader("DashMediaSource");
handler = Util.createHandlerForCurrentLooper();
startLoadingManifest();
}

View File

@ -451,7 +451,7 @@ public final class SsMediaSource extends BaseMediaSource
processManifest();
} else {
manifestDataSource = manifestDataSourceFactory.createDataSource();
manifestLoader = new Loader("Loader:Manifest");
manifestLoader = new Loader("SsMediaSource");
manifestLoaderErrorThrower = manifestLoader;
manifestRefreshHandler = Util.createHandlerForCurrentLooper();
startLoadingManifest();