summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-11-24 21:55:35 -0800
committerLajos Molnar <lajos@google.com>2014-11-25 18:05:33 +0000
commit643319f60e72a86c180ee839b25c086554e5bd47 (patch)
tree84332221078a0ef6c180fab93962e877a0a414d6 /media
parentbc0f452b9a76dd8c8244e775bc9c5aa85cae3ddf (diff)
downloadframeworks_av-643319f60e72a86c180ee839b25c086554e5bd47.zip
frameworks_av-643319f60e72a86c180ee839b25c086554e5bd47.tar.gz
frameworks_av-643319f60e72a86c180ee839b25c086554e5bd47.tar.bz2
stagefright: add graceful handling when setting port definition
- don't crash when count of buffers is incorrect, or when the buffer size decreases. This allows configuring SW video encoders for smaller than QCIF size. Bug: 18513091 Change-Id: Ibfcd6b883a892156e408e94fbc329103b9ac09ac
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/omx/SimpleSoftOMXComponent.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
index 4999663..7f99dcd 100644
--- a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
+++ b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
@@ -152,28 +152,28 @@ OMX_ERRORTYPE SimpleSoftOMXComponent::internalSetParameter(
OMX_PARAM_PORTDEFINITIONTYPE *defParams =
(OMX_PARAM_PORTDEFINITIONTYPE *)params;
- if (defParams->nPortIndex >= mPorts.size()
- || defParams->nSize
- != sizeof(OMX_PARAM_PORTDEFINITIONTYPE)) {
- return OMX_ErrorUndefined;
+ if (defParams->nPortIndex >= mPorts.size()) {
+ return OMX_ErrorBadPortIndex;
+ }
+ if (defParams->nSize != sizeof(OMX_PARAM_PORTDEFINITIONTYPE)) {
+ return OMX_ErrorUnsupportedSetting;
}
PortInfo *port =
&mPorts.editItemAt(defParams->nPortIndex);
- if (defParams->nBufferSize != port->mDef.nBufferSize) {
- CHECK_GE(defParams->nBufferSize, port->mDef.nBufferSize);
+ // default behavior is that we only allow buffer size to increase
+ if (defParams->nBufferSize > port->mDef.nBufferSize) {
port->mDef.nBufferSize = defParams->nBufferSize;
}
- if (defParams->nBufferCountActual
- != port->mDef.nBufferCountActual) {
- CHECK_GE(defParams->nBufferCountActual,
- port->mDef.nBufferCountMin);
-
- port->mDef.nBufferCountActual = defParams->nBufferCountActual;
+ if (defParams->nBufferCountActual < port->mDef.nBufferCountMin) {
+ ALOGW("component requires at least %u buffers (%u requested)",
+ port->mDef.nBufferCountMin, defParams->nBufferCountActual);
+ return OMX_ErrorUnsupportedSetting;
}
+ port->mDef.nBufferCountActual = defParams->nBufferCountActual;
return OMX_ErrorNone;
}