summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/OMXCodec.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-10-18 16:21:52 -0700
committerJames Dong <jdong@google.com>2011-10-18 16:27:53 -0700
commit5e69eb97b0e5e70919f61099bcc5bdbb1db0861c (patch)
tree5f6ddc1a6f1a9f60afd1e7c078b9bd0b63d42da3 /media/libstagefright/OMXCodec.cpp
parent3c57859f03ce9257128e3b2cd29a906b8f9a6aa5 (diff)
downloadframeworks_av-5e69eb97b0e5e70919f61099bcc5bdbb1db0861c.zip
frameworks_av-5e69eb97b0e5e70919f61099bcc5bdbb1db0861c.tar.gz
frameworks_av-5e69eb97b0e5e70919f61099bcc5bdbb1db0861c.tar.bz2
Bail out after kMaxColorFormatSupported calls to OMX_GetParameter().
Avoid infinite loop in querying omx component about the supported color format. Change-Id: I4997efd36462c792a6d8b5e04c79a80966a559fe related-to-bug: 5466057
Diffstat (limited to 'media/libstagefright/OMXCodec.cpp')
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 7c34257..7b7078a 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -52,6 +52,13 @@ namespace android {
// buffers after 3 seconds.
const static int64_t kBufferFilledEventTimeOutNs = 3000000000LL;
+// OMX Spec defines less than 50 color formats. If the query for
+// color format is executed for more than kMaxColorFormatSupported,
+// the query will fail to avoid looping forever.
+// 1000 is more than enough for us to tell whether the omx
+// component in question is buggy or not.
+const static uint32_t kMaxColorFormatSupported = 1000;
+
struct CodecInfo {
const char *mime;
const char *codec;
@@ -818,6 +825,11 @@ status_t OMXCodec::setVideoPortFormatType(
}
++index;
+ if (index >= kMaxColorFormatSupported) {
+ CODEC_LOGE("color format %d or compression format %d is not supported",
+ colorFormat, compressionFormat);
+ return UNKNOWN_ERROR;
+ }
}
if (!found) {
@@ -901,22 +913,19 @@ status_t OMXCodec::isColorFormatSupported(
// the incremented index (bug 2897413).
CHECK_EQ(index, portFormat.nIndex);
if (portFormat.eColorFormat == colorFormat) {
- LOGV("Found supported color format: %d", portFormat.eColorFormat);
+ CODEC_LOGV("Found supported color format: %d", portFormat.eColorFormat);
return OK; // colorFormat is supported!
}
++index;
portFormat.nIndex = index;
- // OMX Spec defines less than 50 color formats
- // 1000 is more than enough for us to tell whether the omx
- // component in question is buggy or not.
- if (index >= 1000) {
- LOGE("More than %ld color formats are supported???", index);
+ if (index >= kMaxColorFormatSupported) {
+ CODEC_LOGE("More than %ld color formats are supported???", index);
break;
}
}
- LOGE("color format %d is not supported", colorFormat);
+ CODEC_LOGE("color format %d is not supported", colorFormat);
return UNKNOWN_ERROR;
}