mirror of
https://github.com/samsonjs/media.git
synced 2026-03-31 10:25:48 +00:00
Post errors before calling stopInternal
When an error occurs we call stopInternal, and this clears the MediaPeriodQueue, which in turn releases media period holders and notifies that media periods have been released. AnalyticsCollector updates its information about media periods using the media period release events, which means that if we post the source error after stopInternal posts its events we can't determine what media period the source error corresponds to. Move error notifications before calling stopInternal, so that AnalyticsCollector's model of the media period queue contains the loading period at the point when it handles the error. For consistency also move the other (non-source) error notifications to match the new ordering. PiperOrigin-RevId: 238559324
This commit is contained in:
parent
d088be7acc
commit
f9055396b8
2 changed files with 7 additions and 7 deletions
|
|
@ -375,31 +375,31 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
maybeNotifyPlaybackInfoChanged();
|
||||
} catch (ExoPlaybackException e) {
|
||||
Log.e(TAG, "Playback error.", e);
|
||||
eventHandler.obtainMessage(MSG_ERROR, e).sendToTarget();
|
||||
stopInternal(
|
||||
/* forceResetRenderers= */ true,
|
||||
/* resetPositionAndState= */ false,
|
||||
/* acknowledgeStop= */ false);
|
||||
eventHandler.obtainMessage(MSG_ERROR, e).sendToTarget();
|
||||
maybeNotifyPlaybackInfoChanged();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Source error.", e);
|
||||
eventHandler.obtainMessage(MSG_ERROR, ExoPlaybackException.createForSource(e)).sendToTarget();
|
||||
stopInternal(
|
||||
/* forceResetRenderers= */ false,
|
||||
/* resetPositionAndState= */ false,
|
||||
/* acknowledgeStop= */ false);
|
||||
eventHandler.obtainMessage(MSG_ERROR, ExoPlaybackException.createForSource(e)).sendToTarget();
|
||||
maybeNotifyPlaybackInfoChanged();
|
||||
} catch (RuntimeException | OutOfMemoryError e) {
|
||||
Log.e(TAG, "Internal runtime error.", e);
|
||||
stopInternal(
|
||||
/* forceResetRenderers= */ true,
|
||||
/* resetPositionAndState= */ false,
|
||||
/* acknowledgeStop= */ false);
|
||||
ExoPlaybackException error =
|
||||
e instanceof OutOfMemoryError
|
||||
? ExoPlaybackException.createForOutOfMemoryError((OutOfMemoryError) e)
|
||||
: ExoPlaybackException.createForUnexpected((RuntimeException) e);
|
||||
eventHandler.obtainMessage(MSG_ERROR, error).sendToTarget();
|
||||
stopInternal(
|
||||
/* forceResetRenderers= */ true,
|
||||
/* resetPositionAndState= */ false,
|
||||
/* acknowledgeStop= */ false);
|
||||
maybeNotifyPlaybackInfoChanged();
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ public final class AnalyticsCollectorTest {
|
|||
.containsExactly(WINDOW_0 /* prepared */, WINDOW_0 /* prepared */);
|
||||
assertThat(listener.getEvents(EVENT_LOADING_CHANGED))
|
||||
.containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0);
|
||||
assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(WINDOW_0);
|
||||
assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(period0Seq0);
|
||||
assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0Seq0, period0Seq0);
|
||||
assertThat(listener.getEvents(EVENT_LOAD_STARTED))
|
||||
.containsExactly(
|
||||
|
|
|
|||
Loading…
Reference in a new issue