mirror of
https://github.com/samsonjs/media.git
synced 2026-04-06 11:25:46 +00:00
Add utility to create ScheduledExecutorService
PiperOrigin-RevId: 538129792
This commit is contained in:
parent
d9764c18ad
commit
08e7158be5
2 changed files with 14 additions and 2 deletions
|
|
@ -117,6 +117,7 @@ import java.util.concurrent.CancellationException;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
|
@ -742,6 +743,17 @@ public final class Util {
|
|||
return Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, threadName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new single threaded scheduled executor whose thread has the specified name.
|
||||
*
|
||||
* @param threadName The name of the thread.
|
||||
* @return The executor.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static ScheduledExecutorService newSingleThreadScheduledExecutor(String threadName) {
|
||||
return Executors.newSingleThreadScheduledExecutor(runnable -> new Thread(runnable, threadName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a {@link Closeable}, suppressing any {@link IOException} that may occur. Both {@link
|
||||
* java.io.OutputStream} and {@link InputStream} are {@code Closeable}.
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import androidx.media3.effect.DebugTraceUtil;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
|
||||
|
|
@ -48,6 +47,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
*/
|
||||
/* package */ final class MuxerWrapper {
|
||||
|
||||
private static final String TIMER_THREAD_NAME = "Muxer:Timer";
|
||||
private static final String MUXER_TIMEOUT_ERROR_FORMAT_STRING =
|
||||
"Abort: no output sample written in the last %d milliseconds. DebugTrace: %s";
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
|
||||
trackTypeToInfo = new SparseArray<>();
|
||||
previousTrackType = C.TRACK_TYPE_NONE;
|
||||
abortScheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
|
||||
abortScheduledExecutorService = Util.newSingleThreadScheduledExecutor(TIMER_THREAD_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue