mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00

While most ExoPlayer code parsing ByteBuffers is called with buffers in big endian, in certain situation, buffers in little endian are used too. MediaCodec produced ByteBuffers are in little endian, while buffers receive from the sources are in big endian (ByteBuffer's default). As a result, some code called from AudioSink in passthrough parsed bytebuffer in little endian. This is not correct because those format are specified in BigEndian. Changing the endianness of the ByteBuffer returned from MediaCodec would impact a lot more code that can currently be tested in the current COVID lockdown situation. As a result, this patch instead make the parsing code independent of the ByteBuffer.order() set. All the code that is called from DefaultAudioSink now parses the buffer explicitly in Big Endian. Additionally, the MPEG big endian header data of size 4 bytes was retrieved with ByteBuffer.get, which only returns one byte. PiperOrigin-RevId: 308116173