mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Deduplicate reported position discontinuities
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142257743
This commit is contained in:
parent
e0586a48f0
commit
4bb8793203
3 changed files with 17 additions and 19 deletions
|
|
@ -84,7 +84,6 @@ public final class ExoPlayerTest extends TestCase {
|
||||||
private Format expectedFormat;
|
private Format expectedFormat;
|
||||||
private ExoPlayer player;
|
private ExoPlayer player;
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
private boolean seenPositionDiscontinuity;
|
|
||||||
|
|
||||||
public PlayerWrapper() {
|
public PlayerWrapper() {
|
||||||
endedCountDownLatch = new CountDownLatch(1);
|
endedCountDownLatch = new CountDownLatch(1);
|
||||||
|
|
@ -121,7 +120,7 @@ public final class ExoPlayerTest extends TestCase {
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(true);
|
||||||
player.prepare(new FakeMediaSource(timeline, manifest, format));
|
player.prepare(new FakeMediaSource(timeline, manifest, format));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handlePlayerException(e);
|
handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -136,7 +135,7 @@ public final class ExoPlayerTest extends TestCase {
|
||||||
player.release();
|
player.release();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handlePlayerException(e);
|
handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
playerThread.quit();
|
playerThread.quit();
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +144,7 @@ public final class ExoPlayerTest extends TestCase {
|
||||||
playerThread.join();
|
playerThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePlayerException(Exception exception) {
|
private void handleError(Exception exception) {
|
||||||
if (this.exception == null) {
|
if (this.exception == null) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
}
|
}
|
||||||
|
|
@ -180,20 +179,13 @@ public final class ExoPlayerTest extends TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerError(ExoPlaybackException exception) {
|
public void onPlayerError(ExoPlaybackException exception) {
|
||||||
this.exception = exception;
|
handleError(exception);
|
||||||
endedCountDownLatch.countDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPositionDiscontinuity() {
|
public void onPositionDiscontinuity() {
|
||||||
assertFalse(seenPositionDiscontinuity);
|
// Should never happen.
|
||||||
assertEquals(0, player.getCurrentWindowIndex());
|
handleError(new IllegalStateException("Received position discontinuity"));
|
||||||
assertEquals(0, player.getCurrentPeriodIndex());
|
|
||||||
assertEquals(0, player.getCurrentPosition());
|
|
||||||
assertEquals(0, player.getBufferedPosition());
|
|
||||||
assertEquals(expectedTimeline, player.getCurrentTimeline());
|
|
||||||
assertEquals(expectedManifest, player.getCurrentManifest());
|
|
||||||
seenPositionDiscontinuity = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -332,10 +332,12 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
case ExoPlayerImplInternal.MSG_SEEK_ACK: {
|
case ExoPlayerImplInternal.MSG_SEEK_ACK: {
|
||||||
if (--pendingSeekAcks == 0) {
|
if (--pendingSeekAcks == 0) {
|
||||||
playbackInfo = (ExoPlayerImplInternal.PlaybackInfo) msg.obj;
|
playbackInfo = (ExoPlayerImplInternal.PlaybackInfo) msg.obj;
|
||||||
|
if (msg.arg1 != 0) {
|
||||||
for (EventListener listener : listeners) {
|
for (EventListener listener : listeners) {
|
||||||
listener.onPositionDiscontinuity();
|
listener.onPositionDiscontinuity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ExoPlayerImplInternal.MSG_POSITION_DISCONTINUITY: {
|
case ExoPlayerImplInternal.MSG_POSITION_DISCONTINUITY: {
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ import java.io.IOException;
|
||||||
// The seek position was valid for the timeline that it was performed into, but the
|
// The seek position was valid for the timeline that it was performed into, but the
|
||||||
// timeline has changed and a suitable seek position could not be resolved in the new one.
|
// timeline has changed and a suitable seek position could not be resolved in the new one.
|
||||||
playbackInfo = new PlaybackInfo(0, 0);
|
playbackInfo = new PlaybackInfo(0, 0);
|
||||||
eventHandler.obtainMessage(MSG_SEEK_ACK, playbackInfo).sendToTarget();
|
eventHandler.obtainMessage(MSG_SEEK_ACK, 1, 0, playbackInfo).sendToTarget();
|
||||||
// Set the internal position to (0,TIME_UNSET) so that a subsequent seek to (0,0) isn't
|
// Set the internal position to (0,TIME_UNSET) so that a subsequent seek to (0,0) isn't
|
||||||
// ignored.
|
// ignored.
|
||||||
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
|
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
|
||||||
|
|
@ -569,6 +569,7 @@ import java.io.IOException;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean seekPositionAdjusted = seekPosition.windowPositionUs == C.TIME_UNSET;
|
||||||
int periodIndex = periodPosition.first;
|
int periodIndex = periodPosition.first;
|
||||||
long periodPositionUs = periodPosition.second;
|
long periodPositionUs = periodPosition.second;
|
||||||
|
|
||||||
|
|
@ -578,10 +579,13 @@ import java.io.IOException;
|
||||||
// Seek position equals the current position. Do nothing.
|
// Seek position equals the current position. Do nothing.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
periodPositionUs = seekToPeriodPosition(periodIndex, periodPositionUs);
|
long newPeriodPositionUs = seekToPeriodPosition(periodIndex, periodPositionUs);
|
||||||
|
seekPositionAdjusted |= periodPositionUs != newPeriodPositionUs;
|
||||||
|
periodPositionUs = newPeriodPositionUs;
|
||||||
} finally {
|
} finally {
|
||||||
playbackInfo = new PlaybackInfo(periodIndex, periodPositionUs);
|
playbackInfo = new PlaybackInfo(periodIndex, periodPositionUs);
|
||||||
eventHandler.obtainMessage(MSG_SEEK_ACK, playbackInfo).sendToTarget();
|
eventHandler.obtainMessage(MSG_SEEK_ACK, seekPositionAdjusted ? 1 : 0, 0, playbackInfo)
|
||||||
|
.sendToTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue