mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fully reset AudioProcessors on releasing AudioTrack
Issue: #2675 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=153445372
This commit is contained in:
parent
835839456f
commit
e87e2318d8
@ -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() {
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user