Commit a2ce75d8 by krocard Committed by Oliver Woodman

AudioSink buffers should be in LITTLE_ENDIAN

Some part of the audio pipeline in the DefaultAudioSink
(PCM processors) are expecting little endian buffers.

As a result, in order to behave like MediaCodec,
make sure the passthrough MediaCodec-bypass pipeline
also processes little endian output buffers.

PiperOrigin-RevId: 310172464
parent 040a88f4
...@@ -57,6 +57,7 @@ import java.lang.annotation.Retention; ...@@ -57,6 +57,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -2169,6 +2170,10 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -2169,6 +2170,10 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return false; // The buffer could not be filled, there is nothing more to do. return false; // The buffer could not be filled, there is nothing more to do.
} }
batchBuffer.flip(); // Buffer at least partially full, it can now be processed. batchBuffer.flip(); // Buffer at least partially full, it can now be processed.
// MediaCodec outputs buffers in native endian:
// https://developer.android.com/reference/android/media/MediaCodec#raw-audio-buffers
// and code called from processOutputBuffer expects this endianness.
batchBuffer.data.order(ByteOrder.nativeOrder());
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment