summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-02-27 15:10:34 -0800
committerJamie Gennis <jgennis@google.com>2011-02-28 12:53:31 -0800
commit258d4e3aef7984574b0972a66871afc8a13d8e4e (patch)
treee43f95881328489ac23c72a3a58830a963223289 /media
parent3911a720270fc0326accfa4a3df427a649a45487 (diff)
downloadframeworks_av-258d4e3aef7984574b0972a66871afc8a13d8e4e.zip
frameworks_av-258d4e3aef7984574b0972a66871afc8a13d8e4e.tar.gz
frameworks_av-258d4e3aef7984574b0972a66871afc8a13d8e4e.tar.bz2
Stagefright: Use the ANW min undequeued bufs query.
This change modifies Stagefright's ANativeWindow initialization to use the new MIN_UNDEQUEUED_BUFFERS query on the ANativeWindow. Change-Id: I62565945e90ac40de326de77adcfa5577ed89975 Related-Bug: 3356050
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/ACodec.cpp44
-rw-r--r--media/libstagefright/OMXCodec.cpp38
2 files changed, 53 insertions, 29 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index b0ae3d8..50b7782 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -429,16 +429,6 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
return err;
}
- // Increase the buffer count by one to allow for the ANativeWindow to hold
- // on to one of the buffers.
- def.nBufferCountActual++;
- err = mOMX->setParameter(
- mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
-
- if (err != OK) {
- return err;
- }
-
// Set up the native window.
// XXX TODO: Get the gralloc usage flags from the OMX plugin!
err = native_window_set_usage(
@@ -450,6 +440,33 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
return err;
}
+ int minUndequeuedBufs = 0;
+ err = mNativeWindow->query(
+ mNativeWindow.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ &minUndequeuedBufs);
+
+ if (err != 0) {
+ LOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
+ strerror(-err), -err);
+ return err;
+ }
+
+ // 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 + minUndequeuedBufs) {
+ OMX_U32 newBufferCount = def.nBufferCountMin + minUndequeuedBufs;
+ def.nBufferCountActual = newBufferCount;
+ err = mOMX->setParameter(
+ mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
+
+ if (err != OK) {
+ LOGE("[%s] setting nBufferCountActual to %lu failed: %d",
+ mComponentName.c_str(), newBufferCount, err);
+ return err;
+ }
+ }
+
err = native_window_set_buffer_count(
mNativeWindow.get(), def.nBufferCountActual);
@@ -506,11 +523,7 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
cancelEnd = i;
} else {
// Return the last two buffers to the native window.
- // XXX TODO: The number of buffers the native window owns should
- // probably be queried from it when we put the native window in
- // fixed buffer pool mode (which needs to be implemented).
- // Currently it's hard-coded to 2.
- cancelStart = def.nBufferCountActual - 2;
+ cancelStart = def.nBufferCountActual - minUndequeuedBufs;
cancelEnd = def.nBufferCountActual;
}
@@ -2286,4 +2299,3 @@ void ACodec::FlushingState::changeStateIfWeOwnAllBuffers() {
}
} // namespace android
-
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5d502e7..1a37928 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1738,15 +1738,6 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
return err;
}
- // Increase the buffer count by one to allow for the ANativeWindow to hold
- // on to one of the buffers.
- def.nBufferCountActual++;
- err = mOMX->setParameter(
- mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- if (err != OK) {
- return err;
- }
-
err = applyRotation();
if (err != OK) {
return err;
@@ -1761,6 +1752,30 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
return err;
}
+ int minUndequeuedBufs = 0;
+ err = mNativeWindow->query(mNativeWindow.get(),
+ NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &minUndequeuedBufs);
+ if (err != 0) {
+ LOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
+ strerror(-err), -err);
+ return err;
+ }
+
+ // 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 + minUndequeuedBufs) {
+ OMX_U32 newBufferCount = def.nBufferCountMin + minUndequeuedBufs;
+ def.nBufferCountActual = newBufferCount;
+ err = mOMX->setParameter(
+ mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
+ if (err != OK) {
+ CODEC_LOGE("setting nBufferCountActual to %lu failed: %d",
+ newBufferCount, err);
+ return err;
+ }
+ }
+
err = native_window_set_buffer_count(
mNativeWindow.get(), def.nBufferCountActual);
if (err != 0) {
@@ -1818,10 +1833,7 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
cancelEnd = i;
} else {
// Return the last two buffers to the native window.
- // XXX TODO: The number of buffers the native window owns should probably be
- // queried from it when we put the native window in fixed buffer pool mode
- // (which needs to be implemented). Currently it's hard-coded to 2.
- cancelStart = def.nBufferCountActual - 2;
+ cancelStart = def.nBufferCountActual - minUndequeuedBufs;
cancelEnd = def.nBufferCountActual;
}