Commit c5c4c877 by tonihei Committed by Andrew Lewis

Restrict some Handler to current Looper only.

They currently fall back to the main Looper if the current thread
doesn't have a Looper. All the changed Handlers are guaranteed to
be created on a thread with a Looper (mostly the ExoPlayer playback
Looper) and thus can make this stricter assumption. This makes it
easier to reason about the code as there are no ambiguities as to which
thread the Handler is running on.

PiperOrigin-RevId: 317334503
parent 7d66865d
...@@ -396,6 +396,32 @@ public final class Util { ...@@ -396,6 +396,32 @@ public final class Util {
/** /**
* Creates a {@link Handler} on the current {@link Looper} thread. * Creates a {@link Handler} on the current {@link Looper} thread.
* *
* @throws IllegalStateException If the current thread doesn't have a {@link Looper}.
*/
public static Handler createHandlerForCurrentLooper() {
return createHandlerForCurrentLooper(/* callback= */ null);
}
/**
* Creates a {@link Handler} with the specified {@link Handler.Callback} on the current {@link
* Looper} thread.
*
* <p>The method accepts partially initialized objects as callback under the assumption that the
* Handler won't be used to send messages until the callback is fully initialized.
*
* @param callback A {@link Handler.Callback}. May be a partially initialized class, or null if no
* callback is required.
* @return A {@link Handler} with the specified callback on the current {@link Looper} thread.
* @throws IllegalStateException If the current thread doesn't have a {@link Looper}.
*/
public static Handler createHandlerForCurrentLooper(
@Nullable Handler.@UnknownInitialization Callback callback) {
return createHandler(Assertions.checkStateNotNull(Looper.myLooper()), callback);
}
/**
* Creates a {@link Handler} on the current {@link Looper} thread.
*
* <p>If the current thread doesn't have a {@link Looper}, the application's main thread {@link * <p>If the current thread doesn't have a {@link Looper}, the application's main thread {@link
* Looper} is used. * Looper} is used.
*/ */
...@@ -405,9 +431,10 @@ public final class Util { ...@@ -405,9 +431,10 @@ public final class Util {
/** /**
* Creates a {@link Handler} with the specified {@link Handler.Callback} on the current {@link * Creates a {@link Handler} with the specified {@link Handler.Callback} on the current {@link
* Looper} thread. The method accepts partially initialized objects as callback under the * Looper} thread.
* assumption that the Handler won't be used to send messages until the callback is fully *
* initialized. * <p>The method accepts partially initialized objects as callback under the assumption that the
* Handler won't be used to send messages until the callback is fully initialized.
* *
* <p>If the current thread doesn't have a {@link Looper}, the application's main thread {@link * <p>If the current thread doesn't have a {@link Looper}, the application's main thread {@link
* Looper} is used. * Looper} is used.
...@@ -423,9 +450,10 @@ public final class Util { ...@@ -423,9 +450,10 @@ public final class Util {
/** /**
* Creates a {@link Handler} with the specified {@link Handler.Callback} on the specified {@link * Creates a {@link Handler} with the specified {@link Handler.Callback} on the specified {@link
* Looper} thread. The method accepts partially initialized objects as callback under the * Looper} thread.
* assumption that the Handler won't be used to send messages until the callback is fully *
* initialized. * <p>The method accepts partially initialized objects as callback under the assumption that the
* Handler won't be used to send messages until the callback is fully initialized.
* *
* @param looper A {@link Looper} to run the callback on. * @param looper A {@link Looper} to run the callback on.
* @param callback A {@link Handler.Callback}. May be a partially initialized class, or null if no * @param callback A {@link Handler.Callback}. May be a partially initialized class, or null if no
......
...@@ -48,7 +48,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource { ...@@ -48,7 +48,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
@CallSuper @CallSuper
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) { protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
this.mediaTransferListener = mediaTransferListener; this.mediaTransferListener = mediaTransferListener;
eventHandler = Util.createHandlerForCurrentOrMainLooper(); eventHandler = Util.createHandlerForCurrentLooper();
} }
@Override @Override
......
...@@ -192,7 +192,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -192,7 +192,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
.onContinueLoadingRequested(ProgressiveMediaPeriod.this); .onContinueLoadingRequested(ProgressiveMediaPeriod.this);
} }
}; };
handler = Util.createHandlerForCurrentOrMainLooper(); handler = Util.createHandlerForCurrentLooper();
sampleQueueTrackIds = new TrackId[0]; sampleQueueTrackIds = new TrackId[0];
sampleQueues = new SampleQueue[0]; sampleQueues = new SampleQueue[0];
pendingResetPositionUs = C.TIME_UNSET; pendingResetPositionUs = C.TIME_UNSET;
......
...@@ -336,7 +336,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -336,7 +336,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
* events on the external event listener thread. * events on the external event listener thread.
*/ */
public ComponentListener() { public ComponentListener() {
playerHandler = Util.createHandlerForCurrentOrMainLooper(); playerHandler = Util.createHandlerForCurrentLooper();
} }
/** Releases the component listener. */ /** Releases the component listener. */
......
...@@ -1763,7 +1763,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -1763,7 +1763,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private final Handler handler; private final Handler handler;
public OnFrameRenderedListenerV23(MediaCodec codec) { public OnFrameRenderedListenerV23(MediaCodec codec) {
handler = Util.createHandlerForCurrentOrMainLooper(/* callback= */ this); handler = Util.createHandlerForCurrentLooper(/* callback= */ this);
codec.setOnFrameRenderedListener(/* listener= */ this, handler); codec.setOnFrameRenderedListener(/* listener= */ this, handler);
} }
......
...@@ -599,7 +599,7 @@ public final class ClippingMediaSourceTest { ...@@ -599,7 +599,7 @@ public final class ClippingMediaSourceTest {
testRunner.runOnPlaybackThread( testRunner.runOnPlaybackThread(
() -> () ->
clippingMediaSource.addEventListener( clippingMediaSource.addEventListener(
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
new MediaSourceEventListener() { new MediaSourceEventListener() {
@Override @Override
public void onDownstreamFormatChanged( public void onDownstreamFormatChanged(
......
...@@ -413,7 +413,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -413,7 +413,7 @@ public final class ConcatenatingMediaSourceTest {
() -> () ->
mediaSource.addMediaSource( mediaSource.addMediaSource(
createFakeMediaSource(), createFakeMediaSource(),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); dummyMainThread.release();
...@@ -430,7 +430,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -430,7 +430,7 @@ public final class ConcatenatingMediaSourceTest {
() -> () ->
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}), Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); dummyMainThread.release();
...@@ -448,7 +448,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -448,7 +448,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.addMediaSource( mediaSource.addMediaSource(
/* index */ 0, /* index */ 0,
createFakeMediaSource(), createFakeMediaSource(),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); dummyMainThread.release();
...@@ -466,7 +466,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -466,7 +466,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.addMediaSources( mediaSource.addMediaSources(
/* index */ 0, /* index */ 0,
Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}), Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); dummyMainThread.release();
...@@ -483,9 +483,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -483,9 +483,7 @@ public final class ConcatenatingMediaSourceTest {
() -> { () -> {
mediaSource.addMediaSource(createFakeMediaSource()); mediaSource.addMediaSource(createFakeMediaSource());
mediaSource.removeMediaSource( mediaSource.removeMediaSource(
/* index */ 0, /* index */ 0, Util.createHandlerForCurrentLooper(), runnableInvoked::countDown);
Util.createHandlerForCurrentOrMainLooper(),
runnableInvoked::countDown);
}); });
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); dummyMainThread.release();
...@@ -505,7 +503,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -505,7 +503,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.moveMediaSource( mediaSource.moveMediaSource(
/* fromIndex */ 1, /* toIndex */ /* fromIndex */ 1, /* toIndex */
0, 0,
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown); runnableInvoked::countDown);
}); });
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
...@@ -523,9 +521,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -523,9 +521,7 @@ public final class ConcatenatingMediaSourceTest {
dummyMainThread.runOnMainThread( dummyMainThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSource( mediaSource.addMediaSource(
createFakeMediaSource(), createFakeMediaSource(), Util.createHandlerForCurrentLooper(), timelineGrabber));
Util.createHandlerForCurrentOrMainLooper(),
timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1); assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally { } finally {
...@@ -544,7 +540,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -544,7 +540,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList( Arrays.asList(
new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}), new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
timelineGrabber)); timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2); assertThat(timeline.getWindowCount()).isEqualTo(2);
...@@ -564,7 +560,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -564,7 +560,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.addMediaSource( mediaSource.addMediaSource(
/* index */ 0, /* index */ 0,
createFakeMediaSource(), createFakeMediaSource(),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
timelineGrabber)); timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1); assertThat(timeline.getWindowCount()).isEqualTo(1);
...@@ -585,7 +581,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -585,7 +581,7 @@ public final class ConcatenatingMediaSourceTest {
/* index */ 0, /* index */ 0,
Arrays.asList( Arrays.asList(
new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}), new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
timelineGrabber)); timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2); assertThat(timeline.getWindowCount()).isEqualTo(2);
...@@ -606,7 +602,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -606,7 +602,7 @@ public final class ConcatenatingMediaSourceTest {
dummyMainThread.runOnMainThread( dummyMainThread.runOnMainThread(
() -> () ->
mediaSource.removeMediaSource( mediaSource.removeMediaSource(
/* index */ 0, Util.createHandlerForCurrentOrMainLooper(), timelineGrabber)); /* index */ 0, Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(0); assertThat(timeline.getWindowCount()).isEqualTo(0);
} finally { } finally {
...@@ -632,7 +628,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -632,7 +628,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.moveMediaSource( mediaSource.moveMediaSource(
/* fromIndex */ 1, /* toIndex */ /* fromIndex */ 1, /* toIndex */
0, 0,
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
timelineGrabber)); timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2); assertThat(timeline.getWindowCount()).isEqualTo(2);
...@@ -654,7 +650,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -654,7 +650,7 @@ public final class ConcatenatingMediaSourceTest {
mediaSource.moveMediaSource( mediaSource.moveMediaSource(
/* currentIndex= */ 0, /* currentIndex= */ 0,
/* newIndex= */ 1, /* newIndex= */ 1,
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
callbackCalledCondition::countDown); callbackCalledCondition::countDown);
mediaSource.releaseSource(caller); mediaSource.releaseSource(caller);
}); });
...@@ -907,7 +903,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -907,7 +903,7 @@ public final class ConcatenatingMediaSourceTest {
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( dummyMainThread.runOnMainThread(
() -> mediaSource.clear(Util.createHandlerForCurrentOrMainLooper(), timelineGrabber)); () -> mediaSource.clear(Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.isEmpty()).isTrue(); assertThat(timeline.isEmpty()).isTrue();
...@@ -1059,7 +1055,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -1059,7 +1055,7 @@ public final class ConcatenatingMediaSourceTest {
() -> () ->
mediaSource.setShuffleOrder( mediaSource.setShuffleOrder(
new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 0), new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 0),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); dummyMainThread.release();
...@@ -1079,7 +1075,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -1079,7 +1075,7 @@ public final class ConcatenatingMediaSourceTest {
() -> () ->
mediaSource.setShuffleOrder( mediaSource.setShuffleOrder(
new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 3), new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 3),
Util.createHandlerForCurrentOrMainLooper(), Util.createHandlerForCurrentLooper(),
timelineGrabber)); timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(0); assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(0);
......
...@@ -680,7 +680,7 @@ public final class DashMediaSource extends BaseMediaSource { ...@@ -680,7 +680,7 @@ public final class DashMediaSource extends BaseMediaSource {
} else { } else {
dataSource = manifestDataSourceFactory.createDataSource(); dataSource = manifestDataSourceFactory.createDataSource();
loader = new Loader("Loader:DashMediaSource"); loader = new Loader("Loader:DashMediaSource");
handler = Util.createHandlerForCurrentOrMainLooper(); handler = Util.createHandlerForCurrentLooper();
startLoadingManifest(); startLoadingManifest();
} }
} }
......
...@@ -105,7 +105,7 @@ public final class PlayerEmsgHandler implements Handler.Callback { ...@@ -105,7 +105,7 @@ public final class PlayerEmsgHandler implements Handler.Callback {
this.allocator = allocator; this.allocator = allocator;
manifestPublishTimeToExpiryTimeUs = new TreeMap<>(); manifestPublishTimeToExpiryTimeUs = new TreeMap<>();
handler = Util.createHandlerForCurrentOrMainLooper(/* callback= */ this); handler = Util.createHandlerForCurrentLooper(/* callback= */ this);
decoder = new EventMessageDecoder(); decoder = new EventMessageDecoder();
lastLoadedChunkEndTimeUs = C.TIME_UNSET; lastLoadedChunkEndTimeUs = C.TIME_UNSET;
lastLoadedChunkEndTimeBeforeRefreshUs = C.TIME_UNSET; lastLoadedChunkEndTimeBeforeRefreshUs = C.TIME_UNSET;
......
...@@ -227,7 +227,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -227,7 +227,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@SuppressWarnings("nullness:methodref.receiver.bound.invalid") @SuppressWarnings("nullness:methodref.receiver.bound.invalid")
Runnable onTracksEndedRunnable = this::onTracksEnded; Runnable onTracksEndedRunnable = this::onTracksEnded;
this.onTracksEndedRunnable = onTracksEndedRunnable; this.onTracksEndedRunnable = onTracksEndedRunnable;
handler = Util.createHandlerForCurrentOrMainLooper(); handler = Util.createHandlerForCurrentLooper();
lastSeekPositionUs = positionUs; lastSeekPositionUs = positionUs;
pendingResetPositionUs = positionUs; pendingResetPositionUs = positionUs;
} }
......
...@@ -121,7 +121,7 @@ public final class DefaultHlsPlaylistTracker ...@@ -121,7 +121,7 @@ public final class DefaultHlsPlaylistTracker
Uri initialPlaylistUri, Uri initialPlaylistUri,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
PrimaryPlaylistListener primaryPlaylistListener) { PrimaryPlaylistListener primaryPlaylistListener) {
this.playlistRefreshHandler = Util.createHandlerForCurrentOrMainLooper(); this.playlistRefreshHandler = Util.createHandlerForCurrentLooper();
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.primaryPlaylistListener = primaryPlaylistListener; this.primaryPlaylistListener = primaryPlaylistListener;
ParsingLoadable<HlsPlaylist> masterPlaylistLoadable = ParsingLoadable<HlsPlaylist> masterPlaylistLoadable =
......
...@@ -620,7 +620,7 @@ public final class SsMediaSource extends BaseMediaSource ...@@ -620,7 +620,7 @@ public final class SsMediaSource extends BaseMediaSource
manifestDataSource = manifestDataSourceFactory.createDataSource(); manifestDataSource = manifestDataSourceFactory.createDataSource();
manifestLoader = new Loader("Loader:Manifest"); manifestLoader = new Loader("Loader:Manifest");
manifestLoaderErrorThrower = manifestLoader; manifestLoaderErrorThrower = manifestLoader;
manifestRefreshHandler = Util.createHandlerForCurrentOrMainLooper(); manifestRefreshHandler = Util.createHandlerForCurrentLooper();
startLoadingManifest(); startLoadingManifest();
} }
} }
......
...@@ -162,7 +162,7 @@ public class FakeMediaPeriod implements MediaPeriod { ...@@ -162,7 +162,7 @@ public class FakeMediaPeriod implements MediaPeriod {
/* mediaEndTimeUs = */ C.TIME_UNSET); /* mediaEndTimeUs = */ C.TIME_UNSET);
prepareCallback = callback; prepareCallback = callback;
if (deferOnPrepared) { if (deferOnPrepared) {
playerHandler = Util.createHandlerForCurrentOrMainLooper(); playerHandler = Util.createHandlerForCurrentLooper();
} else { } else {
finishPreparation(); finishPreparation();
} }
......
...@@ -176,7 +176,7 @@ public class FakeMediaSource extends BaseMediaSource { ...@@ -176,7 +176,7 @@ public class FakeMediaSource extends BaseMediaSource {
drmSessionManager.prepare(); drmSessionManager.prepare();
preparedSource = true; preparedSource = true;
releasedSource = false; releasedSource = false;
sourceInfoRefreshHandler = Util.createHandlerForCurrentOrMainLooper(); sourceInfoRefreshHandler = Util.createHandlerForCurrentLooper();
if (timeline != null) { if (timeline != null) {
finishSourcePreparation(/* sendManifestLoadEvents= */ true); finishSourcePreparation(/* sendManifestLoadEvents= */ true);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment