Allow pause if in offload mode after writing all buffers

In offload mode, `AudioTrack#stop()` will put the track in `PLAYSTATE_STOPPING` rather than `PLAYSTATE_STOPPED`. The difference in state means that `AudioTrack` can be paused and played during this 'stopping' period.

Currently, if `AudioTrackPositionTracker#handleEndOfStream()` has been called then `DefaultAudioSink` in `pause()` won't call `AudioTrack#pause()`. `AudioTrack#pause()` should be called in this case if in offload mode.

#minor-release

PiperOrigin-RevId: 571335108
(cherry picked from commit ab42d64d6d5f1859f1c45aebfe26060978b864bd)
This commit is contained in:
michaelkatz 2023-10-06 07:43:11 -07:00 committed by oceanjules
parent da5a743175
commit 5d0d30a280

View File

@ -1407,7 +1407,8 @@ public final class DefaultAudioSink implements AudioSink {
@Override
public void pause() {
playing = false;
if (isAudioTrackInitialized() && audioTrackPositionTracker.pause()) {
if (isAudioTrackInitialized()
&& (audioTrackPositionTracker.pause() || isOffloadedPlayback(audioTrack))) {
audioTrack.pause();
}
}