Loading media/libaudioclient/AudioRecord.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -411,6 +411,9 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t tri mFramesReadServerOffset -= mFramesRead + framesFlushed; mFramesRead = 0; mProxy->clearTimestamp(); // timestamp is invalid until next server push mPreviousTimestamp.clear(); mTimestampRetrogradePositionReported = false; mTimestampRetrogradeTimeReported = false; // reset current position as seen by client to 0 mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition()); Loading Loading @@ -600,6 +603,39 @@ status_t AudioRecord::getTimestamp(ExtendedTimestamp *timestamp) timestamp->mPosition[i] += mFramesReadServerOffset; } } bool timestampRetrogradeTimeReported = false; bool timestampRetrogradePositionReported = false; for (int i = 0; i < ExtendedTimestamp::LOCATION_MAX; ++i) { if (timestamp->mTimeNs[i] >= 0 && mPreviousTimestamp.mTimeNs[i] >= 0) { if (timestamp->mTimeNs[i] < mPreviousTimestamp.mTimeNs[i]) { if (!mTimestampRetrogradeTimeReported) { ALOGD("%s: retrograde time adjusting [%d] current:%lld to previous:%lld", __func__, i, (long long)timestamp->mTimeNs[i], (long long)mPreviousTimestamp.mTimeNs[i]); timestampRetrogradeTimeReported = true; } timestamp->mTimeNs[i] = mPreviousTimestamp.mTimeNs[i]; } if (timestamp->mPosition[i] < mPreviousTimestamp.mPosition[i]) { if (!mTimestampRetrogradePositionReported) { ALOGD("%s: retrograde position" " adjusting [%d] current:%lld to previous:%lld", __func__, i, (long long)timestamp->mPosition[i], (long long)mPreviousTimestamp.mPosition[i]); timestampRetrogradePositionReported = true; } timestamp->mPosition[i] = mPreviousTimestamp.mPosition[i]; } } } mPreviousTimestamp = *timestamp; if (timestampRetrogradeTimeReported) { mTimestampRetrogradeTimeReported = true; } if (timestampRetrogradePositionReported) { mTimestampRetrogradePositionReported = true; } } return status; } Loading media/libaudioclient/include/media/AudioRecord.h +4 −0 Original line number Diff line number Diff line Loading @@ -711,6 +711,10 @@ private: bool mInOverrun; // whether recorder is currently in overrun state ExtendedTimestamp mPreviousTimestamp{}; // used to detect retrograde motion bool mTimestampRetrogradePositionReported = false; // reduce log spam bool mTimestampRetrogradeTimeReported = false; // reduce log spam private: class DeathNotifier : public IBinder::DeathRecipient { public: Loading Loading
media/libaudioclient/AudioRecord.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -411,6 +411,9 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t tri mFramesReadServerOffset -= mFramesRead + framesFlushed; mFramesRead = 0; mProxy->clearTimestamp(); // timestamp is invalid until next server push mPreviousTimestamp.clear(); mTimestampRetrogradePositionReported = false; mTimestampRetrogradeTimeReported = false; // reset current position as seen by client to 0 mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition()); Loading Loading @@ -600,6 +603,39 @@ status_t AudioRecord::getTimestamp(ExtendedTimestamp *timestamp) timestamp->mPosition[i] += mFramesReadServerOffset; } } bool timestampRetrogradeTimeReported = false; bool timestampRetrogradePositionReported = false; for (int i = 0; i < ExtendedTimestamp::LOCATION_MAX; ++i) { if (timestamp->mTimeNs[i] >= 0 && mPreviousTimestamp.mTimeNs[i] >= 0) { if (timestamp->mTimeNs[i] < mPreviousTimestamp.mTimeNs[i]) { if (!mTimestampRetrogradeTimeReported) { ALOGD("%s: retrograde time adjusting [%d] current:%lld to previous:%lld", __func__, i, (long long)timestamp->mTimeNs[i], (long long)mPreviousTimestamp.mTimeNs[i]); timestampRetrogradeTimeReported = true; } timestamp->mTimeNs[i] = mPreviousTimestamp.mTimeNs[i]; } if (timestamp->mPosition[i] < mPreviousTimestamp.mPosition[i]) { if (!mTimestampRetrogradePositionReported) { ALOGD("%s: retrograde position" " adjusting [%d] current:%lld to previous:%lld", __func__, i, (long long)timestamp->mPosition[i], (long long)mPreviousTimestamp.mPosition[i]); timestampRetrogradePositionReported = true; } timestamp->mPosition[i] = mPreviousTimestamp.mPosition[i]; } } } mPreviousTimestamp = *timestamp; if (timestampRetrogradeTimeReported) { mTimestampRetrogradeTimeReported = true; } if (timestampRetrogradePositionReported) { mTimestampRetrogradePositionReported = true; } } return status; } Loading
media/libaudioclient/include/media/AudioRecord.h +4 −0 Original line number Diff line number Diff line Loading @@ -711,6 +711,10 @@ private: bool mInOverrun; // whether recorder is currently in overrun state ExtendedTimestamp mPreviousTimestamp{}; // used to detect retrograde motion bool mTimestampRetrogradePositionReported = false; // reduce log spam bool mTimestampRetrogradeTimeReported = false; // reduce log spam private: class DeathNotifier : public IBinder::DeathRecipient { public: Loading