diff options
author | Wei Jia <wjia@google.com> | 2014-10-02 23:23:58 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-02 23:23:58 +0000 |
commit | 86c541dc3ce6c5af1d0b9dc051f804e03d2c7424 (patch) | |
tree | d865f43ae4ae8fbc15c3e564b163aed443f58f7f | |
parent | 55fc6a77f5c6e26627098dc5257fcf9b605967ef (diff) | |
parent | 6eff943c133903fcd9bdb7bb1812d7b383b090f8 (diff) | |
download | frameworks_av-86c541dc3ce6c5af1d0b9dc051f804e03d2c7424.zip frameworks_av-86c541dc3ce6c5af1d0b9dc051f804e03d2c7424.tar.gz frameworks_av-86c541dc3ce6c5af1d0b9dc051f804e03d2c7424.tar.bz2 |
am 6eff943c: Merge "NuPlayerDecoder: postpone input message processing when it\'s not dequeued." into lmp-dev
* commit '6eff943c133903fcd9bdb7bb1812d7b383b090f8':
NuPlayerDecoder: postpone input message processing when it's not dequeued.
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp | 35 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h | 4 |
2 files changed, 31 insertions, 8 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp index 7814bf1..f131b1f 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp @@ -189,6 +189,8 @@ void NuPlayer::Decoder::releaseAndResetMediaBuffers() { for (size_t i = 0; i < mInputBufferIsDequeued.size(); i++) { mInputBufferIsDequeued.editItemAt(i) = false; } + + mPendingInputMessages.clear(); } void NuPlayer::Decoder::requestCodecNotification() { @@ -274,7 +276,19 @@ bool NuPlayer::Decoder::handleAnInputBuffer() { ALOGI("[%s] resubmitting CSD", mComponentName.c_str()); reply->setBuffer("buffer", buffer); mCSDsToSubmit.removeAt(0); - reply->post(); + CHECK(onInputBufferFilled(reply)); + return true; + } + + while (!mPendingInputMessages.empty()) { + sp<AMessage> msg = *mPendingInputMessages.begin(); + if (!onInputBufferFilled(msg)) { + break; + } + mPendingInputMessages.erase(mPendingInputMessages.begin()); + } + + if (!mInputBufferIsDequeued.editItemAt(bufferIx)) { return true; } @@ -286,7 +300,7 @@ bool NuPlayer::Decoder::handleAnInputBuffer() { return true; } -void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) { +bool android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) { size_t bufferIx; CHECK(msg->findSize("buffer-ix", &bufferIx)); CHECK_LT(bufferIx, mInputBuffers.size()); @@ -306,9 +320,12 @@ void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) { const sp<ABuffer> &buf = mInputBuffers[ix]; if (buf->data() == mediaBuffer->data()) { // all input buffers are dequeued on start, hence the check - CHECK(mInputBufferIsDequeued[ix]); - ALOGV("[%s] received MediaBuffer for #%zu instead of #%zu", - mComponentName.c_str(), ix, bufferIx); + if (!mInputBufferIsDequeued[ix]) { + ALOGV("[%s] received MediaBuffer for #%zu instead of #%zu", + mComponentName.c_str(), ix, bufferIx); + mediaBuffer->release(); + return false; + } // TRICKY: need buffer for the metadata, so instead, set // codecBuffer to the same (though incorrect) buffer to @@ -333,7 +350,7 @@ void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) { if (streamErr == OK) { /* buffers are returned to hold on to */ - return; + return true; } // attempt to queue EOS @@ -398,6 +415,7 @@ void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) { } } } + return true; } bool NuPlayer::Decoder::handleAnOutputBuffer() { @@ -620,7 +638,10 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) { case kWhatInputBufferFilled: { if (!isStaleReply(msg)) { - onInputBufferFilled(msg); + if (!mPendingInputMessages.empty() + || !onInputBufferFilled(msg)) { + mPendingInputMessages.push_back(msg); + } } break; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h index cc1bdff..dba3eee 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h @@ -80,6 +80,8 @@ private: sp<ALooper> mCodecLooper; sp<ALooper> mDecoderLooper; + List<sp<AMessage> > mPendingInputMessages; + Vector<sp<ABuffer> > mInputBuffers; Vector<sp<ABuffer> > mOutputBuffers; Vector<sp<ABuffer> > mCSDsForCurrentFormat; @@ -98,7 +100,7 @@ private: void onConfigure(const sp<AMessage> &format); void onFlush(); void onResume(); - void onInputBufferFilled(const sp<AMessage> &msg); + bool onInputBufferFilled(const sp<AMessage> &msg); void onRenderBuffer(const sp<AMessage> &msg); void onShutdown(); |