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

Commit 32768aff authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Steve Kondik
Browse files

ToneGenerator: Limit tones to 48k

DTMF tones are played at the hardware module sampling rate.
Until now, this rate was limited to 48k. Tones sound not too
pleasant at higher rates (like 96k and 192k). Ergo, limit the rate
to 48k.

Change-Id: I7fbc3185d988628ce3ee478076a322857221dece
parent 61c5a4df
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -820,6 +820,12 @@ ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool
        ALOGE("Unable to marshal AudioFlinger");
        return;
    }

    if (mSamplingRate > 48000) {
        ALOGW("mSamplingRate %d . limit to 48k", mSamplingRate);
        mSamplingRate = 48000;
    }

    mThreadCanCallJava = threadCanCallJava;
    mStreamType = streamType;
    mVolume = volume;
@@ -1071,7 +1077,7 @@ bool ToneGenerator::initAudioTrack() {
    ALOGV("Create Track: %p", mpAudioTrack.get());

    mpAudioTrack->set(mStreamType,
                      0,    // sampleRate
                      mSamplingRate,
                      AUDIO_FORMAT_PCM_16_BIT,
                      AUDIO_CHANNEL_OUT_MONO,
                      0,    // frameCount