mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
Fix SpeedChangingAudioProcessor handling of EMPTY_BUFFER.
PiperOrigin-RevId: 490265564
This commit is contained in:
parent
9d84666c8f
commit
af1d7b9b1b
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package androidx.media3.common.audio;
|
||||
|
||||
import static androidx.media3.common.audio.AudioProcessor.EMPTY_BUFFER;
|
||||
import static androidx.media3.common.util.Assertions.checkState;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -23,7 +24,6 @@ import androidx.media3.common.util.UnstableApi;
|
||||
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;
|
||||
|
||||
@ -69,10 +69,6 @@ import java.util.List;
|
||||
@UnstableApi
|
||||
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;
|
||||
/**
|
||||
@ -323,13 +319,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