From bbee0cfc684f60c617ba7488818da1160587a883 Mon Sep 17 00:00:00 2001 From: Eugen Sawin Date: Thu, 23 Jun 2016 15:25:10 +0200 Subject: [PATCH] Bug 1278574 - [1.3] Allow only a single media decoder (pair) on Android 4.2 and earlier. r=jya,snorp --- dom/media/MediaDecoderReader.cpp | 1 - dom/media/MediaPrefs.h | 21 ++++++++++++++++++++- layout/build/nsLayoutStatics.cpp | 1 - 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index 98c914fafde1..b18c4f0a555b 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -16,7 +16,6 @@ #include "mozilla/Mutex.h" #include #include -#include using namespace mozilla::media; diff --git a/dom/media/MediaPrefs.h b/dom/media/MediaPrefs.h index 05c542abb202..edbeb4185703 100644 --- a/dom/media/MediaPrefs.h +++ b/dom/media/MediaPrefs.h @@ -6,6 +6,10 @@ #ifndef MEDIA_PREFS_H #define MEDIA_PREFS_H +#ifdef MOZ_WIDGET_ANDROID +#include "AndroidBridge.h" +#endif + // First time MediaPrefs::GetSingleton() needs to be called on the main thread, // before any of the methods accessing the values are used, but after // the Preferences system has been initialized. @@ -121,7 +125,7 @@ private: DECL_MEDIA_PREF("media.webspeech.recognition.force_enable", WebSpeechRecognitionForceEnabled, bool, false); DECL_MEDIA_PREF("media.num-decode-threads", MediaThreadPoolDefaultCount, uint32_t, 4); - DECL_MEDIA_PREF("media.decoder.limit", MediaDecoderLimit, uint32_t, -1); + DECL_MEDIA_PREF("media.decoder.limit", MediaDecoderLimit, int32_t, MediaDecoderLimitDefault()); public: // Manage the singleton: @@ -132,6 +136,21 @@ private: template friend class StaticAutoPtr; static StaticAutoPtr sInstance; + // Default value functions + static int32_t MediaDecoderLimitDefault() + { +#ifdef MOZ_WIDGET_ANDROID + if (AndroidBridge::Bridge() && + AndroidBridge::Bridge()->GetAPIVersion() < 18) { + // Older Android versions have broken support for multiple simultaneous + // decoders, see bug 1278574. + return 1; + } +#endif + // Otherwise, set no decoder limit. + return -1; + } + // Creating these to avoid having to include Preferences.h in the .h static void PrefAddVarCache(bool*, const char*, bool); static void PrefAddVarCache(int32_t*, const char*, int32_t); diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index 99e05c4d9b95..d7b3045f2627 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -309,7 +309,6 @@ nsLayoutStatics::Initialize() #endif MediaDecoder::InitStatics(); - MediaPrefs::GetSingleton(); PromiseDebugging::Init();