diff --git a/extensions/gvr/src/main/java/com/google/android/exoplayer2/ext/gvr/GvrAudioProcessor.java b/extensions/gvr/src/main/java/com/google/android/exoplayer2/ext/gvr/GvrAudioProcessor.java index 2117985da0..980424904d 100644 --- a/extensions/gvr/src/main/java/com/google/android/exoplayer2/ext/gvr/GvrAudioProcessor.java +++ b/extensions/gvr/src/main/java/com/google/android/exoplayer2/ext/gvr/GvrAudioProcessor.java @@ -152,14 +152,19 @@ public final class GvrAudioProcessor implements AudioProcessor { @Override public void flush() { - gvrAudioSurround.flush(); + if (gvrAudioSurround != null) { + gvrAudioSurround.flush(); + } inputEnded = false; } @Override - public synchronized void release() { - buffer = null; + public synchronized void reset() { maybeReleaseGvrAudioSurround(); + inputEnded = false; + buffer = null; + sampleRateHz = Format.NO_VALUE; + channelCount = Format.NO_VALUE; } private void maybeReleaseGvrAudioSurround() { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java index 2e0d1f98d9..eced040812 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java @@ -116,8 +116,8 @@ public interface AudioProcessor { void flush(); /** - * Releases any resources associated with this instance. + * Resets the processor to its initial state. */ - void release(); + void reset(); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrack.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrack.java index b3700695e5..44a96373f3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrack.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrack.java @@ -1187,7 +1187,7 @@ public final class AudioTrack { reset(); releaseKeepSessionIdAudioTrack(); for (AudioProcessor audioProcessor : availableAudioProcessors) { - audioProcessor.release(); + audioProcessor.reset(); } audioSessionId = C.AUDIO_SESSION_ID_UNSET; playing = false; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java index e81d7e218a..b755776f1e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java @@ -17,6 +17,7 @@ package com.google.android.exoplayer2.audio; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C.Encoding; +import com.google.android.exoplayer2.Format; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Arrays; @@ -43,6 +44,8 @@ import java.util.Arrays; public ChannelMappingAudioProcessor() { buffer = EMPTY_BUFFER; outputBuffer = EMPTY_BUFFER; + channelCount = Format.NO_VALUE; + sampleRateHz = Format.NO_VALUE; } /** @@ -147,9 +150,13 @@ import java.util.Arrays; } @Override - public void release() { + public void reset() { flush(); buffer = EMPTY_BUFFER; + channelCount = Format.NO_VALUE; + sampleRateHz = Format.NO_VALUE; + outputChannels = null; + active = false; } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java index 752f55a0ca..0dd062150d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java @@ -168,9 +168,12 @@ import java.nio.ByteOrder; } @Override - public void release() { + public void reset() { flush(); buffer = EMPTY_BUFFER; + sampleRateHz = Format.NO_VALUE; + channelCount = Format.NO_VALUE; + encoding = C.ENCODING_INVALID; } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java index ba18ebd65a..4fffdf2deb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java @@ -58,9 +58,8 @@ import java.nio.ShortBuffer; private float speed; private float pitch; - private ShortBuffer shortBuffer; - private ByteBuffer buffer; + private ShortBuffer shortBuffer; private ByteBuffer outputBuffer; private long inputBytes; private long outputBytes; @@ -199,13 +198,16 @@ import java.nio.ShortBuffer; } @Override - public void release() { + public void reset() { sonic = null; - channelCount = Format.NO_VALUE; - sampleRateHz = Format.NO_VALUE; buffer = EMPTY_BUFFER; shortBuffer = buffer.asShortBuffer(); outputBuffer = EMPTY_BUFFER; + channelCount = Format.NO_VALUE; + sampleRateHz = Format.NO_VALUE; + inputBytes = 0; + outputBytes = 0; + inputEnded = false; } }