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

Commit 58883a0c authored by Glenn Kasten's avatar Glenn Kasten
Browse files

AudioRecord: Use original flags during track recreation

Bug: 27554925
Change-Id: Idecbadcb114b9470e89dccf1c65b0f965cc2bf15
parent 14fd3a1e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -596,7 +596,13 @@ private:
    size_t                  mFrameSize;         // app-level frame size == AudioFlinger frame size
    uint32_t                mLatency;           // in ms
    audio_channel_mask_t    mChannelMask;
    audio_input_flags_t     mFlags;

    audio_input_flags_t     mFlags;                 // same as mOrigFlags, except for bits that may
                                                    // be denied by client or server, such as
                                                    // AUDIO_INPUT_FLAG_FAST.  mLock must be
                                                    // held to read or write those bits reliably.
    audio_input_flags_t     mOrigFlags;             // as specified in constructor or set(), const

    int                     mSessionId;
    transfer_type           mTransfer;

+7 −4
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ status_t AudioRecord::set(
        mClientPid = pid;
    }

    mFlags = flags;
    mOrigFlags = mFlags = flags;
    mCbf = cbf;

    if (cbf != NULL) {
@@ -518,6 +518,9 @@ status_t AudioRecord::openRecord_l(const Modulo<uint32_t> &epoch, const String16
    }
    audio_io_handle_t input;

    // mFlags (not mOrigFlags) is modified depending on whether fast request is accepted.
    // After fast request is denied, we will request again if IAudioRecord is re-created.

    status_t status;
    status = AudioSystem::getInputForAttr(&mAttributes, &input,
                                        (audio_session_t)mSessionId,
@@ -569,7 +572,6 @@ status_t AudioRecord::openRecord_l(const Modulo<uint32_t> &epoch, const String16
            ALOGW("AUDIO_INPUT_FLAG_FAST denied by client; transfer %d, "
                "track %u Hz, input %u Hz",
                mTransfer, mSampleRate, afSampleRate);
            // once denied, do not request again if IAudioRecord is re-created
            mFlags = (audio_input_flags_t) (mFlags & ~AUDIO_INPUT_FLAG_FAST);
        }
    }
@@ -669,8 +671,7 @@ status_t AudioRecord::openRecord_l(const Modulo<uint32_t> &epoch, const String16
            ALOGV("AUDIO_INPUT_FLAG_FAST successful; frameCount %zu", frameCount);
            mAwaitBoost = true;
        } else {
            ALOGV("AUDIO_INPUT_FLAG_FAST denied by server; frameCount %zu", frameCount);
            // once denied, do not request again if IAudioRecord is re-created
            ALOGW("AUDIO_INPUT_FLAG_FAST denied by server; frameCount %zu", frameCount);
            mFlags = (audio_input_flags_t) (mFlags & ~AUDIO_INPUT_FLAG_FAST);
        }
    }
@@ -1140,6 +1141,8 @@ status_t AudioRecord::restoreRecord_l(const char *from)
    ALOGW("dead IAudioRecord, creating a new one from %s()", from);
    ++mSequence;

    mFlags = mOrigFlags;

    // if the new IAudioRecord is created, openRecord_l() will modify the
    // following member variables: mAudioRecord, mCblkMemory, mCblk, mBufferMemory.
    // It will also delete the strong references on previous IAudioRecord and IMemory