summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2015-07-15 21:46:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-15 21:46:18 +0000
commit6712ae1e1cd4e68c6f43ea3396c30a3633d8bd8c (patch)
treeca01e039a81aeec617b160fb9938b96c6b858d3d /media/libmediaplayerservice
parent1bc88814f530bf67e425cfb8cea0f2b8dce3c03f (diff)
parentda4252f86b1b730827053f015acec43b9c61fd37 (diff)
downloadframeworks_av-6712ae1e1cd4e68c6f43ea3396c30a3633d8bd8c.zip
frameworks_av-6712ae1e1cd4e68c6f43ea3396c30a3633d8bd8c.tar.gz
frameworks_av-6712ae1e1cd4e68c6f43ea3396c30a3633d8bd8c.tar.bz2
Merge "NuPlayer: fix handling of teardown event during flushing or shutting down." into mnc-dev
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 3e0ee08..2fdc196 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -1071,6 +1071,11 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
CHECK(msg->findInt32("audio", &audio));
ALOGV("renderer %s flush completed.", audio ? "audio" : "video");
+ if (audio && (mFlushingAudio == NONE || mFlushingAudio == FLUSHED
+ || mFlushingAudio == SHUT_DOWN)) {
+ // Flush has been handled by tear down.
+ break;
+ }
handleFlushComplete(audio, false /* isDecoder */);
finishFlushIfPossible();
} else if (what == Renderer::kWhatVideoRenderingStart) {
@@ -1079,14 +1084,27 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
ALOGV("media rendering started");
notifyListener(MEDIA_STARTED, 0, 0);
} else if (what == Renderer::kWhatAudioTearDown) {
- int64_t positionUs;
- CHECK(msg->findInt64("positionUs", &positionUs));
int32_t reason;
CHECK(msg->findInt32("reason", &reason));
ALOGV("Tear down audio with reason %d.", reason);
- closeAudioSink();
mAudioDecoder.clear();
++mAudioDecoderGeneration;
+ bool needsToCreateAudioDecoder = true;
+ if (mFlushingAudio == FLUSHING_DECODER) {
+ mFlushComplete[1 /* audio */][1 /* isDecoder */] = true;
+ mFlushingAudio = FLUSHED;
+ finishFlushIfPossible();
+ } else if (mFlushingAudio == FLUSHING_DECODER_SHUTDOWN
+ || mFlushingAudio == SHUTTING_DOWN_DECODER) {
+ mFlushComplete[1 /* audio */][1 /* isDecoder */] = true;
+ mFlushingAudio = SHUT_DOWN;
+ finishFlushIfPossible();
+ needsToCreateAudioDecoder = false;
+ }
+ if (mRenderer == NULL) {
+ break;
+ }
+ closeAudioSink();
mRenderer->flush(
true /* audio */, false /* notifyComplete */);
if (mVideoDecoder != NULL) {
@@ -1094,9 +1112,11 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
false /* audio */, false /* notifyComplete */);
}
+ int64_t positionUs;
+ CHECK(msg->findInt64("positionUs", &positionUs));
performSeek(positionUs);
- if (reason == Renderer::kDueToError) {
+ if (reason == Renderer::kDueToError && needsToCreateAudioDecoder) {
instantiateDecoder(true /* audio */, &mAudioDecoder);
}
}