mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add missing check before calling discardBuffer
The method is only allowed to be called on prepared items. This check was currently missing and also causing the corresponding test to be flaky in ExoPlayerTest. PiperOrigin-RevId: 634694077
This commit is contained in:
parent
282a944eb4
commit
2b5bb945e1
@ -2585,15 +2585,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
playbackPositionUs,
|
||||
bufferedDurationUs,
|
||||
mediaClock.getPlaybackParameters().speed);
|
||||
MediaPeriodHolder playingPeriodHolder = queue.getPlayingPeriod();
|
||||
if (!shouldContinueLoading
|
||||
&& playingPeriodHolder.prepared
|
||||
&& bufferedDurationUs < PLAYBACK_BUFFER_EMPTY_THRESHOLD_US
|
||||
&& (backBufferDurationUs > 0 || retainBackBufferFromKeyframe)) {
|
||||
// LoadControl doesn't want to continue loading despite no buffered data. Clear back buffer
|
||||
// and try again in case it's blocked on memory usage of the back buffer.
|
||||
queue
|
||||
.getPlayingPeriod()
|
||||
.mediaPeriod
|
||||
.discardBuffer(playbackInfo.positionUs, /* toKeyframe= */ false);
|
||||
playingPeriodHolder.mediaPeriod.discardBuffer(
|
||||
playbackInfo.positionUs, /* toKeyframe= */ false);
|
||||
shouldContinueLoading =
|
||||
loadControl.shouldContinueLoading(
|
||||
playerId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user