summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-08-12 17:05:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-12 16:54:46 +0000
commitd018b8ffd84452a7a4b992b5325713b3256e48ff (patch)
treea338c848af9b637f9879a7f0293d0fafbfef4489
parent2461e0cf6ae3fe5c9b52ce9e3ac764f4aff5e5eb (diff)
parent6ff58f04f78886b07c72c0118eb71a78d08f5651 (diff)
downloadframeworks_av-d018b8ffd84452a7a4b992b5325713b3256e48ff.zip
frameworks_av-d018b8ffd84452a7a4b992b5325713b3256e48ff.tar.gz
frameworks_av-d018b8ffd84452a7a4b992b5325713b3256e48ff.tar.bz2
Merge "MediaCodecList: handle errors gracefully" into lmp-dev
-rw-r--r--include/media/MediaCodecInfo.h1
-rw-r--r--media/libmedia/MediaCodecInfo.cpp8
-rw-r--r--media/libstagefright/MediaCodecList.cpp26
3 files changed, 30 insertions, 5 deletions
diff --git a/include/media/MediaCodecInfo.h b/include/media/MediaCodecInfo.h
index b4916af..ab7a4b8 100644
--- a/include/media/MediaCodecInfo.h
+++ b/include/media/MediaCodecInfo.h
@@ -107,6 +107,7 @@ private:
status_t initializeCapabilities(const CodecCapabilities &caps);
void addDetail(const AString &key, const AString &value);
void addFeature(const AString &key, int32_t value);
+ void removeMime(const char *mime);
void complete();
DISALLOW_EVIL_CONSTRUCTORS(MediaCodecInfo);
diff --git a/media/libmedia/MediaCodecInfo.cpp b/media/libmedia/MediaCodecInfo.cpp
index 5ea0519..446c582 100644
--- a/media/libmedia/MediaCodecInfo.cpp
+++ b/media/libmedia/MediaCodecInfo.cpp
@@ -206,6 +206,14 @@ status_t MediaCodecInfo::addMime(const char *mime) {
return OK;
}
+void MediaCodecInfo::removeMime(const char *mime) {
+ ssize_t ix = getCapabilityIndex(mime);
+ if (ix >= 0) {
+ mCaps.removeItemsAt(ix);
+ // mCurrentCaps will be removed when completed
+ }
+}
+
status_t MediaCodecInfo::initializeCapabilities(const CodecCapabilities &caps) {
mCurrentCaps->mProfileLevels.clear();
mCurrentCaps->mColorFormats.clear();
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