mirror of
https://github.com/androidx/media.git
synced 2025-05-04 22:20:47 +08:00
Fix SpeedChangingAudioProcessor handling of EMPTY_BUFFER.
PiperOrigin-RevId: 490265564
This commit is contained in:
parent
309f24adcd
commit
c1e292374d
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.audio;
|
||||
|
||||
import static com.google.android.exoplayer2.audio.AudioProcessor.EMPTY_BUFFER;
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkState;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -22,7 +23,6 @@ import com.google.android.exoplayer2.audio.AudioProcessor.AudioFormat;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -67,10 +67,6 @@ import java.util.List;
|
||||
*/
|
||||
public final class AudioProcessingPipeline {
|
||||
|
||||
/** An empty, direct {@link ByteBuffer}. */
|
||||
private static final ByteBuffer EMPTY_BUFFER =
|
||||
ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());
|
||||
|
||||
/** The {@link AudioProcessor} instances passed to {@link AudioProcessingPipeline}. */
|
||||
private final ImmutableList<AudioProcessor> audioProcessors;
|
||||
/**
|
||||
@ -321,13 +317,6 @@ public final class AudioProcessingPipeline {
|
||||
index > 0
|
||||
? outputBuffers[index - 1]
|
||||
: inputBuffer.hasRemaining() ? inputBuffer : EMPTY_BUFFER;
|
||||
if (input == AudioProcessor.EMPTY_BUFFER) {
|
||||
// TODO(internal b/198772621): compare to how it was done in DefaultAudioSink to make sure
|
||||
// this is not unnecessarily complicated.
|
||||
// Queueing AudioProcessor.EMPTY_BUFFER to an AudioProcessor might lead to unexpected
|
||||
// behaviour (see [Internal: b/259393434]).
|
||||
input = EMPTY_BUFFER;
|
||||
}
|
||||
long inputBytes = input.remaining();
|
||||
audioProcessor.queueInput(input);
|
||||
outputBuffers[index] = audioProcessor.getOutput();
|
||||
|
@ -108,7 +108,9 @@ import java.nio.ByteBuffer;
|
||||
}
|
||||
} else {
|
||||
ByteBuffer buffer = replaceOutputBuffer(/* size= */ inputBuffer.remaining());
|
||||
buffer.put(inputBuffer);
|
||||
if (inputBuffer.hasRemaining()) {
|
||||
buffer.put(inputBuffer);
|
||||
}
|
||||
buffer.flip();
|
||||
}
|
||||
bytesRead += inputBuffer.position() - startPosition;
|
||||
|
Loading…
x
Reference in New Issue
Block a user