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

Commit 41d3f579 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Fix GSM WAV playback

Bug:19289381
Change-Id: If7bbf1ecf1cb8796188e61bc2c42f8a099510424
parent 35395ea6
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -3805,6 +3805,23 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
                    break;
                }

                case OMX_AUDIO_CodingGSMFR:
                {
                    OMX_AUDIO_PARAM_MP3TYPE params;
                    InitOMXParams(&params);
                    params.nPortIndex = portIndex;

                    CHECK_EQ(mOMX->getParameter(
                                mNode, OMX_IndexParamAudioPcm,
                                &params, sizeof(params)),
                             (status_t)OK);

                    notify->setString("mime", MEDIA_MIMETYPE_AUDIO_MSGSM);
                    notify->setInt32("channel-count", params.nChannels);
                    notify->setInt32("sample-rate", params.nSampleRate);
                    break;
                }

                default:
                    ALOGE("UNKNOWN AUDIO CODING: %d\n", audioDef->eEncoding);
                    TRESPASS();
+4 −4
Original line number Diff line number Diff line
@@ -439,10 +439,6 @@ status_t WAVSource::read(
        maxBytesToRead = maxBytesAvailable;
    }

    // read only integral amounts of audio unit frames.
    const size_t inputUnitFrameSize = mNumChannels * mBitsPerSample / 8;
    maxBytesToRead -= maxBytesToRead % inputUnitFrameSize;

    if (mWaveFormat == WAVE_FORMAT_MSGSM) {
        // Microsoft packs 2 frames into 65 bytes, rather than using separate 33-byte frames,
        // so read multiples of 65, and use smaller buffers to account for ~10:1 expansion ratio
@@ -450,6 +446,10 @@ status_t WAVSource::read(
            maxBytesToRead = 1024;
        }
        maxBytesToRead = (maxBytesToRead / 65) * 65;
    } else {
        // read only integral amounts of audio unit frames.
        const size_t inputUnitFrameSize = mNumChannels * mBitsPerSample / 8;
        maxBytesToRead -= maxBytesToRead % inputUnitFrameSize;
    }

    ssize_t n = mDataSource->readAt(