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

Commit 0cde076d authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Cleanup createTrack error handling

Similar to cleanup done earlier for openRecord in this CL:
    > Change-Id: I84897dd7d30b370640b54e928f230604b873cb68

Bug: 10888816
Change-Id: I804a47f898e0319a60a9bd58906bbb037e45cc25
parent a238b9b4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1004,6 +1004,11 @@ status_t AudioTrack::createTrack_l(
        ALOGE("Could not get control block");
        return NO_INIT;
    }
    void *iMemPointer = iMem->pointer();
    if (iMemPointer == NULL) {
        ALOGE("Could not get control block pointer");
        return NO_INIT;
    }
    // invariant that mAudioTrack != 0 is true only after set() returns successfully
    if (mAudioTrack != 0) {
        mAudioTrack->asBinder()->unlinkToDeath(mDeathNotifier, this);
@@ -1011,7 +1016,7 @@ status_t AudioTrack::createTrack_l(
    }
    mAudioTrack = track;
    mCblkMemory = iMem;
    audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMem->pointer());
    audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMemPointer);
    mCblk = cblk;
    size_t temp = cblk->frameCount_;
    if (temp < frameCount || (frameCount == 0 && temp == 0)) {
+12 −0
Original line number Diff line number Diff line
@@ -138,6 +138,17 @@ public:
            name = reply.readString8();
            lStatus = reply.readInt32();
            track = interface_cast<IAudioTrack>(reply.readStrongBinder());
            if (lStatus == NO_ERROR) {
                if (track == 0) {
                    ALOGE("createTrack should have returned an IAudioTrack");
                    lStatus = UNKNOWN_ERROR;
                }
            } else {
                if (track != 0) {
                    ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus);
                    track.clear();
                }
            }
        }
        if (status != NULL) {
            *status = lStatus;
@@ -795,6 +806,7 @@ status_t BnAudioFlinger::onTransact(
                        (audio_stream_type_t) streamType, sampleRate, format,
                        channelMask, frameCount, &flags, buffer, output, tid,
                        &sessionId, name, clientUid, &status);
                LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR));
            }
            reply->writeInt32(flags);
            reply->writeInt32(sessionId);
+1 −0
Original line number Diff line number Diff line
@@ -559,6 +559,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(

        track = thread->createTrack_l(client, streamType, sampleRate, format,
                channelMask, frameCount, sharedBuffer, lSessionId, flags, tid, clientUid, &lStatus);
        LOG_ALWAYS_FATAL_IF((track != 0) != (lStatus == NO_ERROR));
        // we don't abort yet if lStatus != NO_ERROR; there is still work to be done regardless

        // move effect chain to this output thread if an effect on same session was waiting
+1 −0
Original line number Diff line number Diff line
@@ -1339,6 +1339,7 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
        // but TimedTrack::create() is a factory that could fail by returning NULL
        lStatus = track != 0 ? track->initCheck() : (status_t) NO_MEMORY;
        if (lStatus != NO_ERROR) {
            ALOGE("createTrack_l() initCheck failed %d; no control block?", lStatus);
            track.clear();
            goto Exit;
        }