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

Commit 3e98ecd1 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Clear mAudioRecord and mAudioTrack on set() failure

Bug: 20818955
Bug: 20890069
Change-Id: I243205b99b198eb1b5a1a027b27cbb7d5aaaa8db
parent 4a95e694
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -85,12 +85,18 @@ int JetPlayer::init()

    // create the output AudioTrack
    mAudioTrack = new AudioTrack();
    mAudioTrack->set(AUDIO_STREAM_MUSIC,  //TODO parameterize this
    status_t status = mAudioTrack->set(AUDIO_STREAM_MUSIC,  //TODO parameterize this
            pLibConfig->sampleRate,
            AUDIO_FORMAT_PCM_16_BIT,
            audio_channel_out_mask_from_count(pLibConfig->numChannels),
            (size_t) mTrackBufferSize,
            AUDIO_OUTPUT_FLAG_NONE);
    if (status != OK) {
        ALOGE("JetPlayer::init(): Error initializing JET library; AudioTrack error %d", status);
        mAudioTrack.clear();
        mState = EAS_STATE_ERROR;
        return EAS_FAILURE;
    }

    // create render and playback thread
    {
+1 −0
Original line number Diff line number Diff line
@@ -1628,6 +1628,7 @@ status_t MediaPlayerService::AudioOutput::open(
        if ((t == 0) || (t->initCheck() != NO_ERROR)) {
            ALOGE("Unable to create audio track");
            delete newcbd;
            // t goes out of scope, so reference count drops to zero
            return NO_INIT;
        } else {
            // successful AudioTrack initialization implies a legacy stream type was generated
+3 −0
Original line number Diff line number Diff line
@@ -85,6 +85,9 @@ AudioSource::AudioSource(
                    this,
                    frameCount /*notificationFrames*/);
        mInitCheck = mRecord->initCheck();
        if (mInitCheck != OK) {
            mRecord.clear();
        }
    } else {
        mInitCheck = status;
    }