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

Commit 6dadf4e5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: fix SHARED MMAP streams" into main

parents d7d5f982 ed89641f
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -422,9 +422,17 @@ aaudio_result_t AAudioServiceEndpointMMAP::getFreeRunningPosition(int64_t *posit
        return AAUDIO_ERROR_NULL;
    }
    struct audio_mmap_position position;
    const status_t status = mMmapStream->getMmapPosition(&position);
    status_t status = mMmapStream->getMmapPosition(&position);
    ALOGV("%s() status= %d, pos = %d, nanos = %lld\n",
          __func__, status, position.position_frames, (long long) position.time_nanoseconds);
    if (status == INVALID_OPERATION) {
        // The HAL can return INVALID_OPERATION when the position is UNKNOWN.
        // That can cause SHARED MMAP to break. So coerce it to NOT_ENOUGH_DATA.
        // That will get converted to AAUDIO_ERROR_UNAVAILABLE.
        ALOGW("%s(): change INVALID_OPERATION to NOT_ENOUGH_DATA", __func__);
        status = NOT_ENOUGH_DATA; // see b/376467258
    }

    const aaudio_result_t result = AAudioConvert_androidToAAudioResult(status);
    if (result == AAUDIO_ERROR_UNAVAILABLE) {
        ALOGW("%s(): getMmapPosition() has no position data available", __func__);