From: Wei Jia Date: Wed, 6 Aug 2014 18:24:07 +0000 (-0700) Subject: NuPlayer: use generation to detect stale requests from old decoders. X-Git-Tag: android-x86-6.0-r1~253^2~729^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=88703c34fb4a9db1ff51495879f9775474c8ce89;p=android-x86%2Fframeworks-av.git NuPlayer: use generation to detect stale requests from old decoders. Bug: 14955925 Bug: 16303659 Bug: 16467066 Bug: 13133027 Change-Id: I3e66b25b2302c0eb795361629b03bf2e96ed34e4 --- diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 5e7ecfae5a..0cba7f77e9 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -148,6 +148,8 @@ NuPlayer::NuPlayer() mVideoIsAVC(false), mOffloadAudio(false), mCurrentOffloadInfo(AUDIO_INFO_INITIALIZER), + mAudioDecoderGeneration(0), + mVideoDecoderGeneration(0), mAudioEOS(false), mVideoEOS(false), mScanSourcesPending(false), @@ -691,6 +693,25 @@ void NuPlayer::onMessageReceived(const sp &msg) { { bool audio = msg->what() == kWhatAudioNotify; + int32_t currentDecoderGeneration = + (audio? mAudioDecoderGeneration : mVideoDecoderGeneration); + int32_t requesterGeneration = currentDecoderGeneration - 1; + CHECK(msg->findInt32("generation", &requesterGeneration)); + + if (requesterGeneration != currentDecoderGeneration) { + ALOGV("got message from old %s decoder, generation(%d:%d)", + audio ? "audio" : "video", requesterGeneration, + currentDecoderGeneration); + sp reply; + if (!(msg->findMessage("reply", &reply))) { + return; + } + + reply->setInt32("err", INFO_DISCONTINUITY); + reply->post(); + return; + } + int32_t what; CHECK(msg->findInt32("what", &what)); @@ -1150,17 +1171,21 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp *decoder) { } } - sp notify = - new AMessage(audio ? kWhatAudioNotify : kWhatVideoNotify, - id()); - if (audio) { + sp notify = new AMessage(kWhatAudioNotify, id()); + ++mAudioDecoderGeneration; + notify->setInt32("generation", mAudioDecoderGeneration); + if (mOffloadAudio) { *decoder = new DecoderPassThrough(notify); } else { *decoder = new Decoder(notify); } } else { + sp notify = new AMessage(kWhatVideoNotify, id()); + ++mVideoDecoderGeneration; + notify->setInt32("generation", mVideoDecoderGeneration); + *decoder = new Decoder(notify, mNativeWindow); } (*decoder)->init(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 48882c59c1..bb76636a2f 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -129,6 +129,8 @@ private: sp mCCDecoder; sp mRenderer; sp mRendererLooper; + int32_t mAudioDecoderGeneration; + int32_t mVideoDecoderGeneration; List > mDeferredActions;