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

Commit 72b2b9ba authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Tolerate 0 valid bits value in WAV_EXT

Some WAV_EXT writers don't properly set the "valid bits per sample"
 value and set it to 0. Don't return an error when such a header
 is parsed.

Change-Id: I21763087af4f3fc8c62a24b883aae53b23ae71d4
parent 83faee05
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -227,9 +227,15 @@ status_t WAVExtractor::init() {
            if (mWaveFormat == WAVE_FORMAT_EXTENSIBLE) {
                uint16_t validBitsPerSample = U16_LE_AT(&formatSpec[18]);
                if (validBitsPerSample != mBitsPerSample) {
                    if ((validBitsPerSample != 0) {
                        ALOGE("validBits(%d) != bitsPerSample(%d) are not supported",
                                validBitsPerSample, mBitsPerSample);
                        return ERROR_UNSUPPORTED;
                    } else {
                        // we only support valitBitsPerSample == bitsPerSample but some WAV_EXT
                        // writers don't correctly set the valid bits value, and leave it at 0.
                        ALOGW("WAVE_EXT has 0 valid bits per sample, ignoring");
                    }
                }

                mChannelMask = U32_LE_AT(&formatSpec[20]);