summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2014-09-23 18:25:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-23 18:25:37 +0000
commitad5447f659043ce3e4b3719c6c18a254bee1dde2 (patch)
treee8156a950fafbd7268b185e742ff01936146c1f2 /media
parent88b4cc81779cc7da9c438e1bcd2e9f0897157bbd (diff)
parent57568df014f8629ebc5ca8bce9da796dd187401b (diff)
downloadframeworks_av-ad5447f659043ce3e4b3719c6c18a254bee1dde2.zip
frameworks_av-ad5447f659043ce3e4b3719c6c18a254bee1dde2.tar.gz
frameworks_av-ad5447f659043ce3e4b3719c6c18a254bee1dde2.tar.bz2
Merge "NuPlayer: use generation to filter out stale message from renderer." into lmp-dev
Diffstat (limited to 'media')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp26
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.h1
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;