diff options
author | Andreas Huber <andih@google.com> | 2011-09-13 08:28:38 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-09-13 09:48:22 -0700 |
commit | 714aa7b7c52ce07d5fb44870c0853b4d8e5a758e (patch) | |
tree | 57b8bef529101db2340303e0d6c5a842f2cd9aaf /media/libmediaplayerservice/nuplayer | |
parent | 9215ea4cd8bc5f9c9770c5c34a009dc7c6068f86 (diff) | |
download | frameworks_av-714aa7b7c52ce07d5fb44870c0853b4d8e5a758e.zip frameworks_av-714aa7b7c52ce07d5fb44870c0853b4d8e5a758e.tar.gz frameworks_av-714aa7b7c52ce07d5fb44870c0853b4d8e5a758e.tar.bz2 |
Don't post position updates too frequently
i.e. don't hog my message queue.
related-to-bug: 5284760
Change-Id: I8e2d36a11dbee1567b18ed13dc5257a65c6eeda7
Diffstat (limited to 'media/libmediaplayerservice/nuplayer')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp | 16 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h | 4 |
2 files changed, 17 insertions, 3 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index 8f213da..bf83849 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -26,6 +26,9 @@ namespace android { +// static +const int64_t NuPlayer::Renderer::kMinPositionUpdateDelayUs = 100000ll; + NuPlayer::Renderer::Renderer( const sp<MediaPlayerBase::AudioSink> &sink, const sp<AMessage> ¬ify) @@ -43,7 +46,8 @@ NuPlayer::Renderer::Renderer( mHasAudio(false), mHasVideo(false), mSyncQueues(false), - mPaused(false) { + mPaused(false), + mLastPositionUpdateUs(-1ll) { } NuPlayer::Renderer::~Renderer() { @@ -190,7 +194,7 @@ void NuPlayer::Renderer::postDrainAudioQueue() { mDrainAudioQueuePending = true; sp<AMessage> msg = new AMessage(kWhatDrainAudioQueue, id()); msg->setInt32("generation", mAudioQueueGeneration); - msg->post(10000); + msg->post(); } void NuPlayer::Renderer::signalAudioSinkChanged() { @@ -198,7 +202,6 @@ void NuPlayer::Renderer::signalAudioSinkChanged() { } void NuPlayer::Renderer::onDrainAudioQueue() { - for (;;) { if (mAudioQueue.empty()) { break; @@ -562,6 +565,13 @@ void NuPlayer::Renderer::notifyPosition() { } int64_t nowUs = ALooper::GetNowUs(); + + if (mLastPositionUpdateUs >= 0 + && nowUs < mLastPositionUpdateUs + kMinPositionUpdateDelayUs) { + return; + } + mLastPositionUpdateUs = nowUs; + int64_t positionUs = (nowUs - mAnchorTimeRealUs) + mAnchorTimeMediaUs; sp<AMessage> notify = mNotify->dup(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h index 2713031..3a641a2 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h @@ -74,6 +74,8 @@ private: status_t mFinalResult; }; + static const int64_t kMinPositionUpdateDelayUs; + sp<MediaPlayerBase::AudioSink> mAudioSink; sp<AMessage> mNotify; List<QueueEntry> mAudioQueue; @@ -98,6 +100,8 @@ private: bool mPaused; + int64_t mLastPositionUpdateUs; + void onDrainAudioQueue(); void postDrainAudioQueue(); |