From 6f9439efd2a6004b588605f6a9d4af20c98e8e80 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Wed, 4 Sep 2013 15:00:07 -0700 Subject: [PATCH] Better workaround for slow decoders. This is more in the spirit of the original code. Now it checks whether a codec instantiated by name is a video codec, and enables the extra looper if so. b/10528409 Change-Id: Ia253c04c1283d4ecf66f213ef4bf523279ad7cca --- media/libstagefright/MediaCodec.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 66a0b4e06f..e0686be2d8 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -104,10 +105,24 @@ status_t MediaCodec::init(const char *name, bool nameIsType, bool encoder) { bool needDedicatedLooper = false; if (nameIsType && !strncasecmp(name, "video/", 6)) { needDedicatedLooper = true; - } else if (!nameIsType && !strncmp(name, "OMX.TI.DUCATI1.VIDEO.", 21)) { - needDedicatedLooper = true; - } else if (!nameIsType && !strncmp(name, "OMX.qcom.video.decoder.avc.secure", 33)) { - needDedicatedLooper = true; + } else { + AString tmp = name; + if (tmp.endsWith(".secure")) { + tmp.erase(tmp.size() - 7, 7); + } + const MediaCodecList *mcl = MediaCodecList::getInstance(); + ssize_t codecIdx = mcl->findCodecByName(tmp.c_str()); + if (codecIdx >= 0) { + Vector types; + if (mcl->getSupportedTypes(codecIdx, &types) == OK) { + for (int i = 0; i < types.size(); i++) { + if (types[i].startsWith("video/")) { + needDedicatedLooper = true; + break; + } + } + } + } } if (needDedicatedLooper) { -- 2.11.0