diff options
author | Haynes Mathew George <hgeorge@codeaurora.org> | 2015-09-30 16:11:11 -0700 |
---|---|---|
committer | Haynes Mathew George <hgeorge@codeaurora.org> | 2015-10-09 19:10:36 -0700 |
commit | 00208bc4c6d725ea9ce0795a897d42b5a32360c3 (patch) | |
tree | ea0fa986f16a645c542a8704b706b01190b8924c /media/libmediaplayerservice/nuplayer/NuPlayer.cpp | |
parent | 380d397b261d7a12d7d1be10756dc93670aeb017 (diff) | |
download | frameworks_av-00208bc4c6d725ea9ce0795a897d42b5a32360c3.zip frameworks_av-00208bc4c6d725ea9ce0795a897d42b5a32360c3.tar.gz frameworks_av-00208bc4c6d725ea9ce0795a897d42b5a32360c3.tar.bz2 |
NuPlayer: Teardown sequence for pcm offload
On a teardown event, follow proper shutdown sequence
if the decoder instance type is not passthrough.
This is needed to ensure NuPlayerDecoder, MediaCodec do
not enter an invalid state due to forced clear while
handling a teardown event.
CRs-Fixed: 916643
Change-Id: Ied5df07dc8567974ef02e3a0bb415795f31f2ed2
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/NuPlayer.cpp')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index aaf6b9e..f9d1bee 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1110,6 +1110,12 @@ 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; @@ -2401,4 +2407,45 @@ void NuPlayer::Source::onMessageReceived(const sp<AMessage> & /* msg */) { TRESPASS(); } +void NuPlayer::tearDownPCMOffload(const sp<AMessage> &msg) { + int32_t reason; + CHECK(msg->findInt32("reason", &reason)); + + if (mAudioDecoder != NULL) { + switch (mFlushingAudio) { + case NONE: + case FLUSHING_DECODER: + mDeferredActions.push_back( + new FlushDecoderAction(FLUSH_CMD_SHUTDOWN /* audio */, + FLUSH_CMD_NONE /* video */)); + + if (reason == Renderer::kDueToError) { + mDeferredActions.push_back( + new InstantiateDecoderAction(true /* audio */, &mAudioDecoder)); + } + + int64_t positionUs; + if (!msg->findInt64("positionUs", &positionUs)) { + positionUs = mPreviousSeekTimeUs; + } + mDeferredActions.push_back(new SeekAction(positionUs)); + break; + default: + ALOGW("tearDownPCMOffload while flushing audio in %d", mFlushingAudio); + break; + } + } + + if (mRenderer != NULL) { + closeAudioSink(); + mRenderer->flush( + true /* audio */, false /* notifyComplete */); + if (mVideoDecoder != NULL) { + mRenderer->flush( + false /* audio */, false /* notifyComplete */); + } + } + processDeferredActions(); +} + } // namespace android |