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

Commit 5cd258a9 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "ToneGenerator: Increase buffer framecount" into nyc-mr1-dev

parents e14cd31c 7711c90d
Loading
Loading
Loading
Loading
+23 −33
Original line number Diff line number Diff line
@@ -1063,16 +1063,17 @@ void ToneGenerator::stopTone() {
//
////////////////////////////////////////////////////////////////////////////////
bool ToneGenerator::initAudioTrack() {

    // Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
    // Open audio track in mono, PCM 16bit, default sampling rate.
    mpAudioTrack = new AudioTrack();
    ALOGV("Create Track: %p", mpAudioTrack.get());
    ALOGV("AudioTrack(%p) created", mpAudioTrack.get());

    mpAudioTrack->set(mStreamType,
    const size_t frameCount = mProcessSize;
    status_t status = mpAudioTrack->set(
            mStreamType,
            0,    // sampleRate
            AUDIO_FORMAT_PCM_16_BIT,
            AUDIO_CHANNEL_OUT_MONO,
                      0,    // frameCount
            frameCount,
            AUDIO_OUTPUT_FLAG_FAST,
            audioCallback,
            this, // user
@@ -1082,28 +1083,17 @@ bool ToneGenerator::initAudioTrack() {
            AUDIO_SESSION_ALLOCATE,
            AudioTrack::TRANSFER_CALLBACK);

    if (mpAudioTrack->initCheck() != NO_ERROR) {
        ALOGE("AudioTrack->initCheck failed");
        goto initAudioTrack_exit;
    if (status != NO_ERROR) {
        ALOGE("AudioTrack(%p) set failed with error %d", mpAudioTrack.get(), status);
        mpAudioTrack.clear();
        return false;
    }

    mpAudioTrack->setVolume(mVolume);

    mState = TONE_INIT;

    return true;

initAudioTrack_exit:

    ALOGV("Init failed: %p", mpAudioTrack.get());

    // Cleanup
    mpAudioTrack.clear();

    return false;
}


////////////////////////////////////////////////////////////////////////////////
//
//    Method:        ToneGenerator::audioCallback()