mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Prevent wrapping detection on new passthrough AudioTracks.
This commit is contained in:
parent
de5bce3400
commit
a1083d360a
1 changed files with 9 additions and 3 deletions
|
|
@ -790,9 +790,15 @@ public final class AudioTrack {
|
||||||
public long getPlaybackHeadPosition() {
|
public long getPlaybackHeadPosition() {
|
||||||
long rawPlaybackHeadPosition = 0xFFFFFFFFL & audioTrack.getPlaybackHeadPosition();
|
long rawPlaybackHeadPosition = 0xFFFFFFFFL & audioTrack.getPlaybackHeadPosition();
|
||||||
if (Util.SDK_INT <= 22 && isPassthrough) {
|
if (Util.SDK_INT <= 22 && isPassthrough) {
|
||||||
// Work around an issue on platform API versions 21/22 where the playback head position
|
// Work around issues with passthrough/direct AudioTracks on platform API versions 21/22:
|
||||||
// jumps back to zero on paused passthrough/direct audio tracks. See [Internal: b/19187573].
|
// - After resetting, the new AudioTrack's playback position continues to increase for a
|
||||||
if (audioTrack.getPlayState() == android.media.AudioTrack.PLAYSTATE_PAUSED
|
// short time from the old AudioTrack's position, while in the PLAYSTATE_STOPPED state.
|
||||||
|
// - The playback head position jumps back to zero on paused passthrough/direct audio
|
||||||
|
// tracks. See [Internal: b/19187573].
|
||||||
|
if (audioTrack.getPlayState() == android.media.AudioTrack.PLAYSTATE_STOPPED) {
|
||||||
|
// Prevent detecting a wrapped position.
|
||||||
|
lastRawPlaybackHeadPosition = rawPlaybackHeadPosition;
|
||||||
|
} else if (audioTrack.getPlayState() == android.media.AudioTrack.PLAYSTATE_PAUSED
|
||||||
&& rawPlaybackHeadPosition == 0) {
|
&& rawPlaybackHeadPosition == 0) {
|
||||||
passthroughWorkaroundPauseOffset = lastRawPlaybackHeadPosition;
|
passthroughWorkaroundPauseOffset = lastRawPlaybackHeadPosition;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue