summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
authorHaynes Mathew George <hgeorge@codeaurora.org>2015-11-04 19:40:55 -0800
committerHaynes Mathew George <hgeorge@codeaurora.org>2015-11-12 17:48:11 -0800
commit767254cd47bbcaa5ad9e09a6f0bae4a703fbdf7e (patch)
treec63c0f57c976f77f98dcf10d47362ad3c6bbf5b3 /media/libmediaplayerservice
parent60282213a1194ee8753ac53b97fc7f7e36373e17 (diff)
downloadframeworks_av-767254cd47bbcaa5ad9e09a6f0bae4a703fbdf7e.zip
frameworks_av-767254cd47bbcaa5ad9e09a6f0bae4a703fbdf7e.tar.gz
frameworks_av-767254cd47bbcaa5ad9e09a6f0bae4a703fbdf7e.tar.bz2
nuplayer: Perform proper shutdown sequence for offload teardown
Extend shutdown sequence used for pcm offload to compress offload as well. The current tear down sequence for compress offload calls clear on the NuPlayerDecoderPassthrough object directly. This is not guaranteed to prevent an encoded buffer from getting queued into the Renderer. Going through a proper flush+shutdown sequence helps prevent this (rare) scenario. CRs-Fixed: 914308 Change-Id: Ie2040cbbd42b8c67bb53a7ef8a628faf1ab7acda
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp51
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.h2
2 files changed, 10 insertions, 43 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index ec1ab79..b2f86ce 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -1110,46 +1110,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
int32_t reason;
CHECK(msg->findInt32("reason", &reason));
ALOGV("Tear down audio with reason %d.", reason);
-
- if (ifDecodedPCMOffload()) {
- tearDownPCMOffload(msg);
- break;
- }
-
- 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) {
- mRenderer->flush(
- false /* audio */, false /* notifyComplete */);
- }
-
- int64_t positionUs;
- if (!msg->findInt64("positionUs", &positionUs)) {
- positionUs = mPreviousSeekTimeUs;
- }
- performSeek(positionUs);
-
- if (reason == Renderer::kDueToError && needsToCreateAudioDecoder) {
- instantiateDecoder(true /* audio */, &mAudioDecoder);
- }
+ performTearDown(msg);
}
break;
}
@@ -2414,7 +2375,12 @@ void NuPlayer::Source::onMessageReceived(const sp<AMessage> & /* msg */) {
TRESPASS();
}
-void NuPlayer::tearDownPCMOffload(const sp<AMessage> &msg) {
+//
+// There is a flush from within the decoder's onFlush handling.
+// Without it, it is still possible that a buffer can be queueued
+// after NuPlayer issues a flush on the renderer's audio queue.
+//
+void NuPlayer::performTearDown(const sp<AMessage> &msg) {
int32_t reason;
CHECK(msg->findInt32("reason", &reason));
@@ -2438,13 +2404,14 @@ void NuPlayer::tearDownPCMOffload(const sp<AMessage> &msg) {
mDeferredActions.push_back(new SeekAction(positionUs));
break;
default:
- ALOGW("tearDownPCMOffload while flushing audio in %d", mFlushingAudio);
+ ALOGW("performTearDown while flushing audio in %d", mFlushingAudio);
break;
}
}
if (mRenderer != NULL) {
closeAudioSink();
+ // see comment at beginning of function
mRenderer->flush(
true /* audio */, false /* notifyComplete */);
if (mVideoDecoder != NULL) {
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index c0aa782..a939d23 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -280,7 +280,7 @@ protected:
void writeTrackInfo(Parcel* reply, const sp<AMessage> format) const;
- void tearDownPCMOffload(const sp<AMessage> &msg);
+ void performTearDown(const sp<AMessage> &msg);
DISALLOW_EVIL_CONSTRUCTORS(NuPlayer);
};