diff options
author | James Dong <jdong@google.com> | 2012-02-01 19:28:54 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-02-02 10:24:25 -0800 |
commit | 928170837b9dec2b90f7a01b85182a8b00b45972 (patch) | |
tree | 9b12a61e0043eb9673ca3d2968135e5dcb65d103 /media/libstagefright/omx | |
parent | bb62819aa34b0e89090ccc50e5915e25bc137583 (diff) | |
download | frameworks_av-928170837b9dec2b90f7a01b85182a8b00b45972.zip frameworks_av-928170837b9dec2b90f7a01b85182a8b00b45972.tar.gz frameworks_av-928170837b9dec2b90f7a01b85182a8b00b45972.tar.bz2 |
Removed a loop for buffer lookup
o used the nInputPortIndex and nOutputPortIndex from header instead
of assuming that the # of ports == 2
Change-Id: I4b615912b088b4e2bac9c00e89986e811a5c58bb
Diffstat (limited to 'media/libstagefright/omx')
-rw-r--r-- | media/libstagefright/omx/SimpleSoftOMXComponent.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp index 0914f32..c79e01f 100644 --- a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp +++ b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp @@ -333,8 +333,9 @@ OMX_ERRORTYPE SimpleSoftOMXComponent::getState(OMX_STATETYPE *state) { void SimpleSoftOMXComponent::onMessageReceived(const sp<AMessage> &msg) { Mutex::Autolock autoLock(mLock); - - switch (msg->what()) { + uint32_t msgType = msg->what(); + ALOGV("msgType = %d", msgType); + switch (msgType) { case kWhatSendCommand: { int32_t cmd, param; @@ -354,27 +355,27 @@ void SimpleSoftOMXComponent::onMessageReceived(const sp<AMessage> &msg) { CHECK(mState == OMX_StateExecuting && mTargetState == mState); bool found = false; - for (size_t i = 0; i < mPorts.size(); ++i) { - PortInfo *port = &mPorts.editItemAt(i); + size_t portIndex = (kWhatEmptyThisBuffer == msgType)? + header->nInputPortIndex: header->nOutputPortIndex; + PortInfo *port = &mPorts.editItemAt(portIndex); - for (size_t j = 0; j < port->mBuffers.size(); ++j) { - BufferInfo *buffer = &port->mBuffers.editItemAt(j); + for (size_t j = 0; j < port->mBuffers.size(); ++j) { + BufferInfo *buffer = &port->mBuffers.editItemAt(j); - if (buffer->mHeader == header) { - CHECK(!buffer->mOwnedByUs); + if (buffer->mHeader == header) { + CHECK(!buffer->mOwnedByUs); - buffer->mOwnedByUs = true; + buffer->mOwnedByUs = true; - CHECK((msg->what() == kWhatEmptyThisBuffer - && port->mDef.eDir == OMX_DirInput) - || (port->mDef.eDir == OMX_DirOutput)); + CHECK((msgType == kWhatEmptyThisBuffer + && port->mDef.eDir == OMX_DirInput) + || (port->mDef.eDir == OMX_DirOutput)); - port->mQueue.push_back(buffer); - onQueueFilled(i); + port->mQueue.push_back(buffer); + onQueueFilled(portIndex); - found = true; - break; - } + found = true; + break; } } |