summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-02-23 11:21:43 -0800
committerAndreas Huber <andih@google.com>2012-02-23 11:21:43 -0800
commite98f8c04faf27df3b1829d336299ad51dad569cf (patch)
tree87ed36ebec49fde19611331385befab93f25a724 /cmds
parent16d3dfb5710290b334a07aadeb7d3620c7624e7c (diff)
downloadframeworks_av-e98f8c04faf27df3b1829d336299ad51dad569cf.zip
frameworks_av-e98f8c04faf27df3b1829d336299ad51dad569cf.tar.gz
frameworks_av-e98f8c04faf27df3b1829d336299ad51dad569cf.tar.bz2
Be more greedy when it comes to gathering input and output buffers.
Change-Id: I54c4f608e5155917ca35eba5655b4c06357fb112
Diffstat (limited to 'cmds')
-rw-r--r--cmds/stagefright/SimplePlayer.cpp73
-rw-r--r--cmds/stagefright/codec.cpp2
2 files changed, 49 insertions, 26 deletions
diff --git a/cmds/stagefright/SimplePlayer.cpp b/cmds/stagefright/SimplePlayer.cpp
index f850344..f269e80 100644
--- a/cmds/stagefright/SimplePlayer.cpp
+++ b/cmds/stagefright/SimplePlayer.cpp
@@ -259,7 +259,7 @@ void SimplePlayer::onMessageReceived(const sp<AMessage> &msg) {
status_t err = onDoMoreStuff();
if (err == OK) {
- msg->post(5000ll);
+ msg->post(10000ll);
}
break;
}
@@ -411,33 +411,53 @@ status_t SimplePlayer::onReset() {
}
status_t SimplePlayer::onDoMoreStuff() {
+ ALOGV("onDoMoreStuff");
for (size_t i = 0; i < mStateByTrackIndex.size(); ++i) {
CodecState *state = &mStateByTrackIndex.editValueAt(i);
- size_t index;
- status_t err = state->mCodec->dequeueInputBuffer(&index);
+ status_t err;
+ do {
+ size_t index;
+ err = state->mCodec->dequeueInputBuffer(&index);
- if (err == OK) {
- state->mAvailInputBufferIndices.push_back(index);
- }
+ if (err == OK) {
+ ALOGV("dequeued input buffer on track %d",
+ mStateByTrackIndex.keyAt(i));
- BufferInfo info;
- err = state->mCodec->dequeueOutputBuffer(
- &info.mIndex,
- &info.mOffset,
- &info.mSize,
- &info.mPresentationTimeUs,
- &info.mFlags);
-
- if (err == OK) {
- state->mAvailOutputBufferInfos.push_back(info);
- } else if (err == INFO_FORMAT_CHANGED) {
- err = onOutputFormatChanged(mStateByTrackIndex.keyAt(i), state);
- CHECK_EQ(err, (status_t)OK);
- } else if (err == INFO_OUTPUT_BUFFERS_CHANGED) {
- err = state->mCodec->getOutputBuffers(&state->mBuffers[1]);
- CHECK_EQ(err, (status_t)OK);
- }
+ state->mAvailInputBufferIndices.push_back(index);
+ } else {
+ ALOGV("dequeueInputBuffer on track %d returned %d",
+ mStateByTrackIndex.keyAt(i), err);
+ }
+ } while (err == OK);
+
+ do {
+ BufferInfo info;
+ err = state->mCodec->dequeueOutputBuffer(
+ &info.mIndex,
+ &info.mOffset,
+ &info.mSize,
+ &info.mPresentationTimeUs,
+ &info.mFlags);
+
+ if (err == OK) {
+ ALOGV("dequeued output buffer on track %d",
+ mStateByTrackIndex.keyAt(i));
+
+ state->mAvailOutputBufferInfos.push_back(info);
+ } else if (err == INFO_FORMAT_CHANGED) {
+ err = onOutputFormatChanged(mStateByTrackIndex.keyAt(i), state);
+ CHECK_EQ(err, (status_t)OK);
+ } else if (err == INFO_OUTPUT_BUFFERS_CHANGED) {
+ err = state->mCodec->getOutputBuffers(&state->mBuffers[1]);
+ CHECK_EQ(err, (status_t)OK);
+ } else {
+ ALOGV("dequeueOutputBuffer on track %d returned %d",
+ mStateByTrackIndex.keyAt(i), err);
+ }
+ } while (err == OK
+ || err == INFO_FORMAT_CHANGED
+ || err == INFO_OUTPUT_BUFFERS_CHANGED);
}
for (;;) {
@@ -475,6 +495,8 @@ status_t SimplePlayer::onDoMoreStuff() {
0);
CHECK_EQ(err, (status_t)OK);
+ ALOGV("enqueued input data on track %d", trackIndex);
+
err = mExtractor->advance();
CHECK_EQ(err, (status_t)OK);
}
@@ -500,7 +522,7 @@ status_t SimplePlayer::onDoMoreStuff() {
if (lateByUs > 30000ll) {
ALOGI("track %d buffer late by %lld us, dropping.",
- i, lateByUs);
+ mStateByTrackIndex.keyAt(i), lateByUs);
state->mCodec->releaseOutputBuffer(info->mIndex);
} else {
if (state->mAudioTrack != NULL) {
@@ -529,7 +551,8 @@ status_t SimplePlayer::onDoMoreStuff() {
break;
}
} else {
- ALOGV("track %d buffer early by %lld us.", i, -lateByUs);
+ ALOGV("track %d buffer early by %lld us.",
+ mStateByTrackIndex.keyAt(i), -lateByUs);
break;
}
}
diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp
index 02dc8dd..ad246d2 100644
--- a/cmds/stagefright/codec.cpp
+++ b/cmds/stagefright/codec.cpp
@@ -394,7 +394,7 @@ int main(int argc, char **argv) {
player->setDataSource(argv[0]);
player->setSurface(surface->getSurfaceTexture());
player->start();
- sleep(10);
+ sleep(60);
player->stop();
player->reset();