diff options
author | Jamie Gennis <jgennis@google.com> | 2011-03-02 16:44:51 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-02 16:44:51 -0800 |
commit | 9a5f9b7dbe9ecdebfbd9e8f96452c42213b08a31 (patch) | |
tree | 1acbbf96751320d217d292dd4b65a802be4aa68e /media/libstagefright/ACodec.cpp | |
parent | 8b17ba3296340dd556d5c00b322be42b9490b4e0 (diff) | |
parent | 258d4e3aef7984574b0972a66871afc8a13d8e4e (diff) | |
download | frameworks_av-9a5f9b7dbe9ecdebfbd9e8f96452c42213b08a31.zip frameworks_av-9a5f9b7dbe9ecdebfbd9e8f96452c42213b08a31.tar.gz frameworks_av-9a5f9b7dbe9ecdebfbd9e8f96452c42213b08a31.tar.bz2 |
Merge "Stagefright: Use the ANW min undequeued bufs query."
Diffstat (limited to 'media/libstagefright/ACodec.cpp')
-rw-r--r-- | media/libstagefright/ACodec.cpp | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index e43cdaa..d590ab9 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. OMX_U32 usage = 0; err = mOMX->getGraphicBufferUsage(mNode, kPortIndexOutput, &usage); @@ -457,6 +447,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); @@ -512,11 +529,7 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() { cancelEnd = mBuffers[kPortIndexOutput].size(); } 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; } |