Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f83b317 authored by Iris Chang's avatar Iris Chang Committed by Marco Nelissen
Browse files

Fix a noise issue caused by random value of byteOrder

The value of byteOrder is a random value. If the random
value is 1 and it does not judge whether it gets a big-endian
key successfully at the same time, the pcm buffer will be
transferred to little-endian, which is not correct and causes
noise.

To fix this problem, we initialize the byteOrder as 0 and
judge if it gets a big-endian key

Bug: 137221067
Test: play a mp4 file with pcm audio and check if we can play
it normally
Change-Id: I709db10ce967909949c13f749869f76b1c6a80bb
parent 85bf8a17
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -5820,11 +5820,11 @@ media_status_t MPEG4Source::read(
                      meta, AMEDIAFORMAT_KEY_TIME_US, ((long double)cts * 1000000) / mTimescale);
                AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_IS_SYNC_FRAME, 1);

                int32_t byteOrder;
                AMediaFormat_getInt32(mFormat,
                int32_t byteOrder = 0;
                bool isGetBigEndian = AMediaFormat_getInt32(mFormat,
                        AMEDIAFORMAT_KEY_PCM_BIG_ENDIAN, &byteOrder);

                if (byteOrder == 1) {
                if (isGetBigEndian && byteOrder == 1) {
                    // Big-endian -> little-endian
                    uint16_t *dstData = (uint16_t *)buf;
                    uint16_t *srcData = (uint16_t *)buf;