diff options
author | Wei Jia <wjia@google.com> | 2014-08-21 00:49:54 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-21 00:16:54 +0000 |
commit | 01047680ac57712303e259f485efd9cb97e9a99a (patch) | |
tree | 052f35d6e82e2dcc833352cec40a54fc3ef7c730 | |
parent | c10b4689be0d3a0f4ff38c544a6c86c984665d26 (diff) | |
parent | 15506a6582fb86567c6887c4c426d44be02d12af (diff) | |
download | frameworks_av-01047680ac57712303e259f485efd9cb97e9a99a.zip frameworks_av-01047680ac57712303e259f485efd9cb97e9a99a.tar.gz frameworks_av-01047680ac57712303e259f485efd9cb97e9a99a.tar.bz2 |
Merge "NuPlayerDriver: include lapsed time when reporting current position." into lmp-dev
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp | 11 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index 8a63cfe..c0091bf 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -36,6 +36,8 @@ NuPlayerDriver::NuPlayerDriver() mAsyncResult(UNKNOWN_ERROR), mDurationUs(-1), mPositionUs(-1), + mNotifyTimeRealUs(0), + mPauseStartedTimeUs(0), mNumFramesTotal(0), mNumFramesDropped(0), mLooper(new ALooper), @@ -244,6 +246,7 @@ status_t NuPlayerDriver::start() { case STATE_STOPPED_AND_PREPARED: { mPlayer->resume(); + mPositionUs -= ALooper::GetNowUs() - mPauseStartedTimeUs; break; } @@ -278,6 +281,7 @@ status_t NuPlayerDriver::stop() { default: return INVALID_OPERATION; } + mPauseStartedTimeUs = ALooper::GetNowUs(); return OK; } @@ -299,6 +303,7 @@ status_t NuPlayerDriver::pause() { return INVALID_OPERATION; } + mPauseStartedTimeUs = ALooper::GetNowUs(); mState = STATE_PAUSED; return OK; @@ -347,7 +352,10 @@ status_t NuPlayerDriver::getCurrentPosition(int *msec) { if (mPositionUs < 0) { *msec = 0; } else { - *msec = (mPositionUs + 500ll) / 1000; + int64_t nowUs = + (mState != STATE_RUNNING ? + mPauseStartedTimeUs : ALooper::GetNowUs()); + *msec = (mPositionUs + nowUs - mNotifyTimeRealUs + 500ll) / 1000; } return OK; @@ -522,6 +530,7 @@ void NuPlayerDriver::notifyDuration(int64_t durationUs) { void NuPlayerDriver::notifyPosition(int64_t positionUs) { Mutex::Autolock autoLock(mLock); mPositionUs = positionUs; + mNotifyTimeRealUs = ALooper::GetNowUs(); } void NuPlayerDriver::notifySeekComplete() { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h index a006d8f..076493d 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h @@ -104,6 +104,8 @@ private: // >>> int64_t mDurationUs; int64_t mPositionUs; + int64_t mNotifyTimeRealUs; + int64_t mPauseStartedTimeUs; int64_t mNumFramesTotal; int64_t mNumFramesDropped; // <<< |