mirror of
https://github.com/androidx/media.git
synced 2025-05-15 19:49:50 +08:00
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
This commit is contained in:
parent
040a88f4f8
commit
a2ce75d836
@ -57,6 +57,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -2169,6 +2170,10 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
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.
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user