Reset tracker for offload track completion prior to stopping AudioTrack

For offloaded playback, reset the tracking field for stream completion in `DefaultAudioSink` prior to calling `AudioTrack.stop()` so that `AudioTrack.StreamEventCallback#onPresentationEnded` correctly identifies when all pending data has been played.

#minor-release

PiperOrigin-RevId: 631744805
This commit is contained in:
michaelkatz 2024-05-08 03:59:41 -07:00 committed by Copybara-Service
parent 9adb532b6c
commit ab64ca809a
2 changed files with 9 additions and 0 deletions

View File

@ -35,6 +35,10 @@
* Audio:
* Fix DTS:X Profile 2 encoding attributes for passthrough playback
([#1299](https://github.com/androidx/media/pull/1299)).
* For offloaded playback, reset the tracking field for stream completion
in `DefaultAudioSink` prior to calling `AudioTrack.stop()` so that
`AudioTrack.StreamEventCallback#onPresentationEnded` correctly
identifies when all pending data has been played.
* Video:
* Text:
* Fix issue where subtitles starting before a seek position are skipped.

View File

@ -1869,6 +1869,11 @@ public final class DefaultAudioSink implements AudioSink {
if (!stoppedAudioTrack) {
stoppedAudioTrack = true;
audioTrackPositionTracker.handleEndOfStream(getWrittenFrames());
if (isOffloadedPlayback(audioTrack)) {
// Reset handledOffloadOnPresentationEnded to track completion after
// this following stop call.
handledOffloadOnPresentationEnded = false;
}
audioTrack.stop();
bytesUntilNextAvSync = 0;
}