mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1206637: P2. Replace all cached preferences with MediaPrefs ones. r=cpearce
Additionally, clean up stray and unused Preferences.h header. MozReview-Commit-ID: IcPrD2inkDE --HG-- extra : rebase_source : c3c6e37767627db3601090c2855a3dfa98cb4368
This commit is contained in:
parent
e926d54268
commit
d31cb0499b
@ -9,7 +9,6 @@
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaFormatReader.h"
|
||||
#include "MP3Demuxer.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "PDMFactory.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -168,8 +168,6 @@ MediaFormatReader::InitLayersBackendType()
|
||||
mLayersBackendType = layerManager->GetCompositorBackendType();
|
||||
}
|
||||
|
||||
static bool sIsEMEEnabled = false;
|
||||
|
||||
nsresult
|
||||
MediaFormatReader::Init()
|
||||
{
|
||||
@ -183,12 +181,6 @@ MediaFormatReader::Init()
|
||||
mVideo.mTaskQueue =
|
||||
new FlushableTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
|
||||
|
||||
static bool sSetupPrefCache = false;
|
||||
if (!sSetupPrefCache) {
|
||||
sSetupPrefCache = true;
|
||||
Preferences::AddBoolVarCache(&sIsEMEEnabled, "media.eme.enabled", false);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
||||
#include "mozilla/dom/GetUserMediaRequestBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/media/MediaChild.h"
|
||||
|
@ -32,6 +32,10 @@ static const char* Get##Name##PrefName() { return Pref; } \
|
||||
static Type Get##Name##PrefDefault() { return Default; } \
|
||||
PrefTemplate<Type, Get##Name##PrefDefault, Get##Name##PrefName> mPref##Name
|
||||
|
||||
// Custom Definitions.
|
||||
#define GMP_DEFAULT_ASYNC_SHUTDOWN_TIMEOUT 3000
|
||||
#define TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE "media.webspeech.test.fake_recognition_service"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
template<class T> class StaticAutoPtr;
|
||||
@ -60,16 +64,52 @@ private:
|
||||
};
|
||||
|
||||
// This is where DECL_MEDIA_PREF for each of the preferences should go.
|
||||
// We will keep these in an alphabetical order to make it easier to see if
|
||||
// a method accessing a pref already exists. Just add yours in the list.
|
||||
DECL_MEDIA_PREF("accessibility.monoaudio.enable", MonoAudio, bool, false);
|
||||
DECL_MEDIA_PREF("media.resampling.enabled", AudioSinkResampling, bool, false);
|
||||
DECL_MEDIA_PREF("media.resampling.rate", AudioSinkResampleRate, uint32_t, 48000);
|
||||
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, true);
|
||||
|
||||
// WARNING:
|
||||
// Please make sure that you've added your new preference to the list above in alphabetical order.
|
||||
// Please do not just append it to the end of the list.
|
||||
// AudioSink
|
||||
DECL_MEDIA_PREF("accessibility.monoaudio.enable", MonoAudio, bool, false);
|
||||
DECL_MEDIA_PREF("media.resampling.enabled", AudioSinkResampling, bool, false);
|
||||
DECL_MEDIA_PREF("media.resampling.rate", AudioSinkResampleRate, uint32_t, 48000);
|
||||
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, true);
|
||||
|
||||
// PlatformDecoderModule
|
||||
DECL_MEDIA_PREF("media.apple.forcevda", AppleForceVDA, bool, false);
|
||||
DECL_MEDIA_PREF("media.gmp.insecure.allow", GMPAllowInsecure, bool, false);
|
||||
DECL_MEDIA_PREF("media.gmp.async-shutdown-timeout", GMPAsyncShutdownTimeout, uint32_t, GMP_DEFAULT_ASYNC_SHUTDOWN_TIMEOUT);
|
||||
DECL_MEDIA_PREF("media.eme.enabled", EMEEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.use-blank-decoder", PDMUseBlankDecoder, bool, false);
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
DECL_MEDIA_PREF("media.gonk.enabled", PDMGonkDecoderEnabled, bool, true);
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
DECL_MEDIA_PREF("media.android-media-codec.enabled", PDMAndroidMediaCodecEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.android-media-codec.preferred", PDMAndroidMediaCodecPreferred, bool, false);
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
DECL_MEDIA_PREF("media.ffmpeg.enabled", PDMFFmpegEnabled, bool, true);
|
||||
#endif
|
||||
#ifdef MOZ_FFVPX
|
||||
DECL_MEDIA_PREF("media.ffvpx.enabled", PDMFFVPXEnabled, bool, true);
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
DECL_MEDIA_PREF("media.wmf.enabled", PDMWMFEnabled, bool, true);
|
||||
DECL_MEDIA_PREF("media.webm.intel_decoder.enabled", PDMWMFIntelDecoderEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1);
|
||||
#endif
|
||||
DECL_MEDIA_PREF("media.decoder.fuzzing.enabled", PDMFuzzingEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0);
|
||||
DECL_MEDIA_PREF("media.decoder.fuzzing.dont-delay-inputexhausted", PDMFuzzingDelayInputExhausted, bool, true);
|
||||
DECL_MEDIA_PREF("media.gmp.decoder.enabled", PDMGMPEnabled, bool, true);
|
||||
DECL_MEDIA_PREF("media.gmp.decoder.aac", GMPAACPreferred, uint32_t, 0);
|
||||
DECL_MEDIA_PREF("media.gmp.decoder.h264", GMPH264Preferred, uint32_t, 0);
|
||||
|
||||
// WebSpeech
|
||||
DECL_MEDIA_PREF("media.webspeech.synth.force_global_queue", WebSpeechForceGlobal, bool, false);
|
||||
DECL_MEDIA_PREF("media.webspeech.test.enable", WebSpeechTestEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.webspeech.test.fake_fsm_events", WebSpeechFakeFSMEvents, bool, false);
|
||||
DECL_MEDIA_PREF(TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE, WebSpeechFakeRecognitionService, bool, false);
|
||||
DECL_MEDIA_PREF("media.webspeech.recognition.enable", WebSpeechRecognitionEnabled, bool, false);
|
||||
DECL_MEDIA_PREF("media.webspeech.recognition.force_enable", WebSpeechRecognitionForceEnabled, bool, false);
|
||||
|
||||
public:
|
||||
// Manage the singleton:
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "mozilla/dom/MediaKeySystemAccess.h"
|
||||
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "nsContentTypeParser.h"
|
||||
#ifdef MOZ_FMP4
|
||||
#include "MP4Decoder.h"
|
||||
@ -261,7 +262,7 @@ MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
|
||||
nsACString& aOutMessage,
|
||||
nsACString& aOutCdmVersion)
|
||||
{
|
||||
MOZ_ASSERT(Preferences::GetBool("media.eme.enabled", false));
|
||||
MOZ_ASSERT(MediaPrefs::EMEEnabled());
|
||||
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
||||
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
||||
if (NS_WARN_IF(!mps)) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "MediaKeySystemAccessManager.h"
|
||||
#include "DecoderDoctorDiagnostics.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "mozilla/EMEUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -97,7 +97,7 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Preferences::GetBool("media.eme.enabled", false)) {
|
||||
if (!MediaPrefs::EMEEnabled()) {
|
||||
// EME disabled by user, send notification to chrome so UI can inform user.
|
||||
MediaKeySystemAccess::NotifyObservers(mWindow,
|
||||
aKeySystem,
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "mozilla/EMEUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsContentTypeParser.h"
|
||||
#ifdef MOZ_FMP4
|
||||
#include "MP4Decoder.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/SandboxInfo.h"
|
||||
#endif
|
||||
#include "GMPContentParent.h"
|
||||
#include "MediaPrefs.h"
|
||||
|
||||
#include "mozilla/dom/CrashReporterParent.h"
|
||||
using mozilla::dom::CrashReporterParent;
|
||||
@ -252,7 +253,7 @@ GMPParent::EnsureAsyncShutdownTimeoutSet()
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t timeout = GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT;
|
||||
int32_t timeout = MediaPrefs::GMPAsyncShutdownTimeout();
|
||||
RefPtr<GeckoMediaPluginServiceParent> service =
|
||||
GeckoMediaPluginServiceParent::GetSingleton();
|
||||
if (service) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "GMPVideoDecoderParent.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "GeckoChildProcessHost.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
@ -24,7 +23,6 @@
|
||||
#include "GMPDecryptorParent.h"
|
||||
#include "GMPAudioDecoderParent.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "runnable_utils.h"
|
||||
#include "VideoUtils.h"
|
||||
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
||||
|
@ -31,8 +31,6 @@ namespace gmp {
|
||||
|
||||
class GetGMPContentParentCallback;
|
||||
|
||||
#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000
|
||||
|
||||
class GeckoMediaPluginService : public mozIGeckoMediaPluginService
|
||||
, public nsIObserver
|
||||
{
|
||||
|
@ -15,8 +15,6 @@
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000
|
||||
|
||||
class GMPContentParent;
|
||||
class GMPServiceChild;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "GMPDecryptorParent.h"
|
||||
#include "GMPAudioDecoderParent.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "runnable_utils.h"
|
||||
#include "VideoUtils.h"
|
||||
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
||||
@ -41,6 +40,7 @@
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "GMPDecoderModule.h"
|
||||
#include <limits>
|
||||
#include "MediaPrefs.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -80,10 +80,6 @@ NS_IMPL_ISUPPORTS_INHERITED(GeckoMediaPluginServiceParent,
|
||||
GeckoMediaPluginService,
|
||||
mozIGeckoMediaPluginChromeService)
|
||||
|
||||
static int32_t sMaxAsyncShutdownWaitMs = 0;
|
||||
static bool sAllowInsecureGMP = false;
|
||||
static bool sHaveSetGMPServiceParentPrefCaches = false;
|
||||
|
||||
GeckoMediaPluginServiceParent::GeckoMediaPluginServiceParent()
|
||||
: mShuttingDown(false)
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
@ -95,14 +91,6 @@ GeckoMediaPluginServiceParent::GeckoMediaPluginServiceParent()
|
||||
, mLoadPluginsFromDiskComplete(false)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!sHaveSetGMPServiceParentPrefCaches) {
|
||||
sHaveSetGMPServiceParentPrefCaches = true;
|
||||
Preferences::AddIntVarCache(&sMaxAsyncShutdownWaitMs,
|
||||
"media.gmp.async-shutdown-timeout",
|
||||
GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT);
|
||||
Preferences::AddBoolVarCache(&sAllowInsecureGMP,
|
||||
"media.gmp.insecure.allow", false);
|
||||
}
|
||||
mInitPromise.SetMonitor(&mInitPromiseMonitor);
|
||||
}
|
||||
|
||||
@ -115,8 +103,7 @@ GeckoMediaPluginServiceParent::~GeckoMediaPluginServiceParent()
|
||||
int32_t
|
||||
GeckoMediaPluginServiceParent::AsyncShutdownTimeoutMs()
|
||||
{
|
||||
MOZ_ASSERT(sHaveSetGMPServiceParentPrefCaches);
|
||||
return sMaxAsyncShutdownWaitMs;
|
||||
return MediaPrefs::GMPAsyncShutdownTimeout();
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1057,7 +1044,7 @@ CreateGMPParent()
|
||||
{
|
||||
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
||||
if (!SandboxInfo::Get().CanSandboxMedia()) {
|
||||
if (!sAllowInsecureGMP) {
|
||||
if (!MediaPrefs::GMPAllowInsecure()) {
|
||||
NS_WARNING("Denying media plugin load due to lack of sandboxing.");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ namespace gmp {
|
||||
|
||||
class GMPParent;
|
||||
|
||||
#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000
|
||||
|
||||
class GeckoMediaPluginServiceParent final : public GeckoMediaPluginService
|
||||
, public mozIGeckoMediaPluginChromeService
|
||||
{
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "GMPVideoEncoderProxy.h"
|
||||
#include "GMPDecryptorProxy.h"
|
||||
#include "GMPServiceParent.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
@ -33,6 +34,7 @@ struct GMPTestRunner
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPTestRunner)
|
||||
|
||||
GMPTestRunner() { MediaPrefs::GetSingleton(); }
|
||||
void DoTest(void (GMPTestRunner::*aTestMethod)(GMPTestMonitor&));
|
||||
void RunTestGMPTestCodec1(GMPTestMonitor& aMonitor);
|
||||
void RunTestGMPTestCodec2(GMPTestMonitor& aMonitor);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "GMPService.h"
|
||||
#include "GMPUtils.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "MediaPrefs.h"
|
||||
|
||||
#define GMP_DIR_NAME NS_LITERAL_STRING("gmp-fakeopenh264")
|
||||
#define GMP_OLD_VERSION NS_LITERAL_STRING("1.0")
|
||||
@ -227,6 +228,8 @@ GMPRemoveTest::~GMPRemoveTest()
|
||||
void
|
||||
GMPRemoveTest::Setup()
|
||||
{
|
||||
// Initialize media preferences.
|
||||
MediaPrefs::GetSingleton();
|
||||
GeneratePlugin();
|
||||
GetService()->GetThread(getter_AddRefs(mGMPThread));
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "GMPUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "MediaPrefs.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -19,6 +20,8 @@ void TestSplitAt(const char* aInput,
|
||||
size_t aNumExpectedTokens,
|
||||
const char* aExpectedTokens[])
|
||||
{
|
||||
// Initialize media preferences.
|
||||
MediaPrefs::GetSingleton();
|
||||
nsCString input(aInput);
|
||||
nsTArray<nsCString> tokens;
|
||||
SplitAt(aDelims, input, tokens);
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaSource.h"
|
||||
#include "MediaSourceResource.h"
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "mozilla/layers/GrallocTextureClient.h"
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Types.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
@ -26,12 +26,12 @@
|
||||
#endif
|
||||
#include "GMPDecoderModule.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TaskQueue.h"
|
||||
|
||||
#include "mozilla/SharedThreadPool.h"
|
||||
|
||||
#include "MediaInfo.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "FuzzingWrapper.h"
|
||||
#include "H264Converter.h"
|
||||
|
||||
@ -49,29 +49,6 @@ namespace mozilla {
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
|
||||
|
||||
bool PDMFactory::sUseBlankDecoder = false;
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
bool PDMFactory::sGonkDecoderEnabled = false;
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
bool PDMFactory::sAndroidMCDecoderEnabled = false;
|
||||
bool PDMFactory::sAndroidMCDecoderPreferred = false;
|
||||
#endif
|
||||
bool PDMFactory::sGMPDecoderEnabled = false;
|
||||
#ifdef MOZ_FFVPX
|
||||
bool PDMFactory::sFFVPXDecoderEnabled = false;
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
bool PDMFactory::sFFmpegDecoderEnabled = false;
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
bool PDMFactory::sWMFDecoderEnabled = false;
|
||||
#endif
|
||||
|
||||
bool PDMFactory::sEnableFuzzingWrapper = false;
|
||||
uint32_t PDMFactory::sVideoOutputMinimumInterval_ms = 0;
|
||||
bool PDMFactory::sDontDelayInputExhausted = false;
|
||||
|
||||
/* static */
|
||||
void
|
||||
PDMFactory::Init()
|
||||
@ -83,40 +60,8 @@ PDMFactory::Init()
|
||||
}
|
||||
alreadyInitialized = true;
|
||||
|
||||
Preferences::AddBoolVarCache(&sUseBlankDecoder,
|
||||
"media.use-blank-decoder", false);
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
Preferences::AddBoolVarCache(&sGonkDecoderEnabled,
|
||||
"media.gonk.enabled", true);
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
Preferences::AddBoolVarCache(&sAndroidMCDecoderEnabled,
|
||||
"media.android-media-codec.enabled", false);
|
||||
Preferences::AddBoolVarCache(&sAndroidMCDecoderPreferred,
|
||||
"media.android-media-codec.preferred", false);
|
||||
#endif
|
||||
|
||||
Preferences::AddBoolVarCache(&sGMPDecoderEnabled,
|
||||
"media.gmp.decoder.enabled", true);
|
||||
#ifdef MOZ_FFMPEG
|
||||
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
|
||||
"media.ffmpeg.enabled", true);
|
||||
#endif
|
||||
#ifdef MOZ_FFVPX
|
||||
Preferences::AddBoolVarCache(&sFFVPXDecoderEnabled,
|
||||
"media.ffvpx.enabled", true);
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
Preferences::AddBoolVarCache(&sWMFDecoderEnabled,
|
||||
"media.wmf.enabled", true);
|
||||
#endif
|
||||
|
||||
Preferences::AddBoolVarCache(&sEnableFuzzingWrapper,
|
||||
"media.decoder.fuzzing.enabled", false);
|
||||
Preferences::AddUintVarCache(&sVideoOutputMinimumInterval_ms,
|
||||
"media.decoder.fuzzing.video-output-minimum-interval-ms", 0);
|
||||
Preferences::AddBoolVarCache(&sDontDelayInputExhausted,
|
||||
"media.decoder.fuzzing.dont-delay-inputexhausted", false);
|
||||
// Ensure MediaPrefs are initialized.
|
||||
MediaPrefs::GetSingleton();
|
||||
|
||||
#ifdef XP_WIN
|
||||
WMFDecoderModule::Init();
|
||||
@ -222,11 +167,11 @@ PDMFactory::CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
|
||||
|
||||
MediaDataDecoderCallback* callback = aCallback;
|
||||
RefPtr<DecoderCallbackFuzzingWrapper> callbackWrapper;
|
||||
if (sEnableFuzzingWrapper) {
|
||||
if (MediaPrefs::PDMFuzzingEnabled()) {
|
||||
callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback);
|
||||
callbackWrapper->SetVideoOutputMinimumInterval(
|
||||
TimeDuration::FromMilliseconds(sVideoOutputMinimumInterval_ms));
|
||||
callbackWrapper->SetDontDelayInputExhausted(sDontDelayInputExhausted);
|
||||
TimeDuration::FromMilliseconds(MediaPrefs::PDMFuzzingInterval()));
|
||||
callbackWrapper->SetDontDelayInputExhausted(!MediaPrefs::PDMFuzzingDelayInputExhausted());
|
||||
callback = callbackWrapper.get();
|
||||
}
|
||||
|
||||
@ -278,7 +223,7 @@ PDMFactory::CreatePDMs()
|
||||
{
|
||||
RefPtr<PlatformDecoderModule> m;
|
||||
|
||||
if (sUseBlankDecoder) {
|
||||
if (MediaPrefs::PDMUseBlankDecoder()) {
|
||||
m = CreateBlankDecoderModule();
|
||||
StartupPDM(m);
|
||||
// The Blank PDM SupportsMimeType reports true for all codecs; the creation
|
||||
@ -288,13 +233,14 @@ PDMFactory::CreatePDMs()
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled) {
|
||||
if(MediaPrefs::PDMAndroidMediaCodecPreferred() &&
|
||||
MediaPrefs::PDMAndroidMediaCodecEnabled()) {
|
||||
m = new AndroidDecoderModule();
|
||||
StartupPDM(m);
|
||||
}
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
if (sWMFDecoderEnabled) {
|
||||
if (MediaPrefs::PDMWMFEnabled()) {
|
||||
m = new WMFDecoderModule();
|
||||
if (!StartupPDM(m)) {
|
||||
mWMFFailedToLoad = true;
|
||||
@ -302,13 +248,13 @@ PDMFactory::CreatePDMs()
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_FFVPX
|
||||
if (sFFVPXDecoderEnabled) {
|
||||
if (MediaPrefs::PDMFFVPXEnabled()) {
|
||||
m = FFVPXRuntimeLinker::CreateDecoderModule();
|
||||
StartupPDM(m);
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
if (sFFmpegDecoderEnabled) {
|
||||
if (MediaPrefs::PDMFFmpegEnabled()) {
|
||||
m = FFmpegRuntimeLinker::CreateDecoderModule();
|
||||
if (!StartupPDM(m)) {
|
||||
mFFmpegFailedToLoad = true;
|
||||
@ -320,13 +266,13 @@ PDMFactory::CreatePDMs()
|
||||
StartupPDM(m);
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
if (sGonkDecoderEnabled) {
|
||||
if (MediaPrefs::PDMGonkDecoderEnabled()) {
|
||||
m = new GonkDecoderModule();
|
||||
StartupPDM(m);
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if(sAndroidMCDecoderEnabled){
|
||||
if(MediaPrefs::PDMAndroidMediaCodecEnabled()){
|
||||
m = new AndroidDecoderModule();
|
||||
StartupPDM(m);
|
||||
}
|
||||
@ -335,7 +281,7 @@ PDMFactory::CreatePDMs()
|
||||
m = new AgnosticDecoderModule();
|
||||
StartupPDM(m);
|
||||
|
||||
if (sGMPDecoderEnabled) {
|
||||
if (MediaPrefs::PDMGMPEnabled()) {
|
||||
m = new GMPDecoderModule();
|
||||
if (!StartupPDM(m)) {
|
||||
mGMPPDMFailedToStartup = true;
|
||||
|
@ -69,29 +69,6 @@ private:
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer);
|
||||
|
||||
// PDM pref caches...
|
||||
static bool sUseBlankDecoder;
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
static bool sGonkDecoderEnabled;
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
static bool sAndroidMCDecoderPreferred;
|
||||
static bool sAndroidMCDecoderEnabled;
|
||||
#endif
|
||||
static bool sGMPDecoderEnabled;
|
||||
#ifdef MOZ_FFVPX
|
||||
static bool sFFVPXDecoderEnabled;
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
static bool sFFmpegDecoderEnabled;
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
static bool sWMFDecoderEnabled;
|
||||
#endif
|
||||
static bool sEnableFuzzingWrapper;
|
||||
static uint32_t sVideoOutputMinimumInterval_ms;
|
||||
static bool sDontDelayInputExhausted;
|
||||
|
||||
nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
|
||||
RefPtr<PlatformDecoderModule> mEMEPDM;
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
#include "GMPAudioDecoder.h"
|
||||
#include "GMPVideoDecoder.h"
|
||||
#include "MediaDataDecoderProxy.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "mozIGeckoMediaPluginService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "gmp-audio-decode.h"
|
||||
#include "gmp-video-decode.h"
|
||||
@ -175,9 +175,6 @@ GMPDecoderModule::UpdateUsableCodecs()
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t sPreferredAacGmp = 0;
|
||||
static uint32_t sPreferredH264Gmp = 0;
|
||||
|
||||
/* static */
|
||||
void
|
||||
GMPDecoderModule::Init()
|
||||
@ -188,11 +185,6 @@ GMPDecoderModule::Init()
|
||||
// SupportsMimeType() we build a table of the codecs which each whitelisted
|
||||
// GMP has and update it when any GMPs are removed or added at runtime.
|
||||
UpdateUsableCodecs();
|
||||
|
||||
Preferences::AddUintVarCache(&sPreferredAacGmp,
|
||||
"media.gmp.decoder.aac", 0);
|
||||
Preferences::AddUintVarCache(&sPreferredH264Gmp,
|
||||
"media.gmp.decoder.h264", 0);
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -201,7 +193,7 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
|
||||
{
|
||||
Maybe<nsCString> rv;
|
||||
if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
|
||||
switch (sPreferredAacGmp) {
|
||||
switch (MediaPrefs::GMPAACPreferred()) {
|
||||
case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break;
|
||||
case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break;
|
||||
default: break;
|
||||
@ -210,7 +202,7 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
|
||||
|
||||
if (aMimeType.EqualsLiteral("video/avc") ||
|
||||
aMimeType.EqualsLiteral("video/mp4")) {
|
||||
switch (sPreferredH264Gmp) {
|
||||
switch (MediaPrefs::GMPH264Preferred()) {
|
||||
case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break;
|
||||
case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break;
|
||||
default: break;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "AppleVTDecoder.h"
|
||||
#include "AppleVTLinker.h"
|
||||
#include "MacIOSurfaceImage.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
@ -23,7 +23,6 @@ bool AppleDecoderModule::sIsCoreMediaAvailable = false;
|
||||
bool AppleDecoderModule::sIsVTAvailable = false;
|
||||
bool AppleDecoderModule::sIsVTHWAvailable = false;
|
||||
bool AppleDecoderModule::sIsVDAAvailable = false;
|
||||
bool AppleDecoderModule::sForceVDA = false;
|
||||
bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true;
|
||||
|
||||
AppleDecoderModule::AppleDecoderModule()
|
||||
@ -44,8 +43,6 @@ AppleDecoderModule::Init()
|
||||
return;
|
||||
}
|
||||
|
||||
Preferences::AddBoolVarCache(&sForceVDA, "media.apple.forcevda", false);
|
||||
|
||||
// Ensure IOSurface framework is loaded.
|
||||
MacIOSurfaceLib::LoadLibrary();
|
||||
const bool loaded = MacIOSurfaceLib::isInit();
|
||||
@ -88,7 +85,7 @@ AppleDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
|
||||
{
|
||||
RefPtr<MediaDataDecoder> decoder;
|
||||
|
||||
if (sIsVDAAvailable && (!sIsVTHWAvailable || sForceVDA)) {
|
||||
if (sIsVDAAvailable && (!sIsVTHWAvailable || MediaPrefs::AppleForceVDA())) {
|
||||
decoder =
|
||||
AppleVDADecoder::CreateVDADecoder(aConfig,
|
||||
aVideoTaskQueue,
|
||||
|
@ -50,7 +50,6 @@ private:
|
||||
static bool sIsVTAvailable;
|
||||
static bool sIsVTHWAvailable;
|
||||
static bool sIsVDAAvailable;
|
||||
static bool sForceVDA;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "GonkDecoderModule.h"
|
||||
#include "GonkVideoDecoderManager.h"
|
||||
#include "GonkAudioDecoderManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "GonkMediaDataDecoder.h"
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "WMFVideoMFTManager.h"
|
||||
#include "WMFAudioMFTManager.h"
|
||||
#include "MFTDecoder.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "WMFMediaDataDecoder.h"
|
||||
@ -21,6 +20,7 @@
|
||||
#include "GfxDriverInfo.h"
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include "MediaInfo.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "prsystem.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
@ -28,9 +28,6 @@
|
||||
namespace mozilla {
|
||||
|
||||
static bool sDXVAEnabled = false;
|
||||
static int sNumDecoderThreads = -1;
|
||||
static bool sIsIntelDecoderEnabled = false;
|
||||
static bool sLowLatencyMFTEnabled = false;
|
||||
|
||||
WMFDecoderModule::WMFDecoderModule()
|
||||
: mWMFInitialized(false)
|
||||
@ -45,49 +42,30 @@ WMFDecoderModule::~WMFDecoderModule()
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetNumOfDecoderThreads()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Preferences can only be read on main thread");
|
||||
int32_t numCores = PR_GetNumberOfProcessors();
|
||||
|
||||
// If we have more than 4 cores, let the decoder decide how many threads.
|
||||
// On an 8 core machine, WMF chooses 4 decoder threads
|
||||
const int WMF_DECODER_DEFAULT = -1;
|
||||
int32_t prefThreadCount = Preferences::GetInt("media.wmf.decoder.thread-count", -1);
|
||||
if (prefThreadCount != WMF_DECODER_DEFAULT) {
|
||||
sNumDecoderThreads = std::max(prefThreadCount, 1);
|
||||
} else if (numCores > 4) {
|
||||
sNumDecoderThreads = WMF_DECODER_DEFAULT;
|
||||
} else {
|
||||
sNumDecoderThreads = std::max(numCores - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
WMFDecoderModule::Init()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
sDXVAEnabled = gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding();
|
||||
Preferences::AddBoolVarCache(&sIsIntelDecoderEnabled,
|
||||
"media.webm.intel_decoder.enabled");
|
||||
sLowLatencyMFTEnabled = Preferences::GetBool("media.wmf.low-latency.enabled", false);
|
||||
SetNumOfDecoderThreads();
|
||||
}
|
||||
|
||||
/* static */
|
||||
int
|
||||
WMFDecoderModule::GetNumDecoderThreads()
|
||||
{
|
||||
return sNumDecoderThreads;
|
||||
}
|
||||
int32_t numCores = PR_GetNumberOfProcessors();
|
||||
|
||||
/* static */
|
||||
bool
|
||||
WMFDecoderModule::LowLatencyMFTEnabled()
|
||||
{
|
||||
return sLowLatencyMFTEnabled;
|
||||
// If we have more than 4 cores, let the decoder decide how many threads.
|
||||
// On an 8 core machine, WMF chooses 4 decoder threads
|
||||
const int WMF_DECODER_DEFAULT = -1;
|
||||
int32_t prefThreadCount = MediaPrefs::PDMWMFThreadCount();
|
||||
if (prefThreadCount != WMF_DECODER_DEFAULT) {
|
||||
return std::max(prefThreadCount, 1);
|
||||
} else if (numCores > 4) {
|
||||
return WMF_DECODER_DEFAULT;
|
||||
}
|
||||
return std::max(numCores - 1, 1);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -232,7 +210,7 @@ WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType,
|
||||
CanCreateWMFDecoder<CLSID_CMP3DecMediaObject>()) {
|
||||
return true;
|
||||
}
|
||||
if (sIsIntelDecoderEnabled && sDXVAEnabled) {
|
||||
if (MediaPrefs::PDMWMFIntelDecoderEnabled() && sDXVAEnabled) {
|
||||
if (aMimeType.EqualsLiteral("video/webm; codecs=vp8") &&
|
||||
CanCreateWMFDecoder<CLSID_WebmMfVp8Dec>()) {
|
||||
return true;
|
||||
|
@ -44,7 +44,6 @@ public:
|
||||
|
||||
// Called from any thread, must call init first
|
||||
static int GetNumDecoderThreads();
|
||||
static bool LowLatencyMFTEnabled();
|
||||
|
||||
// Accessors that report whether we have the required MFTs available
|
||||
// on the system to play various codecs. Windows Vista doesn't have the
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include "WMFVideoMFTManager.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "WMFUtils.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "VideoUtils.h"
|
||||
@ -249,7 +250,7 @@ WMFVideoMFTManager::InitInternal(bool aForceD3D9)
|
||||
attr->GetUINT32(MF_SA_D3D_AWARE, &aware);
|
||||
attr->SetUINT32(CODECAPI_AVDecNumWorkerThreads,
|
||||
WMFDecoderModule::GetNumDecoderThreads());
|
||||
if (WMFDecoderModule::LowLatencyMFTEnabled()) {
|
||||
if (MediaPrefs::PDMWMFLowLatencyEnabled()) {
|
||||
hr = attr->SetUINT32(CODECAPI_AVLowLatencyMode, TRUE);
|
||||
if (SUCCEEDED(hr)) {
|
||||
LOG("Enabling Low Latency Mode");
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "AudioContext.h"
|
||||
#include "mozilla/dom/AudioDestinationNodeBinding.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "AudioChannelAgent.h"
|
||||
#include "AudioChannelService.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "PlayingRefChangeHandler.h"
|
||||
#include "WebAudioUtils.h"
|
||||
#include "blink/Biquad.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "AudioParamTimeline.h"
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "AudioParam.h"
|
||||
#include "PeriodicWave.h"
|
||||
#include "mozilla/dom/OscillatorNodeBinding.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/PannerNodeBinding.h"
|
||||
#include "ThreeDPoint.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "WebAudioUtils.h"
|
||||
#include <set>
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "gfx2DGlue.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Endian.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/SharedThreadPool.h"
|
||||
#include "MediaDataDemuxer.h"
|
||||
#include "nsAutoRef.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "SpeechGrammar.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/SpeechGrammarBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
||||
#include "mozilla/dom/MediaStreamError.h"
|
||||
#include "mozilla/MediaManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "AudioSegment.h"
|
||||
@ -70,7 +72,7 @@ GetSpeechRecognitionService(const nsAString& aLang)
|
||||
nsAutoCString speechRecognitionServiceCID;
|
||||
|
||||
nsAdoptingCString prefValue =
|
||||
Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE);
|
||||
Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE);
|
||||
nsAutoCString speechRecognitionService;
|
||||
|
||||
if (!aLang.IsEmpty()) {
|
||||
@ -83,7 +85,7 @@ GetSpeechRecognitionService(const nsAString& aLang)
|
||||
speechRecognitionService = DEFAULT_RECOGNITION_SERVICE;
|
||||
}
|
||||
|
||||
if (SpeechRecognition::mTestConfig.mFakeRecognitionService) {
|
||||
if (MediaPrefs::WebSpeechFakeRecognitionService()) {
|
||||
speechRecognitionServiceCID =
|
||||
NS_SPEECH_RECOGNITION_SERVICE_CONTRACTID_PREFIX "fake";
|
||||
} else {
|
||||
@ -107,8 +109,6 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(SpeechRecognition, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(SpeechRecognition, DOMEventTargetHelper)
|
||||
|
||||
struct SpeechRecognition::TestConfig SpeechRecognition::mTestConfig;
|
||||
|
||||
SpeechRecognition::SpeechRecognition(nsPIDOMWindowInner* aOwnerWindow)
|
||||
: DOMEventTargetHelper(aOwnerWindow)
|
||||
, mEndpointer(kSAMPLE_RATE)
|
||||
@ -120,8 +120,7 @@ SpeechRecognition::SpeechRecognition(nsPIDOMWindowInner* aOwnerWindow)
|
||||
{
|
||||
SR_LOG("created SpeechRecognition");
|
||||
|
||||
mTestConfig.Init();
|
||||
if (mTestConfig.mEnableTests) {
|
||||
if (MediaPrefs::WebSpeechTestEnabled()) {
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
obs->AddObserver(this, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC, false);
|
||||
obs->AddObserver(this, SPEECH_RECOGNITION_TEST_END_TOPIC, false);
|
||||
@ -175,10 +174,9 @@ SpeechRecognition::IsAuthorized(JSContext* aCx, JSObject* aGlobal)
|
||||
|
||||
bool hasPermission = (speechRecognition == nsIPermissionManager::ALLOW_ACTION);
|
||||
|
||||
bool enableTests = Preferences::GetBool(TEST_PREFERENCE_ENABLE);
|
||||
bool enableRecognitionEnable = Preferences::GetBool(TEST_PREFERENCE_RECOGNITION_ENABLE);
|
||||
bool enableRecognitionForceEnable = Preferences::GetBool(TEST_PREFERENCE_RECOGNITION_FORCE_ENABLE);
|
||||
return (hasPermission || enableRecognitionForceEnable || enableTests) && enableRecognitionEnable;
|
||||
return (hasPermission || MediaPrefs::WebSpeechRecognitionForceEnabled()
|
||||
|| MediaPrefs::WebSpeechTestEnabled())
|
||||
&& MediaPrefs::WebSpeechRecognitionEnabled();
|
||||
}
|
||||
|
||||
already_AddRefed<SpeechRecognition>
|
||||
@ -617,7 +615,7 @@ SpeechRecognition::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
obs->RemoveObserver(this, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC);
|
||||
obs->RemoveObserver(this, SPEECH_RECOGNITION_TEST_END_TOPIC);
|
||||
} else if (mTestConfig.mFakeFSMEvents &&
|
||||
} else if (MediaPrefs::WebSpeechFakeFSMEvents() &&
|
||||
!strcmp(aTopic, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC)) {
|
||||
ProcessTestEventRequest(aSubject, nsDependentString(aData));
|
||||
}
|
||||
@ -635,7 +633,7 @@ SpeechRecognition::ProcessTestEventRequest(nsISupports* aSubject, const nsAStrin
|
||||
SpeechRecognitionErrorCode::Audio_capture, // TODO different codes?
|
||||
NS_LITERAL_STRING("AUDIO_ERROR test event"));
|
||||
} else {
|
||||
NS_ASSERTION(mTestConfig.mFakeRecognitionService,
|
||||
NS_ASSERTION(MediaPrefs::WebSpeechFakeRecognitionService(),
|
||||
"Got request for fake recognition service event, but "
|
||||
TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE " is unset");
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "AudioSegment.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "SpeechGrammarList.h"
|
||||
#include "SpeechRecognitionResultList.h"
|
||||
@ -35,11 +34,6 @@ namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
|
||||
#define TEST_PREFERENCE_ENABLE "media.webspeech.test.enable"
|
||||
#define TEST_PREFERENCE_FAKE_FSM_EVENTS "media.webspeech.test.fake_fsm_events"
|
||||
#define TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE "media.webspeech.test.fake_recognition_service"
|
||||
#define TEST_PREFERENCE_RECOGNITION_ENABLE "media.webspeech.recognition.enable"
|
||||
#define TEST_PREFERENCE_RECOGNITION_FORCE_ENABLE "media.webspeech.recognition.force_enable"
|
||||
#define SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC "SpeechRecognitionTest:RequestEvent"
|
||||
#define SPEECH_RECOGNITION_TEST_END_TOPIC "SpeechRecognitionTest:End"
|
||||
|
||||
@ -131,33 +125,6 @@ public:
|
||||
AudioSegment* CreateAudioSegment(nsTArray<RefPtr<SharedBuffer>>& aChunks);
|
||||
void FeedAudioData(already_AddRefed<SharedBuffer> aSamples, uint32_t aDuration, MediaStreamListener* aProvider, TrackRate aTrackRate);
|
||||
|
||||
static struct TestConfig
|
||||
{
|
||||
public:
|
||||
bool mEnableTests;
|
||||
bool mFakeFSMEvents;
|
||||
bool mFakeRecognitionService;
|
||||
|
||||
void Init()
|
||||
{
|
||||
if (mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
Preferences::AddBoolVarCache(&mEnableTests, TEST_PREFERENCE_ENABLE);
|
||||
|
||||
if (mEnableTests) {
|
||||
Preferences::AddBoolVarCache(&mFakeFSMEvents, TEST_PREFERENCE_FAKE_FSM_EVENTS);
|
||||
Preferences::AddBoolVarCache(&mFakeRecognitionService, TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE);
|
||||
}
|
||||
|
||||
mInitialized = true;
|
||||
}
|
||||
private:
|
||||
bool mInitialized;
|
||||
} mTestConfig;
|
||||
|
||||
|
||||
friend class SpeechEvent;
|
||||
private:
|
||||
virtual ~SpeechRecognition() {};
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "FakeSpeechRecognitionService.h"
|
||||
#include "MediaPrefs.h"
|
||||
|
||||
#include "SpeechRecognition.h"
|
||||
#include "SpeechRecognitionAlternative.h"
|
||||
@ -66,7 +67,7 @@ FakeSpeechRecognitionService::Abort()
|
||||
NS_IMETHODIMP
|
||||
FakeSpeechRecognitionService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
|
||||
{
|
||||
MOZ_ASSERT(mRecognition->mTestConfig.mFakeRecognitionService,
|
||||
MOZ_ASSERT(MediaPrefs::WebSpeechFakeRecognitionService(),
|
||||
"Got request to fake recognition service event, but "
|
||||
TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE " is not set");
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
|
||||
#include "MediaPrefs.h"
|
||||
#include "SpeechSynthesisUtterance.h"
|
||||
#include "SpeechSynthesisVoice.h"
|
||||
#include "nsSynthVoiceRegistry.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "SpeechSynthesisChild.h"
|
||||
@ -137,7 +137,6 @@ public:
|
||||
// nsSynthVoiceRegistry
|
||||
|
||||
static StaticRefPtr<nsSynthVoiceRegistry> gSynthVoiceRegistry;
|
||||
static bool sForceGlobalQueue = false;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsSynthVoiceRegistry, nsISynthVoiceRegistry)
|
||||
|
||||
@ -189,8 +188,6 @@ nsSynthVoiceRegistry::GetInstance()
|
||||
|
||||
if (!gSynthVoiceRegistry) {
|
||||
gSynthVoiceRegistry = new nsSynthVoiceRegistry();
|
||||
Preferences::AddBoolVarCache(&sForceGlobalQueue,
|
||||
"media.webspeech.synth.force_global_queue");
|
||||
if (XRE_IsParentProcess()) {
|
||||
// Start up all speech synth services.
|
||||
NS_CreateServicesFromCategory(NS_SPEECH_SYNTH_STARTED, nullptr,
|
||||
@ -342,7 +339,7 @@ nsSynthVoiceRegistry::RemoveVoice(nsISpeechService* aService,
|
||||
mDefaultVoices.RemoveElement(retval);
|
||||
mUriVoiceMap.Remove(aUri);
|
||||
|
||||
if (retval->mIsQueued && !sForceGlobalQueue) {
|
||||
if (retval->mIsQueued && !MediaPrefs::WebSpeechForceGlobal()) {
|
||||
// Check if this is the last queued voice, and disable the global queue if
|
||||
// it is.
|
||||
bool queued = false;
|
||||
@ -713,7 +710,7 @@ nsSynthVoiceRegistry::Speak(const nsAString& aText,
|
||||
|
||||
aTask->SetChosenVoiceURI(voice->mUri);
|
||||
|
||||
if (mUseGlobalQueue || sForceGlobalQueue) {
|
||||
if (mUseGlobalQueue || MediaPrefs::WebSpeechForceGlobal()) {
|
||||
LOG(LogLevel::Debug,
|
||||
("nsSynthVoiceRegistry::Speak queueing text='%s' lang='%s' uri='%s' rate=%f pitch=%f",
|
||||
NS_ConvertUTF16toUTF8(aText).get(), NS_ConvertUTF16toUTF8(aLang).get(),
|
||||
@ -791,7 +788,8 @@ nsSynthVoiceRegistry::SetIsSpeaking(bool aIsSpeaking)
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
// Only set to 'true' if global queue is enabled.
|
||||
mIsSpeaking = aIsSpeaking && (mUseGlobalQueue || sForceGlobalQueue);
|
||||
mIsSpeaking =
|
||||
aIsSpeaking && (mUseGlobalQueue || MediaPrefs::WebSpeechForceGlobal());
|
||||
|
||||
nsTArray<SpeechSynthesisParent*> ssplist;
|
||||
GetAllSpeechSynthActors(ssplist);
|
||||
|
Loading…
Reference in New Issue
Block a user