summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MediaCodecList.cpp
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-08-11 16:46:15 -0700
committerLajos Molnar <lajos@google.com>2014-08-12 09:29:29 -0700
commit6ff58f04f78886b07c72c0118eb71a78d08f5651 (patch)
tree99652bd3f5349e5cd8c55c261e7e06b65fc06ea1 /media/libstagefright/MediaCodecList.cpp
parente7a1737c92cf2e84754ffbc52cfec8edeffcbc75 (diff)
downloadframeworks_av-6ff58f04f78886b07c72c0118eb71a78d08f5651.zip
frameworks_av-6ff58f04f78886b07c72c0118eb71a78d08f5651.tar.gz
frameworks_av-6ff58f04f78886b07c72c0118eb71a78d08f5651.tar.bz2
MediaCodecList: handle errors gracefully
Handle missing OMX codecs, and codecs that do not load. Fix NULL dereference when initializing codec with no type. Bug: 16907578 Bug: 16905025 Change-Id: I5d103db36ebb029d1aab03222bf6e9324beb1566
Diffstat (limited to 'media/libstagefright/MediaCodecList.cpp')
-rw-r--r--media/libstagefright/MediaCodecList.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index 7f8b7f5..2f2a0b3 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -482,11 +482,21 @@ status_t MediaCodecList::addMediaCodecFromAttributes(
}
mCurrentInfo = new MediaCodecInfo(name, encoder, type);
- mCodecInfos.push_back(mCurrentInfo);
- return initializeCapabilities(type);
+ // The next step involves trying to load the codec, which may
+ // fail. Only list the codec if this succeeds.
+ // However, keep mCurrentInfo object around until parsing
+ // of full codec info is completed.
+ if (initializeCapabilities(type) == OK) {
+ mCodecInfos.push_back(mCurrentInfo);
+ }
+ return OK;
}
status_t MediaCodecList::initializeCapabilities(const char *type) {
+ if (type == NULL) {
+ return OK;
+ }
+
ALOGV("initializeCapabilities %s:%s",
mCurrentInfo->mName.c_str(), type);
@@ -553,10 +563,16 @@ status_t MediaCodecList::addTypeFromAttributes(const char **attrs) {
}
status_t ret = mCurrentInfo->addMime(name);
- if (ret == OK) {
- ret = initializeCapabilities(name);
+ if (ret != OK) {
+ return ret;
}
- return ret;
+
+ // The next step involves trying to load the codec, which may
+ // fail. Handle this gracefully (by not reporting such mime).
+ if (initializeCapabilities(name) != OK) {
+ mCurrentInfo->removeMime(name);
+ }
+ return OK;
}
// legacy method for non-advanced codecs