Loading media/extractors/mp4/MPEG4Extractor.cpp +24 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading Loading @@ -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; Loading media/libaaudio/src/client/AudioStreamInternalCapture.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading media/libaaudio/src/client/AudioStreamInternalPlay.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading media/libaaudio/src/core/AudioStream.cpp +11 −19 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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; Loading @@ -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: Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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() { Loading Loading @@ -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; } Loading @@ -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(); Loading media/libaaudio/src/core/AudioStream.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -424,7 +424,7 @@ public: */ aaudio_result_t safeReleaseClose(); aaudio_result_t safeReleaseCloseFromCallback(); aaudio_result_t safeReleaseCloseInternal(); protected: Loading Loading
media/extractors/mp4/MPEG4Extractor.cpp +24 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading Loading @@ -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; Loading
media/libaaudio/src/client/AudioStreamInternalCapture.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading
media/libaaudio/src/client/AudioStreamInternalPlay.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading
media/libaaudio/src/core/AudioStream.cpp +11 −19 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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; Loading @@ -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: Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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() { Loading Loading @@ -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; } Loading @@ -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(); Loading
media/libaaudio/src/core/AudioStream.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -424,7 +424,7 @@ public: */ aaudio_result_t safeReleaseClose(); aaudio_result_t safeReleaseCloseFromCallback(); aaudio_result_t safeReleaseCloseInternal(); protected: Loading