Skip to content

Commit

Permalink
Fix relevant tests to use time.monotonic() instead of time.time()
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx committed Aug 29, 2023
1 parent 0dff066 commit 1541a10
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test_contrib_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async def test_audio_slow_consumer(self):

# skip some frames
timestamp = 5 * samples_per_frame
await asyncio.sleep(source._start + (timestamp / 8000) - time.time())
await asyncio.sleep(source._start + (timestamp / 8000) - time.monotonic())

frame1, frame2 = await asyncio.gather(proxy1.recv(), proxy2.recv())
self.assertEqual(frame1.format.name, "s16")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mediastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class VideoPacketStreamTrack(MediaStreamTrack):
async def next_timestamp(self) -> Tuple[int, fractions.Fraction]:
if hasattr(self, "_timestamp"):
self._timestamp += int(VIDEO_PTIME * VIDEO_CLOCK_RATE)
wait = self._start + (self._timestamp / VIDEO_CLOCK_RATE) - time.time()
wait = self._start + (self._timestamp / VIDEO_CLOCK_RATE) - time.monotonic()
await asyncio.sleep(wait)
else:
self._start = time.time()
self._start = time.monotonic()
self._timestamp = 0
return self._timestamp, VIDEO_TIME_BASE

Expand Down

0 comments on commit 1541a10

Please sign in to comment.