Bug 846465 - Fix OMX plugin crash on HTC One X r=doublec a=lsblakk
authorEdwin Flores <eflores@mozilla.com>
Tue, 26 Mar 2013 10:44:09 +1300
changeset 127789 5573b93cd43ddf10bcaaac7987261a4d0c43bc37
parent 127788 1802d450878a4a595b01d12a00cd8703c503d6ce
child 127790 116acfdc505999c92eb91785d05c7733515640ec
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersdoublec, lsblakk
bugs846465
milestone20.0
Bug 846465 - Fix OMX plugin crash on HTC One X r=doublec a=lsblakk
content/media/plugins/MediaPluginHost.cpp
media/omx-plugin/OmxPlugin.cpp
media/omx-plugin/jb-htc/Makefile.in
media/omx-plugin/jb-htc/OmxPluginJB-HTC.cpp
media/omx-plugin/jb-htc/moz.build
mobile/android/installer/package-manifest.in
toolkit/mozapps/installer/packager.mk
toolkit/toolkit-tiers.mk
--- a/content/media/plugins/MediaPluginHost.cpp
+++ b/content/media/plugins/MediaPluginHost.cpp
@@ -158,17 +158,26 @@ static const char* GetOmxLibraryName()
   }
 
   nsAutoString device;
   rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("device"), device);
   if (NS_SUCCEEDED(rv)) {
     ALOG("Android Device is: %s", NS_LossyConvertUTF16toASCII(device).get());
   }
 
-  if (version == 15 &&
+  nsAutoString manufacturer;
+  rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("manufacturer"), manufacturer);
+  if (NS_SUCCEEDED(rv)) {
+    ALOG("Android Manufacturer is: %s", NS_LossyConvertUTF16toASCII(manufacturer).get());
+  }
+
+  if (version >= 16 && manufacturer.Find("HTC") == 0) {
+    return "libomxpluginjb-htc.so";
+  }
+  else if (version == 15 &&
       (device.Find("LT28", false) == 0 ||
        device.Find("LT26", false) == 0 ||
        device.Find("LT22", false) == 0 ||
        device.Find("IS12", false) == 0 ||
        device.Find("MT27", false) == 0)) {
     // Sony Ericsson devices running ICS
     return "lib/libomxpluginsony.so";
   }
--- a/media/omx-plugin/OmxPlugin.cpp
+++ b/media/omx-plugin/OmxPlugin.cpp
@@ -53,16 +53,24 @@ public:
 
   virtual ~MediaStreamSource();
 
 private:
   Decoder *mDecoder;
 
   MediaStreamSource(const MediaStreamSource &);
   MediaStreamSource &operator=(const MediaStreamSource &);
