Disable offload scheduling at set up for track transition

While sleeping for offload, position is estimated based on time playing. If asleep and AudioTrack is reused, then the position will keep incrementing as the subsequent item plays. That is until wakeup when playing position is updated to the timestamp of the second item. Offload scheduling should be disabled until track transitions fully.

PiperOrigin-RevId: 570397140
This commit is contained in:
michaelkatz 2023-10-03 08:34:34 -07:00 committed by Copybara-Service
parent bd5a3920b8
commit da06bf057a

View file

@ -2251,6 +2251,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
readingPeriodHolder.getStartPositionRendererTime(),
readingPeriodHolder.getRendererOffset(),
readingPeriodHolder.info.id);
if (offloadSchedulingEnabled) {
// Prevent sleeping across offload track transition else position won't get updated.
// TODO: (b/183635183) Optimize Offload End-Of-Stream: Sleep to just before end of track
setOffloadSchedulingEnabled(false);
}
} else if (renderer.isEnded()) {
// The renderer has finished playback, so we can disable it now.
disableRenderer(renderer);