diff options
author | Wei Jia <wjia@google.com> | 2014-09-23 19:09:22 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-23 19:09:22 +0000 |
commit | 888451fbabf574a09b33a01db821a0a2d4a00add (patch) | |
tree | adaf9024916f34d6a252028ca0e8e2e0397d9d7d /media | |
parent | 20862d50fa66a18b1984250e15e387960d24b22d (diff) | |
parent | ad5447f659043ce3e4b3719c6c18a254bee1dde2 (diff) | |
download | frameworks_av-888451fbabf574a09b33a01db821a0a2d4a00add.zip frameworks_av-888451fbabf574a09b33a01db821a0a2d4a00add.tar.gz frameworks_av-888451fbabf574a09b33a01db821a0a2d4a00add.tar.bz2 |
am ad5447f6: Merge "NuPlayer: use generation to filter out stale message from renderer." into lmp-dev
* commit 'ad5447f659043ce3e4b3719c6c18a254bee1dde2':
NuPlayer: use generation to filter out stale message from renderer.
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 26 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.h | 1 |
2 files changed, 20 insertions, 7 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index dad480d..b589909 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -155,6 +155,7 @@ NuPlayer::NuPlayer() mCurrentOffloadInfo(AUDIO_INFO_INITIALIZER), mAudioDecoderGeneration(0), mVideoDecoderGeneration(0), + mRendererGeneration(0), mAudioEOS(false), mVideoEOS(false), mScanSourcesPending(false), @@ -633,10 +634,10 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { flags |= Renderer::FLAG_OFFLOAD_AUDIO; } - mRenderer = new Renderer( - mAudioSink, - new AMessage(kWhatRendererNotify, id()), - flags); + sp<AMessage> notify = new AMessage(kWhatRendererNotify, id()); + ++mRendererGeneration; + notify->setInt32("generation", mRendererGeneration); + mRenderer = new Renderer(mAudioSink, notify, flags); mRendererLooper = new ALooper; mRendererLooper->setName("NuPlayerRenderer"); @@ -813,11 +814,13 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { ALOGV("%s shutdown completed", audio ? "audio" : "video"); if (audio) { mAudioDecoder.clear(); + ++mAudioDecoderGeneration; CHECK_EQ((int)mFlushingAudio, (int)SHUTTING_DOWN_DECODER); mFlushingAudio = SHUT_DOWN; } else { mVideoDecoder.clear(); + ++mVideoDecoderGeneration; CHECK_EQ((int)mFlushingVideo, (int)SHUTTING_DOWN_DECODER); mFlushingVideo = SHUT_DOWN; @@ -835,9 +838,11 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { mRenderer->queueEOS(audio, err); if (audio && mFlushingAudio != NONE) { mAudioDecoder.clear(); + ++mAudioDecoderGeneration; mFlushingAudio = SHUT_DOWN; } else if (!audio && mFlushingVideo != NONE){ mVideoDecoder.clear(); + ++mVideoDecoderGeneration; mFlushingVideo = SHUT_DOWN; } finishFlushIfPossible(); @@ -857,6 +862,14 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { case kWhatRendererNotify: { + int32_t requesterGeneration = mRendererGeneration - 1; + CHECK(msg->findInt32("generation", &requesterGeneration)); + if (requesterGeneration != mRendererGeneration) { + ALOGV("got message from old renderer, generation(%d:%d)", + requesterGeneration, mRendererGeneration); + return; + } + int32_t what; CHECK(msg->findInt32("what", &what)); @@ -919,6 +932,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { CHECK(msg->findInt64("positionUs", &positionUs)); closeAudioSink(); mAudioDecoder.clear(); + ++mAudioDecoderGeneration; mRenderer->flush(true /* audio */); if (mVideoDecoder != NULL) { mRenderer->flush(false /* audio */); @@ -1849,9 +1863,6 @@ void NuPlayer::performReset() { ++mScanSourcesGeneration; mScanSourcesPending = false; - ++mAudioDecoderGeneration; - ++mVideoDecoderGeneration; - if (mRendererLooper != NULL) { if (mRenderer != NULL) { mRendererLooper->unregisterHandler(mRenderer->id()); @@ -1860,6 +1871,7 @@ void NuPlayer::performReset() { mRendererLooper.clear(); } mRenderer.clear(); + ++mRendererGeneration; if (mSource != NULL) { mSource->stop(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 7197e5f..eee96ca 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -137,6 +137,7 @@ private: sp<ALooper> mRendererLooper; int32_t mAudioDecoderGeneration; int32_t mVideoDecoderGeneration; + int32_t mRendererGeneration; List<sp<Action> > mDeferredActions; |