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

Commit b30f1584 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7266202 from a4bfdc34 to sc-release

Change-Id: I7253ed54efc17b75a4c4400face3d87602d7779c
parents 14dc93d4 a4bfdc34
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -6266,6 +6266,18 @@ media_status_t MPEG4Source::read(
                    AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_IS_SYNC_FRAME, 1);
                }

                AMediaFormat_setInt64(
                        meta, "sample-file-offset" /*AMEDIAFORMAT_KEY_SAMPLE_FILE_OFFSET*/,
                        offset);

                if (mSampleTable != nullptr &&
                        mCurrentSampleIndex == mSampleTable->getLastSampleIndexInChunk()) {
                    AMediaFormat_setInt64(
                    meta,
                    "last-sample-index-in-chunk" /*AMEDIAFORMAT_KEY_LAST_SAMPLE_INDEX_IN_CHUNK*/,
                    mSampleTable->getLastSampleIndexInChunk());
                }

                ++mCurrentSampleIndex;
            }
        }
@@ -6415,6 +6427,17 @@ media_status_t MPEG4Source::read(
            AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_IS_SYNC_FRAME, 1);
        }

        AMediaFormat_setInt64(
                meta, "sample-file-offset" /*AMEDIAFORMAT_KEY_SAMPLE_FILE_OFFSET*/, offset);

        if (mSampleTable != nullptr &&
                mCurrentSampleIndex == mSampleTable->getLastSampleIndexInChunk()) {
            AMediaFormat_setInt64(
                    meta,
                    "last-sample-index-in-chunk" /*AMEDIAFORMAT_KEY_LAST_SAMPLE_INDEX_IN_CHUNK*/,
                    mSampleTable->getLastSampleIndexInChunk());
        }

        ++mCurrentSampleIndex;

        *out = mBuffer;
+1 −1
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ void *AudioStreamInternalCapture::callbackLoop() {

        if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
            ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
            result = systemStopFromCallback();
            result = systemStopInternal();
            break;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ void *AudioStreamInternalPlay::callbackLoop() {
            }
        } else if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
            ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
            result = systemStopFromCallback();
            result = systemStopInternal();
            break;
        }
    }
+11 −19
Original line number Diff line number Diff line
@@ -143,13 +143,13 @@ void AudioStream::logReleaseBufferState() {
}

aaudio_result_t AudioStream::systemStart() {
    std::lock_guard<std::mutex> lock(mStreamLock);

    if (collidesWithCallback()) {
        ALOGE("%s cannot be called from a callback!", __func__);
        return AAUDIO_ERROR_INVALID_STATE;
    }

    std::lock_guard<std::mutex> lock(mStreamLock);

    switch (getState()) {
        // Is this a good time to start?
        case AAUDIO_STREAM_STATE_OPEN:
@@ -187,7 +187,6 @@ aaudio_result_t AudioStream::systemStart() {
}

aaudio_result_t AudioStream::systemPause() {
    std::lock_guard<std::mutex> lock(mStreamLock);

    if (!isPauseSupported()) {
        return AAUDIO_ERROR_UNIMPLEMENTED;
@@ -198,6 +197,7 @@ aaudio_result_t AudioStream::systemPause() {
        return AAUDIO_ERROR_INVALID_STATE;
    }

    std::lock_guard<std::mutex> lock(mStreamLock);
    switch (getState()) {
        // Proceed with pausing.
        case AAUDIO_STREAM_STATE_STARTING:
@@ -242,12 +242,12 @@ aaudio_result_t AudioStream::safeFlush() {
        return AAUDIO_ERROR_UNIMPLEMENTED;
    }

    std::lock_guard<std::mutex> lock(mStreamLock);
    if (collidesWithCallback()) {
        ALOGE("stream cannot be flushed from a callback!");
        return AAUDIO_ERROR_INVALID_STATE;
    }

    std::lock_guard<std::mutex> lock(mStreamLock);
    aaudio_result_t result = AAudio_isFlushAllowed(getState());
    if (result != AAUDIO_OK) {
        return result;
@@ -256,7 +256,7 @@ aaudio_result_t AudioStream::safeFlush() {
    return requestFlush_l();
}

aaudio_result_t AudioStream::systemStopFromCallback() {
aaudio_result_t AudioStream::systemStopInternal() {
    std::lock_guard<std::mutex> lock(mStreamLock);
    aaudio_result_t result = safeStop_l();
    if (result == AAUDIO_OK) {
@@ -267,17 +267,12 @@ aaudio_result_t AudioStream::systemStopFromCallback() {
}

aaudio_result_t AudioStream::systemStopFromApp() {
    std::lock_guard<std::mutex> lock(mStreamLock);
    // This check can and should be done outside the lock.
    if (collidesWithCallback()) {
        ALOGE("stream cannot be stopped by calling from a callback!");
        return AAUDIO_ERROR_INVALID_STATE;
    }
    aaudio_result_t result = safeStop_l();
    if (result == AAUDIO_OK) {
        // We only call this for logging in "dumpsys audio". So ignore return code.
        (void) mPlayerBase->stopWithStatus();
    }
    return result;
    return systemStopInternal();
}

aaudio_result_t AudioStream::safeStop_l() {
@@ -316,12 +311,12 @@ aaudio_result_t AudioStream::safeStop_l() {
}

aaudio_result_t AudioStream::safeRelease() {
    // This may get temporarily unlocked in the MMAP release() when joining callback threads.
    std::lock_guard<std::mutex> lock(mStreamLock);
    if (collidesWithCallback()) {
        ALOGE("%s cannot be called from a callback!", __func__);
        return AAUDIO_ERROR_INVALID_STATE;
    }
    // This may get temporarily unlocked in the MMAP release() when joining callback threads.
    std::lock_guard<std::mutex> lock(mStreamLock);
    if (getState() == AAUDIO_STREAM_STATE_CLOSING) { // already released?
        return AAUDIO_OK;
    }
@@ -329,17 +324,14 @@ aaudio_result_t AudioStream::safeRelease() {
}

aaudio_result_t AudioStream::safeReleaseClose() {
    // This get temporarily unlocked in the MMAP release() when joining callback threads.
    std::lock_guard<std::mutex> lock(mStreamLock);
    if (collidesWithCallback()) {
        ALOGE("%s cannot be called from a callback!", __func__);
        return AAUDIO_ERROR_INVALID_STATE;
    }
    releaseCloseFinal_l();
    return AAUDIO_OK;
    return safeReleaseCloseInternal();
}

aaudio_result_t AudioStream::safeReleaseCloseFromCallback() {
aaudio_result_t AudioStream::safeReleaseCloseInternal() {
    // This get temporarily unlocked in the MMAP release() when joining callback threads.
    std::lock_guard<std::mutex> lock(mStreamLock);
    releaseCloseFinal_l();
+2 −2
Original line number Diff line number Diff line
@@ -408,7 +408,7 @@ public:
    /**
     * This is called internally when an app callback returns AAUDIO_CALLBACK_RESULT_STOP.
     */
    aaudio_result_t systemStopFromCallback();
    aaudio_result_t systemStopInternal();

    /**
     * Safely RELEASE a stream after taking mStreamLock and checking
@@ -424,7 +424,7 @@ public:
     */
    aaudio_result_t safeReleaseClose();

    aaudio_result_t safeReleaseCloseFromCallback();
    aaudio_result_t safeReleaseCloseInternal();

protected:

Loading