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

Commit bf04a5d7 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Simplify AudioRecord::getInputFramesLost()

This also fixes a benign race in reading mActive without a lock.

Change-Id: I19e953d4f275e5c266ca1ca3fece7b6c02ad1707
parent 39c54f68
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ public:
    // necessary to check returned status before using the returned values.
    static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT);

    // return the number of input frames lost by HAL implementation, or 0 if the handle is invalid
    static unsigned int  getInputFramesLost(audio_io_handle_t ioHandle);

    static int newAudioSessionId();
+2 −4
Original line number Diff line number Diff line
@@ -432,10 +432,8 @@ status_t AudioRecord::getPosition(uint32_t *position) const

unsigned int AudioRecord::getInputFramesLost() const
{
    if (mActive)
    // no need to check mActive, because if inactive this will return 0, which is what we want
    return AudioSystem::getInputFramesLost(mInput);
    else
        return 0;
}

// -------------------------------------------------------------------------
+0 −4
Original line number Diff line number Diff line
@@ -978,10 +978,6 @@ size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t form

unsigned int AudioFlinger::getInputFramesLost(audio_io_handle_t ioHandle) const
{
    if (ioHandle == 0) {
        return 0;
    }

    Mutex::Autolock _l(mLock);

    RecordThread *recordThread = checkRecordThread_l(ioHandle);