From 6b52104523e82e57935e395f94f90618222ff042 Mon Sep 17 00:00:00 2001 From: Alex Andres Date: Tue, 10 Nov 2026 08:29:31 +0100 Subject: [PATCH] test: read the position after a fast seek once a frame has gone out At the first frame the position is still the one asked for, or that of audio that went out before it, so the check depended on which came first. --- .../webrtc/media/player/MediaPlayerTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/webrtc-media/src/test/java/dev/onvoid/webrtc/media/player/MediaPlayerTest.java b/webrtc-media/src/test/java/dev/onvoid/webrtc/media/player/MediaPlayerTest.java index c0061db6..b5756c67 100644 --- a/webrtc-media/src/test/java/dev/onvoid/webrtc/media/player/MediaPlayerTest.java +++ b/webrtc-media/src/test/java/dev/onvoid/webrtc/media/player/MediaPlayerTest.java @@ -415,14 +415,10 @@ void fastSeekPlaysFromTheKeyframeBefore() throws Exception { assertTrue(playback.ended.await(15, TimeUnit.SECONDS), "no end of stream"); - // Audio going out alongside it can be a little ahead of the frame. - long first = playback.firstFramePositionUs.get(); - - assertTrue(first >= 1_000_000 && first < 1_040_000, "first frame at " + first + " us"); - // 1 s to 2.933 s, and the audio from the first packet the reader // lands on, a few milliseconds after 1 s, uncut: about half a - // second more of each than seek gives. + // second more of each than seek gives. Where the position goes is + // up to positionFollowsAFastSeekToItsKeyframe. assertTrue(Math.abs(playback.frames.get() - 30) <= 1, "video frames: " + playback.frames.get()); assertTrue(Math.abs(playback.chunks.get() - 198) <= 3, @@ -962,11 +958,16 @@ void positionFollowsAFastSeekToItsKeyframe() throws Exception { playback.player.fastSeek(1_500_000); playback.player.play(); - assertTrue(waitFor(() -> playback.frames.get() > 0, 10_000), "no video"); + assertTrue(waitFor(() -> playback.frames.get() > 1, 10_000), "no video"); - long first = playback.firstFramePositionUs.get(); + // At the first frame, the position is still the one asked for, or + // that of audio that went out before it, depending on which came + // first. At the second, the first frame has gone out: the position + // follows it and the audio alongside, a little ahead at most, and + // is well short of 1.5 s. + long second = playback.framePositionsUs.get(1); - assertTrue(first < 1_100_000, "first frame at " + first + " us"); + assertTrue(second >= 1_000_000 && second < 1_400_000, "second frame at " + second + " us"); } }