Rabbit-R1/android (non root)/java/sources/androidx/media3/common/audio/BaseAudioProcessor.java
2024-05-21 17:08:36 -04:00

96 lines
3.6 KiB
Java

package androidx.media3.common.audio;
import androidx.media3.common.audio.AudioProcessor;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/* loaded from: classes2.dex */
public abstract class BaseAudioProcessor implements AudioProcessor {
private boolean inputEnded;
private ByteBuffer buffer = EMPTY_BUFFER;
private ByteBuffer outputBuffer = EMPTY_BUFFER;
private AudioProcessor.AudioFormat pendingInputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
private AudioProcessor.AudioFormat pendingOutputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
protected AudioProcessor.AudioFormat inputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
protected AudioProcessor.AudioFormat outputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
protected void onFlush() {
}
protected void onQueueEndOfStream() {
}
protected void onReset() {
}
@Override // androidx.media3.common.audio.AudioProcessor
public final AudioProcessor.AudioFormat configure(AudioProcessor.AudioFormat audioFormat) throws AudioProcessor.UnhandledAudioFormatException {
this.pendingInputAudioFormat = audioFormat;
this.pendingOutputAudioFormat = onConfigure(audioFormat);
return isActive() ? this.pendingOutputAudioFormat : AudioProcessor.AudioFormat.NOT_SET;
}
@Override // androidx.media3.common.audio.AudioProcessor
public boolean isActive() {
return this.pendingOutputAudioFormat != AudioProcessor.AudioFormat.NOT_SET;
}
@Override // androidx.media3.common.audio.AudioProcessor
public final void queueEndOfStream() {
this.inputEnded = true;
onQueueEndOfStream();
}
@Override // androidx.media3.common.audio.AudioProcessor
public ByteBuffer getOutput() {
ByteBuffer byteBuffer = this.outputBuffer;
this.outputBuffer = EMPTY_BUFFER;
return byteBuffer;
}
@Override // androidx.media3.common.audio.AudioProcessor
public boolean isEnded() {
return this.inputEnded && this.outputBuffer == EMPTY_BUFFER;
}
@Override // androidx.media3.common.audio.AudioProcessor
public final void flush() {
this.outputBuffer = EMPTY_BUFFER;
this.inputEnded = false;
this.inputAudioFormat = this.pendingInputAudioFormat;
this.outputAudioFormat = this.pendingOutputAudioFormat;
onFlush();
}
@Override // androidx.media3.common.audio.AudioProcessor
public final void reset() {
flush();
this.buffer = EMPTY_BUFFER;
this.pendingInputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
this.pendingOutputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
this.inputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
this.outputAudioFormat = AudioProcessor.AudioFormat.NOT_SET;
onReset();
}
/* JADX INFO: Access modifiers changed from: protected */
public final ByteBuffer replaceOutputBuffer(int i) {
if (this.buffer.capacity() < i) {
this.buffer = ByteBuffer.allocateDirect(i).order(ByteOrder.nativeOrder());
} else {
this.buffer.clear();
}
ByteBuffer byteBuffer = this.buffer;
this.outputBuffer = byteBuffer;
return byteBuffer;
}
/* JADX INFO: Access modifiers changed from: protected */
public final boolean hasPendingOutput() {
return this.outputBuffer.hasRemaining();
}
protected AudioProcessor.AudioFormat onConfigure(AudioProcessor.AudioFormat audioFormat) throws AudioProcessor.UnhandledAudioFormatException {
return AudioProcessor.AudioFormat.NOT_SET;
}
}