tonihei 38ac6ba711 Fix onAudioPositionAdvancing callback
The logic has always been broken for multiple different reasons:
 - It applied usToMs twice, essentially making all calculations
   for the actual start time meaningless.
 - It compared against the fist observed timestamp after calling
   AudioTrack.play(), which may already include some advanced
   position.
 - The callback was falsely triggered after speed changes (when
   AudioTrack playback params are used).
 - It used the potentially smoothed position from different sources
   instead of using the latest reliable source
 - It did not wait until the getTimestamp source is reliable
   before triggering this callback (instead always relying on the
   more error-prone getPlaybackHeadPosition).

As a result it has always reported the system time when we first
observed a timestamp that was different from a previous one.

We can make the callback more useful by fixing these points:
 - Wait until the getTimestamp source is reliably advancing or
   definitely can't be used (by which point we should also have a
   more reliable playbackHeadPosition value).
 - Calculate the start time using the latest position before
   applying any smoothing.
 - Save the "from" position in start() before AudioTrack.play()
   is called. This also avoid triggering the callback after speed
   changes.
 - Don't apply usToMs twice.

PiperOrigin-RevId: 755927465
2025-05-07 11:09:34 -07:00
..
2025-05-07 11:09:34 -07:00

Test utils module

Provides utility classes for media unit and instrumentation tests.