summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2014-09-25 03:50:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-25 03:50:46 +0000
commitc0d17e349901c3ccf6d15b7dcdf7fa30139c9750 (patch)
treefde8275902f719e5c015b179a5c6c20dfec0668e /media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
parent9a70c2c490afe35383c2226061af5a2f4e5b2109 (diff)
parentcf31f1eecf46d599428e115dfee8dd47b76c83fc (diff)
downloadframeworks_av-c0d17e349901c3ccf6d15b7dcdf7fa30139c9750.zip
frameworks_av-c0d17e349901c3ccf6d15b7dcdf7fa30139c9750.tar.gz
frameworks_av-c0d17e349901c3ccf6d15b7dcdf7fa30139c9750.tar.bz2
Merge "NuPlayer: Fix decoder error handling" into lmp-dev
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 1b1b1c8..1a066b7 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -227,7 +227,11 @@ status_t NuPlayer::Decoder::getInputBuffers(Vector<sp<ABuffer> > *buffers) const
void NuPlayer::Decoder::handleError(int32_t err)
{
- mCodec->release();
+ // We cannot immediately release the codec due to buffers still outstanding
+ // in the renderer. We signal to the player the error so it can shutdown/release the
+ // decoder after flushing and increment the generation to discard unnecessary messages.
+
+ ++mBufferGeneration;
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", kWhatError);
@@ -242,6 +246,8 @@ bool NuPlayer::Decoder::handleAnInputBuffer() {
mComponentName.c_str(), res == OK ? (int)bufferIx : res);
if (res != OK) {
if (res != -EAGAIN) {
+ ALOGE("Failed to dequeue input buffer for %s (err=%d)",
+ mComponentName.c_str(), res);
handleError(res);
}
return false;
@@ -315,7 +321,7 @@ void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) {
}
}
- mInputBufferIsDequeued.editItemAt(bufferIx) = false;
+
if (buffer == NULL /* includes !hasBuffer */) {
int32_t streamErr = ERROR_END_OF_STREAM;
@@ -333,12 +339,18 @@ void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) {
0,
0,
MediaCodec::BUFFER_FLAG_EOS);
- if (streamErr == ERROR_END_OF_STREAM && err != OK) {
+ if (err == OK) {
+ mInputBufferIsDequeued.editItemAt(bufferIx) = false;
+ } else if (streamErr == ERROR_END_OF_STREAM) {
streamErr = err;
// err will not be ERROR_END_OF_STREAM
}
if (streamErr != ERROR_END_OF_STREAM) {
+ ALOGE("Stream error for %s (err=%d), EOS %s queued",
+ mComponentName.c_str(),
+ streamErr,
+ err == OK ? "successfully" : "unsuccessfully");
handleError(streamErr);
}
} else {
@@ -368,14 +380,18 @@ void android::NuPlayer::Decoder::onInputBufferFilled(const sp<AMessage> &msg) {
timeUs,
flags);
if (err != OK) {
+ if (mediaBuffer != NULL) {
+ mediaBuffer->release();
+ }
ALOGE("Failed to queue input buffer for %s (err=%d)",
mComponentName.c_str(), err);
handleError(err);
- }
-
- if (mediaBuffer != NULL) {
- CHECK(mMediaBuffers[bufferIx] == NULL);
- mMediaBuffers.editItemAt(bufferIx) = mediaBuffer;
+ } else {
+ mInputBufferIsDequeued.editItemAt(bufferIx) = false;
+ if (mediaBuffer != NULL) {
+ CHECK(mMediaBuffers[bufferIx] == NULL);
+ mMediaBuffers.editItemAt(bufferIx) = mediaBuffer;
+ }
}
}
}
@@ -426,6 +442,8 @@ bool NuPlayer::Decoder::handleAnOutputBuffer() {
return true;
} else if (res != OK) {
if (res != -EAGAIN) {
+ ALOGE("Failed to dequeue output buffer for %s (err=%d)",
+ mComponentName.c_str(), res);
handleError(res);
}
return false;