Bug 1278574 - [1.3] Allow only a single media decoder (pair) on Android 4.2 and earlier. r=jya,snorp

This commit is contained in:
Eugen Sawin 2016-06-23 15:25:10 +02:00
parent ea2b81ece8
commit bbee0cfc68
3 changed files with 20 additions and 3 deletions

View File

@ -16,7 +16,6 @@
#include "mozilla/Mutex.h"
#include <stdint.h>
#include <algorithm>
#include <list>
using namespace mozilla::media;

View File

@ -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<class T> friend class StaticAutoPtr;
static StaticAutoPtr<MediaPrefs> 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);

View File

@ -309,7 +309,6 @@ nsLayoutStatics::Initialize()
#endif
MediaDecoder::InitStatics();
MediaPrefs::GetSingleton();
PromiseDebugging::Init();