diff options
author | Wei Jia <wjia@google.com> | 2014-08-19 18:52:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-19 15:47:37 +0000 |
commit | 2a1bcb8347ad4778a49bb340c3ed28ba27caa7d7 (patch) | |
tree | bd75963a5dbc52df1f889adaf118b7c0b5d35f4d /media | |
parent | 1e2d7cd671ece1b9eaec7b4c56633884c9a899bd (diff) | |
parent | 88703c34fb4a9db1ff51495879f9775474c8ce89 (diff) | |
download | frameworks_av-2a1bcb8347ad4778a49bb340c3ed28ba27caa7d7.zip frameworks_av-2a1bcb8347ad4778a49bb340c3ed28ba27caa7d7.tar.gz frameworks_av-2a1bcb8347ad4778a49bb340c3ed28ba27caa7d7.tar.bz2 |
Merge "NuPlayer: use generation to detect stale requests from old decoders." into lmp-dev
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 33 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.h | 2 |
2 files changed, 31 insertions, 4 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 7ed65de..5f2c20a 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<AMessage> &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<AMessage> reply; + if (!(msg->findMessage("reply", &reply))) { + return; + } + + reply->setInt32("err", INFO_DISCONTINUITY); + reply->post(); + return; + } + int32_t what; CHECK(msg->findInt32("what", &what)); @@ -1151,17 +1172,21 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) { } } - sp<AMessage> notify = - new AMessage(audio ? kWhatAudioNotify : kWhatVideoNotify, - id()); - if (audio) { + sp<AMessage> notify = new AMessage(kWhatAudioNotify, id()); + ++mAudioDecoderGeneration; + notify->setInt32("generation", mAudioDecoderGeneration); + if (mOffloadAudio) { *decoder = new DecoderPassThrough(notify); } else { *decoder = new Decoder(notify); } } else { + sp<AMessage> 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 48882c5..bb76636 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -129,6 +129,8 @@ private: sp<CCDecoder> mCCDecoder; sp<Renderer> mRenderer; sp<ALooper> mRendererLooper; + int32_t mAudioDecoderGeneration; + int32_t mVideoDecoderGeneration; List<sp<Action> > mDeferredActions; |