summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-03-09 09:46:33 -0800
committerAndreas Huber <andih@google.com>2012-03-09 09:46:33 -0800
commit5aaeb0d64fc98f9b019a4378eb39f0ee49ee6ec4 (patch)
treeaad8b0cec3fb0153fbee5391ee636cac73c02fa5 /cmds
parent083c154162c88a9f63aeaa10a4b52dd454bda9ff (diff)
downloadframeworks_av-5aaeb0d64fc98f9b019a4378eb39f0ee49ee6ec4.zip
frameworks_av-5aaeb0d64fc98f9b019a4378eb39f0ee49ee6ec4.tar.gz
frameworks_av-5aaeb0d64fc98f9b019a4378eb39f0ee49ee6ec4.tar.bz2
fix EOS handling in codec test.
Change-Id: I5eb6d00aa0c1a728a951c7ffa4faebcadd7b14a6
Diffstat (limited to 'cmds')
-rw-r--r--cmds/stagefright/codec.cpp57
1 files changed, 30 insertions, 27 deletions
diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp
index 0414b98..fea62cc 100644
--- a/cmds/stagefright/codec.cpp
+++ b/cmds/stagefright/codec.cpp
@@ -49,6 +49,7 @@ struct CodecState {
size_t mCSDIndex;
Vector<sp<ABuffer> > mInBuffers;
Vector<sp<ABuffer> > mOutBuffers;
+ bool mSignalledInputEOS;
bool mSawOutputEOS;
int64_t mNumBuffersDecoded;
int64_t mNumBytesDecoded;
@@ -127,6 +128,7 @@ static int decode(
}
state->mCSDIndex = 0;
+ state->mSignalledInputEOS = false;
state->mSawOutputEOS = false;
ALOGV("got %d pieces of codec specific data.", state->mCSD.size());
@@ -180,33 +182,7 @@ static int decode(
status_t err = extractor->getSampleTrackIndex(&trackIndex);
if (err != OK) {
- ALOGV("signalling EOS.");
-
- for (size_t i = 0; i < stateByTrack.size(); ++i) {
- CodecState *state = &stateByTrack.editValueAt(i);
-
- for (;;) {
- size_t index;
- err = state->mCodec->dequeueInputBuffer(&index, kTimeout);
-
- if (err == -EAGAIN) {
- continue;
- }
-
- CHECK_EQ(err, (status_t)OK);
-
- err = state->mCodec->queueInputBuffer(
- index,
- 0 /* offset */,
- 0 /* size */,
- 0ll /* timeUs */,
- MediaCodec::BUFFER_FLAG_EOS);
-
- CHECK_EQ(err, (status_t)OK);
- break;
- }
- }
-
+ ALOGV("saw input eos");
sawInputEOS = true;
} else {
CodecState *state = &stateByTrack.editValueFor(trackIndex);
@@ -240,6 +216,33 @@ static int decode(
CHECK_EQ(err, -EAGAIN);
}
}
+ } else {
+ for (size_t i = 0; i < stateByTrack.size(); ++i) {
+ CodecState *state = &stateByTrack.editValueAt(i);
+
+ if (!state->mSignalledInputEOS) {
+ size_t index;
+ status_t err =
+ state->mCodec->dequeueInputBuffer(&index, kTimeout);
+
+ if (err == OK) {
+ ALOGV("signalling input EOS on track %d", i);
+
+ err = state->mCodec->queueInputBuffer(
+ index,
+ 0 /* offset */,
+ 0 /* size */,
+ 0ll /* timeUs */,
+ MediaCodec::BUFFER_FLAG_EOS);
+
+ CHECK_EQ(err, (status_t)OK);
+
+ state->mSignalledInputEOS = true;
+ } else {
+ CHECK_EQ(err, -EAGAIN);
+ }
+ }
+ }
}
bool sawOutputEOSOnAllTracks = true;