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

Commit 79629f07 authored by Andy Hung's avatar Andy Hung
Browse files

AudioTrack: Do not resume callback thread on start failure

Bug: 27673375
Change-Id: I1df1db51e75cee57f19824ac6506bf02000714fd
parent 5a898236
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -552,7 +552,20 @@ status_t AudioTrack::start()
    mNewPosition = mPosition + mUpdatePeriod;
    int32_t flags = android_atomic_and(~CBLK_DISABLED, &mCblk->mFlags);

    status_t status = NO_ERROR;
    if (!(flags & CBLK_INVALID)) {
        status = mAudioTrack->start();
        if (status == DEAD_OBJECT) {
            flags |= CBLK_INVALID;
        }
    }
    if (flags & CBLK_INVALID) {
        status = restoreTrack_l("start");
    }

    // resume or pause the callback thread as needed.
    sp<AudioTrackThread> t = mAudioTrackThread;
    if (status == NO_ERROR) {
        if (t != 0) {
            if (previousState == STATE_STOPPING) {
                mProxy->interrupt();
@@ -564,19 +577,7 @@ status_t AudioTrack::start()
            get_sched_policy(0, &mPreviousSchedulingGroup);
            androidSetThreadPriority(0, ANDROID_PRIORITY_AUDIO);
        }

    status_t status = NO_ERROR;
    if (!(flags & CBLK_INVALID)) {
        status = mAudioTrack->start();
        if (status == DEAD_OBJECT) {
            flags |= CBLK_INVALID;
        }
    }
    if (flags & CBLK_INVALID) {
        status = restoreTrack_l("start");
    }

    if (status != NO_ERROR) {
    } else {
        ALOGE("start() status %d", status);
        mState = previousState;
        if (t != 0) {