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

Commit fee4ce33 authored by Glenn Kasten's avatar Glenn Kasten Committed by Android (Google) Code Review
Browse files

Merge "Cleanup openRecord error handling" into klp-dev

parents ea0fadeb e93cf2ca
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,9 @@ public:
    };
    typedef uint32_t track_flags_t;

    // invariant on exit for all APIs that return an sp<>:
    //   (return value != 0) == (*status == NO_ERROR)

    /* create an audio track and registers it with AudioFlinger.
     * return null if the track cannot be created.
     */
+7 −2
Original line number Diff line number Diff line
@@ -474,7 +474,7 @@ status_t AudioRecord::openRecord_l(size_t epoch)
    ALOGE_IF(originalSessionId != 0 && mSessionId != originalSessionId,
            "session ID changed from %d to %d", originalSessionId, mSessionId);

    if (record == 0) {
    if (record == 0 || status != NO_ERROR) {
        ALOGE("AudioFlinger could not create record track, status: %d", status);
        AudioSystem::releaseInput(input);
        return status;
@@ -484,6 +484,11 @@ status_t AudioRecord::openRecord_l(size_t epoch)
        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;
    }
    if (mAudioRecord != 0) {
        mAudioRecord->asBinder()->unlinkToDeath(mDeathNotifier, this);
        mDeathNotifier.clear();
@@ -491,7 +496,7 @@ status_t AudioRecord::openRecord_l(size_t epoch)
    mInput = input;
    mAudioRecord = record;
    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;
    // FIXME missing fast track frameCount logic
    mAwaitBoost = false;
+12 −0
Original line number Diff line number Diff line
@@ -184,6 +184,17 @@ public:
            }
            lStatus = reply.readInt32();
            record = interface_cast<IAudioRecord>(reply.readStrongBinder());
            if (lStatus == NO_ERROR) {
                if (record == 0) {
                    ALOGE("openRecord should have returned an IAudioRecord");
                    lStatus = UNKNOWN_ERROR;
                }
            } else {
                if (record != 0) {
                    ALOGE("openRecord returned an IAudioRecord but with status %d", lStatus);
                    record.clear();
                }
            }
        }
        if (status) {
            *status = lStatus;
@@ -784,6 +795,7 @@ status_t BnAudioFlinger::onTransact(
            status_t status;
            sp<IAudioRecord> record = openRecord(input,
                    sampleRate, format, channelMask, frameCount, &flags, tid, &sessionId, &status);
            LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
            reply->writeInt32(flags);
            reply->writeInt32(sessionId);
            reply->writeInt32(status);
+4 −0
Original line number Diff line number Diff line
@@ -1242,6 +1242,7 @@ sp<IAudioRecord> AudioFlinger::openRecord(

    // check calling permissions
    if (!recordingAllowed()) {
        ALOGE("openRecord() permission denied: recording not allowed");
        lStatus = PERMISSION_DENIED;
        goto Exit;
    }
@@ -1257,12 +1258,14 @@ sp<IAudioRecord> AudioFlinger::openRecord(
        Mutex::Autolock _l(mLock);
        thread = checkRecordThread_l(input);
        if (thread == NULL) {
            ALOGE("openRecord() checkRecordThread_l failed");
            lStatus = BAD_VALUE;
            goto Exit;
        }

        if (deviceRequiresCaptureAudioOutputPermission(thread->inDevice())
                && !captureAudioOutputAllowed()) {
            ALOGE("openRecord() permission denied: capture not allowed");
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }
@@ -1283,6 +1286,7 @@ sp<IAudioRecord> AudioFlinger::openRecord(
        // The record track uses one track in mHardwareMixerThread by convention.
        recordTrack = thread->createRecordTrack_l(client, sampleRate, format, channelMask,
                                                  frameCount, lSessionId, flags, tid, &lStatus);
        LOG_ALWAYS_FATAL_IF((recordTrack != 0) != (lStatus == NO_ERROR));
    }
    if (lStatus != NO_ERROR) {
        // remove local strong reference to Client before deleting the RecordTrack so that the
+3 −1
Original line number Diff line number Diff line
@@ -4575,7 +4575,7 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR

    lStatus = initCheck();
    if (lStatus != NO_ERROR) {
        ALOGE("Audio driver not initialized.");
        ALOGE("createRecordTrack_l() audio driver not initialized");
        goto Exit;
    }
    // client expresses a preference for FAST, but we get the final say
@@ -4638,7 +4638,9 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR
                      format, channelMask, frameCount, sessionId);

        if (track->getCblk() == 0) {
            ALOGE("createRecordTrack_l() no control block");
            lStatus = NO_MEMORY;
            track.clear();
            goto Exit;
        }
        mTracks.add(track);