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
This commit is contained in:
andrewlewis 2017-05-07 08:18:25 -07:00 committed by Oliver Woodman
parent 65607b2736
commit 2d2fcf1510

View File

@ -16,6 +16,7 @@
package com.google.android.exoplayer2.decoder;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* Buffer for {@link SimpleDecoder} output.
@ -40,7 +41,7 @@ public class SimpleOutputBuffer extends OutputBuffer {
public ByteBuffer init(long timeUs, int size) {
this.timeUs = timeUs;
if (data == null || data.capacity() < size) {
data = ByteBuffer.allocateDirect(size);
data = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
}
data.position(0);
data.limit(size);