summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/ACodec.cpp
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-03-28 01:50:50 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-28 01:50:50 +0000
commit4f1ef2cd65d734edae17f8586cf717598b40f2c3 (patch)
treeef7587a0fa6221794a277b87812ea23d54c85406 /media/libstagefright/ACodec.cpp
parentff382d0c40493303ceb81a6c22d1a48c0fecfe9c (diff)
parent1000d426bedb1ec38bdfff98fc8f004b64af13cb (diff)
downloadframeworks_av-4f1ef2cd65d734edae17f8586cf717598b40f2c3.zip
frameworks_av-4f1ef2cd65d734edae17f8586cf717598b40f2c3.tar.gz
frameworks_av-4f1ef2cd65d734edae17f8586cf717598b40f2c3.tar.bz2
am 1000d426: am f780d28d: Merge "DO NOT MERGE: Revert "mediaplayer: keep more buffers with the BufferQueue"" into klp-dev
* commit '1000d426bedb1ec38bdfff98fc8f004b64af13cb': DO NOT MERGE: Revert "mediaplayer: keep more buffers with the BufferQueue"
Diffstat (limited to 'media/libstagefright/ACodec.cpp')
-rw-r--r--media/libstagefright/ACodec.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index fc9bee7..6dcedca 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -640,33 +640,18 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
return err;
}
- // FIXME: assume that surface is controlled by app (native window
- // returns the number for the case when surface is not controlled by app)
- (*minUndequeuedBuffers)++;
-
-
- // Use conservative allocation while also trying to reduce starvation
- //
- // 1. allocate at least nBufferCountMin + minUndequeuedBuffers - that is the
- // minimum needed for the consumer to be able to work
- // 2. try to allocate two (2) additional buffers to reduce starvation from
- // the consumer
- for (OMX_U32 extraBuffers = 2; /* condition inside loop */; extraBuffers--) {
- OMX_U32 newBufferCount =
- def.nBufferCountMin + *minUndequeuedBuffers + extraBuffers;
+ // XXX: Is this the right logic to use? It's not clear to me what the OMX
+ // buffer counts refer to - how do they account for the renderer holding on
+ // to buffers?
+ if (def.nBufferCountActual < def.nBufferCountMin + *minUndequeuedBuffers) {
+ OMX_U32 newBufferCount = def.nBufferCountMin + *minUndequeuedBuffers;
def.nBufferCountActual = newBufferCount;
err = mOMX->setParameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- if (err == OK) {
- *minUndequeuedBuffers += extraBuffers;
- break;
- }
-
- ALOGW("[%s] setting nBufferCountActual to %lu failed: %d",
- mComponentName.c_str(), newBufferCount, err);
- /* exit condition */
- if (extraBuffers == 0) {
+ if (err != OK) {
+ ALOGE("[%s] setting nBufferCountActual to %lu failed: %d",
+ mComponentName.c_str(), newBufferCount, err);
return err;
}
}
@@ -691,7 +676,6 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
&bufferCount, &bufferSize, &minUndequeuedBuffers);
if (err != 0)
return err;
- mNumUndequeuedBuffers = minUndequeuedBuffers;
ALOGV("[%s] Allocating %lu buffers from a native window of size %lu on "
"output port",
@@ -757,7 +741,6 @@ status_t ACodec::allocateOutputMetaDataBuffers() {
&bufferCount, &bufferSize, &minUndequeuedBuffers);
if (err != 0)
return err;
- mNumUndequeuedBuffers = minUndequeuedBuffers;
ALOGV("[%s] Allocating %lu meta buffers on output port",
mComponentName.c_str(), bufferCount);
@@ -2499,7 +2482,19 @@ void ACodec::waitUntilAllPossibleNativeWindowBuffersAreReturnedToUs() {
return;
}
- while (countBuffersOwnedByNativeWindow() > mNumUndequeuedBuffers
+ int minUndequeuedBufs = 0;
+ status_t err = mNativeWindow->query(
+ mNativeWindow.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ &minUndequeuedBufs);
+
+ if (err != OK) {
+ ALOGE("[%s] NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
+ mComponentName.c_str(), strerror(-err), -err);
+
+ minUndequeuedBufs = 0;
+ }
+
+ while (countBuffersOwnedByNativeWindow() > (size_t)minUndequeuedBufs
&& dequeueBufferFromNativeWindow() != NULL) {
// these buffers will be submitted as regular buffers; account for this
if (mStoreMetaDataInOutputBuffers && mMetaDataBuffersToSubmit > 0) {