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

Commit c2f0db7b authored by Atneya Nair's avatar Atneya Nair
Browse files

Protect AudioRecord against double set

Analogous to AudioTrack.

Test: atest AudioRecordTest
Change-Id: I405169be83bd181141f3a5120a3db1aa2ebbb3ab
parent b428b009
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -307,6 +307,8 @@ status_t AudioRecord::set(
        int32_t maxSharedAudioHistoryMs)
{
    status_t status = NO_ERROR;
    LOG_ALWAYS_FATAL_IF(mInitialized, "%s: should not be called twice", __func__);
    mInitialized = true;
    // Note mPortId is not valid until the track is created, so omit mPortId in ALOG for set.
    ALOGV("%s(): inputSource %d, sampleRate %u, format %#x, channelMask %#x, frameCount %zu, "
          "notificationFrames %u, sessionId %d, transferType %d, flags %#x, attributionSource %s"
+1 −0
Original line number Diff line number Diff line
@@ -740,6 +740,7 @@ private:
    wp<IAudioRecordCallback> mCallback;
    sp<IAudioRecordCallback> mLegacyCallbackWrapper;

    bool                    mInitialized = false;   // Protect against double set
    // for notification APIs
    uint32_t                mNotificationFramesReq; // requested number of frames between each
                                                    // notification callback