+
+#ifdef MOZ_ANDROID_HTC_WORKAROUND
+  // libstagefright on some Jellybean HTC devices (at least the Tegra 3 One X)
+  // call this function and expect this magic number to be returned when
+  // sniffing audio stream formats.
+  // It is unclear what this is for or what it does.
+  virtual uint32_t MagicalHTCIncantation() { return 0x3f0; }
+#endif
 };
 
 MediaStreamSource::MediaStreamSource(PluginHost *aPluginHost, Decoder *aDecoder) :
   mPluginHost(aPluginHost)
 {
   mDecoder = aDecoder;
 }
 
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/jb-htc/Makefile.in
@@ -0,0 +1,67 @@
+# Copyright 2012 Mozilla Foundation and Mozilla contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEPTH   = @DEPTH@
+topsrcdir = @top_srcdir@
+srcdir    = @srcdir@
+VPATH   = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = omxpluginjb-htc
+MODULE_NAME = omxpluginjb-htc
+LIBRARY_NAME = omxpluginjb-htc
+FORCE_SHARED_LIB = 1
+
+# Don't use STL wrappers; this isn't Gecko code
+STL_FLAGS =
+
+# must link statically with the CRT; this isn't Gecko code
+USE_STATIC_LIBS = 1
+
+# Need to custom install OMX media plugin
+NO_DIST_INSTALL = 1
+NO_INSTALL = 1
+
+CPPSRCS = \
+    OmxPluginJB-HTC.cpp \
+    $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+ifdef GNU_CXX
+# Turn off C++ 11 features due to conflicts with Android OS headers and char16_t definition
+CXXFLAGS += -std=gnu++98
+endif
+
+INCLUDES        += \
+                -I$(srcdir)/../../../content/media/plugins \
+                $(NULL)
+
+EXTRA_DSO_LDOPTS += \
+		-L$(DEPTH)/media/omx-plugin/lib/ics/libutils \
+		-lutils \
+		-L$(DEPTH)/media/omx-plugin/lib/ics/libstagefright \
+		-lstagefright \
+		$(NULL)
+
+INCLUDES        += \
+                -I$(srcdir)/../include/ics \
+                -I$(srcdir)/../include/ics/media/stagefright/openmax \
+                $(NULL)
+
+libs::	$(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
+	$(INSTALL) $< $(DEPTH)/dist/bin
+
+libs:: $(PROGRAMS)
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/jb-htc/OmxPluginJB-HTC.cpp
@@ -0,0 +1,9 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+#define MOZ_STAGEFRIGHT_OFF_T off64_t
+#define MOZ_ANDROID_ICS
+#define MOZ_ANDROID_HTC_WORKAROUND
+#include "../OmxPlugin.cpp"
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/jb-htc/moz.build
@@ -0,0 +1,7 @@
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+MODULE = 'omxpluginjb-htc'
+
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -40,16 +40,17 @@
 @BINPATH@/@DLL_PREFIX@xpcom@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@mozglue@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxplugin@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxplugingb@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxplugingb235@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxpluginhc@DLL_SUFFIX@
+@BINPATH@/@DLL_PREFIX@omxpluginjb-htc@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxpluginsony@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxpluginfroyo@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
 @BINPATH@/@MOZ_CHILD_PROCESS_NAME@
 
 @BINPATH@/AndroidManifest.xml
 @BINPATH@/resources.arsc
 @BINPATH@/package-name.txt
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -343,17 +343,17 @@ INNER_ROBOCOP_PACKAGE= \
   $(JARSIGNER) $(_ABS_DIST)/robocop-raw.apk && \
   $(ZIPALIGN) -f -v 4 $(_ABS_DIST)/robocop-raw.apk $(_ABS_DIST)/robocop.apk
 endif
 else
 INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Robocop for you'
 endif
 
 ifdef MOZ_OMX_PLUGIN
-OMX_PLUGIN_NAMES = libomxplugin.so libomxplugingb.so libomxplugingb235.so libomxpluginhc.so libomxpluginsony.so libomxpluginfroyo.so
+OMX_PLUGIN_NAMES = libomxplugin.so libomxplugingb.so libomxplugingb235.so libomxpluginhc.so libomxpluginsony.so libomxpluginfroyo.so libomxpluginjb-htc.so
 else
 OMX_PLUGIN_NAMES =
 endif
 
 PKG_SUFFIX      = .apk
 INNER_MAKE_PACKAGE	= \
   $(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib:.so=.sz) && mv $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib:.so=.sz) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && ) \
   make -C $(GECKO_APP_AP_PATH) gecko.ap_ && \
@@ -384,16 +384,17 @@ INNER_UNMAKE_PACKAGE	= \
   $(UNZIP) $(UNPACKAGE) && \
   mv lib/$(ABI_DIR)/libmozglue.so . && \
   mv lib/$(ABI_DIR)/libomxplugin.so . && \
   mv lib/$(ABI_DIR)/libomxplugingb.so . && \
   mv lib/$(ABI_DIR)/libomxplugingb235.so . && \
   mv lib/$(ABI_DIR)/libomxpluginhc.so . && \
   mv lib/$(ABI_DIR)/libomxpluginsony.so . && \
   mv lib/$(ABI_DIR)/libomxpluginfroyo.so . && \
+  mv lib/$(ABI_DIR)/libomxpluginjb-htc.so . && \
   mv lib/$(ABI_DIR)/*plugin-container* $(MOZ_CHILD_PROCESS_NAME) && \
   rm -rf lib/$(ABI_DIR) && \
   popd
 endif
 
 ifeq ($(MOZ_PKG_FORMAT),DMG)
 PKG_SUFFIX	= .dmg
 PKG_DMG_FLAGS	=
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -173,16 +173,17 @@ tier_platform_dirs += \
 		media/omx-plugin/lib/froyo/libstagefright \
 		media/omx-plugin \
 		media/omx-plugin/gb \
 		media/omx-plugin/gb235 \
 		media/omx-plugin/froyo \
 		media/omx-plugin/lib/hc/libstagefright \
 		media/omx-plugin/hc \
 		media/omx-plugin/sony \
+		media/omx-plugin/jb-htc \
 		$(NULL)
 endif
 
 ifndef MOZ_NATIVE_PNG
 tier_platform_dirs += media/libpng
 endif
 
 ifdef ENABLE_TESTS