diff options
author | Wei Jia <wjia@google.com> | 2014-08-20 15:14:44 -0700 |
---|---|---|
committer | Wei Jia <wjia@google.com> | 2014-08-20 15:58:35 -0700 |
commit | 15506a6582fb86567c6887c4c426d44be02d12af (patch) | |
tree | 48471d4edf7dcb4088d3cee5e52f0d83b589f0ef /media/libmediaplayerservice | |
parent | e0b5cf7eae5ae16699864eeb8ae36975caa7a26c (diff) | |
download | frameworks_av-15506a6582fb86567c6887c4c426d44be02d12af.zip frameworks_av-15506a6582fb86567c6887c4c426d44be02d12af.tar.gz frameworks_av-15506a6582fb86567c6887c4c426d44be02d12af.tar.bz2 |
NuPlayerDriver: include lapsed time when reporting current position.
Bug: 17031731
Change-Id: I01962ee9194bdaa9e8ed1a51abbf365733be3c85
Diffstat (limited to 'media/libmediaplayerservice')
-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; // <<< |