Commit 4b5c521a by andrewlewis Committed by Oliver Woodman

Use native byte order for SimpleOutputBuffers

The default byte order for ByteBuffers is big endian, but platform decoder
output buffers use native byte order. AudioProcessors handle native byte order
input/output.

When using a software audio decoding extension the Sonic audio processor would
receive big endian input but was outputting to a native byte order buffer,
which could be little endian. This mismatch caused audio output to be
distorted.

After this change both platform decoder and extension decoder output buffers
should be in native byte order.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155320973
parent 7f667259
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.decoder; package com.google.android.exoplayer2.decoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/** /**
* Buffer for {@link SimpleDecoder} output. * Buffer for {@link SimpleDecoder} output.
...@@ -40,7 +41,7 @@ public class SimpleOutputBuffer extends OutputBuffer { ...@@ -40,7 +41,7 @@ public class SimpleOutputBuffer extends OutputBuffer {
public ByteBuffer init(long timeUs, int size) { public ByteBuffer init(long timeUs, int size) {
this.timeUs = timeUs; this.timeUs = timeUs;
if (data == null || data.capacity() < size) { if (data == null || data.capacity() < size) {
data = ByteBuffer.allocateDirect(size); data = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
} }
data.position(0); data.position(0);
data.limit(size); data.limit(size);
......
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