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

Commit 51634104 authored by cong.zhou's avatar cong.zhou
Browse files

Fix bug in WAVExtractor for 24-bit per sample wav

support stereo/multichannel 24-bit format
kMaxFrameSize is fixed to 32768. When converting 24-bit to 16-bit,
number of samlpes is maxBytesToRead /3.
In this case, if the maxBytesToRead is not multiple of 3,
pcm data is messed when converting.

Bug:7630939
Change-Id: I0ea1b53eb1272a8d83b63815fc0a05b73cef75f1
parent 5676e25a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -401,8 +401,10 @@ status_t WAVSource::read(
        return err;
    }

    // make sure that maxBytesToRead is multiple of 3, in 24-bit case
    size_t maxBytesToRead =
        mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize;
        mBitsPerSample == 8 ? kMaxFrameSize / 2 : 
        (mBitsPerSample == 24 ? 3*(kMaxFrameSize/3): kMaxFrameSize);

    size_t maxBytesAvailable =
        (mCurrentPos - mOffset >= (off64_t)mSize)
@@ -425,7 +427,7 @@ status_t WAVSource::read(

    buffer->set_range(0, n);

    if (mWaveFormat == WAVE_FORMAT_PCM) {
    if (mWaveFormat == WAVE_FORMAT_PCM || mWaveFormat == WAVE_FORMAT_EXTENSIBLE) {
        if (mBitsPerSample == 8) {
            // Convert 8-bit unsigned samples to 16-bit signed.