зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1414759 - Replace some unnecessary media prefs with code constants. r=cpearce
Specifically: - media.decoder.limit - media.num-decode-threads - media.resampling.rate - media.wmf.decoder.thread-count - media.cache.resource-index --HG-- extra : rebase_source : a46aa7078b98b4731ec96b66398c51aa6cb42d27
This commit is contained in:
Родитель
39d276d2d7
Коммит
b15805ab71
|
@ -136,7 +136,6 @@ const char* mozilla::dom::ContentPrefs::gInitPrefs[] = {
|
|||
"media.cubeb_latency_msg_frames",
|
||||
"media.cubeb_latency_playback_ms",
|
||||
"media.decoder-doctor.wmf-disabled-is-failure",
|
||||
"media.decoder.limit",
|
||||
"media.decoder.recycle.enabled",
|
||||
"media.dormant-on-pause-timeout-ms",
|
||||
"media.eme.audio.blank",
|
||||
|
@ -151,11 +150,9 @@ const char* mozilla::dom::ContentPrefs::gInitPrefs[] = {
|
|||
"media.gmp.insecure.allow",
|
||||
"media.gpu-process-decoder",
|
||||
"media.libavcodec.allow-obsolete",
|
||||
"media.num-decode-threads",
|
||||
"media.ogg.enabled",
|
||||
"media.ogg.flac.enabled",
|
||||
"media.resampling.enabled",
|
||||
"media.resampling.rate",
|
||||
"media.ruin-av-sync.enabled",
|
||||
"media.rust.test_mode",
|
||||
"media.suspend-bkgnd-video.delay-ms",
|
||||
|
@ -170,7 +167,6 @@ const char* mozilla::dom::ContentPrefs::gInitPrefs[] = {
|
|||
"media.webspeech.test.fake_fsm_events",
|
||||
"media.webspeech.test.fake_recognition_service",
|
||||
"media.wmf.allow-unsupported-resolutions",
|
||||
"media.wmf.decoder.thread-count",
|
||||
"media.wmf.enabled",
|
||||
"media.wmf.skip-blacklist",
|
||||
"media.wmf.vp9.enabled",
|
||||
|
|
|
@ -197,9 +197,23 @@ private:
|
|||
GlobalAllocPolicy& mPolicy; // reference to a singleton object.
|
||||
};
|
||||
|
||||
static int32_t
|
||||
MediaDecoderLimitDefault()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (jni::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;
|
||||
}
|
||||
|
||||
GlobalAllocPolicy::GlobalAllocPolicy()
|
||||
: mMonitor("DecoderAllocPolicy::mMonitor")
|
||||
, mDecoderLimit(MediaPrefs::MediaDecoderLimit())
|
||||
, mDecoderLimit(MediaDecoderLimitDefault())
|
||||
{
|
||||
SystemGroup::Dispatch(
|
||||
TaskCategory::Other,
|
||||
|
|
|
@ -92,7 +92,6 @@ private:
|
|||
DECL_MEDIA_PREF("media.memory_caches_combined_limit_kb", MediaMemoryCachesCombinedLimitKb, uint32_t, 524288);
|
||||
DECL_MEDIA_PREF("media.memory_caches_combined_limit_pc_sysmem",
|
||||
MediaMemoryCachesCombinedLimitPcSysmem, uint32_t, 5);
|
||||
DECL_MEDIA_PREF("media.cache.resource-index", MediaResourceIndexCache, uint32_t, 8192);
|
||||
|
||||
DECL_MEDIA_PREF("media.cache_resume_threshold", MediaCacheResumeThreshold, int32_t, 10);
|
||||
DECL_MEDIA_PREF("media.cache_readahead_limit", MediaCacheReadaheadLimit, int32_t, 30);
|
||||
|
@ -100,7 +99,6 @@ private:
|
|||
// 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);
|
||||
#if defined(XP_WIN) || defined(XP_DARWIN) || defined(MOZ_PULSEAUDIO)
|
||||
// libcubeb backend implement .get_preferred_channel_layout
|
||||
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, false);
|
||||
|
@ -140,7 +138,6 @@ private:
|
|||
DECL_MEDIA_PREF("media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
|
||||
DECL_MEDIA_PREF("media.decoder-doctor.wmf-disabled-is-failure", DecoderDoctorWMFDisabledIsFailure, bool, false);
|
||||
DECL_MEDIA_PREF("media.wmf.vp9.enabled", PDMWMFVP9DecoderEnabled, bool, true);
|
||||
DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1);
|
||||
#endif
|
||||
DECL_MEDIA_PREF("media.decoder.recycle.enabled", MediaDecoderCheckRecycling, bool, false);
|
||||
DECL_MEDIA_PREF("media.decoder.skip-to-next-key-frame.enabled", MFRSkipToNextKeyFrameEnabled, bool, true);
|
||||
|
@ -165,9 +162,6 @@ private:
|
|||
DECL_MEDIA_PREF("media.webspeech.recognition.enable", WebSpeechRecognitionEnabled, bool, false);
|
||||
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, int32_t, MediaDecoderLimitDefault());
|
||||
|
||||
#if defined(RELEASE_OR_BETA)
|
||||
DECL_MEDIA_PREF("media.audio-max-decode-error", MaxAudioDecodeError, uint32_t, 3);
|
||||
DECL_MEDIA_PREF("media.video-max-decode-error", MaxVideoDecodeError, uint32_t, 2);
|
||||
|
@ -216,20 +210,6 @@ private:
|
|||
template<class T> friend class StaticAutoPtr;
|
||||
static StaticAutoPtr<MediaPrefs> sInstance;
|
||||
|
||||
// Default value functions
|
||||
static int32_t MediaDecoderLimitDefault()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (jni::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);
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaResource.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "MediaPrefs.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
|
||||
|
@ -42,11 +43,15 @@ MediaResource::Destroy()
|
|||
NS_IMPL_ADDREF(MediaResource)
|
||||
NS_IMPL_RELEASE_WITH_DESTROY(MediaResource, Destroy())
|
||||
|
||||
static const uint32_t kMediaResourceIndexCacheSize = 8192;
|
||||
static_assert(IsPowerOfTwo(kMediaResourceIndexCacheSize),
|
||||
"kMediaResourceIndexCacheSize cache size must be a power of 2");
|
||||
|
||||
MediaResourceIndex::MediaResourceIndex(MediaResource* aResource)
|
||||
: mResource(aResource)
|
||||
, mOffset(0)
|
||||
, mCacheBlockSize(aResource->ShouldCacheReads()
|
||||
? SelectCacheSize(MediaPrefs::MediaResourceIndexCache())
|
||||
? kMediaResourceIndexCacheSize
|
||||
: 0)
|
||||
, mCachedOffset(0)
|
||||
, mCachedBytes(0)
|
||||
|
@ -513,32 +518,6 @@ MediaResourceIndex::GetLength() const
|
|||
return mResource->GetLength();
|
||||
}
|
||||
|
||||
// Select the next power of 2 (in range 32B-128KB, or 0 -> no cache)
|
||||
/* static */
|
||||
uint32_t
|
||||
MediaResourceIndex::SelectCacheSize(uint32_t aHint)
|
||||
{
|
||||
if (aHint == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (aHint <= 32) {
|
||||
return 32;
|
||||
}
|
||||
if (aHint > 64 * 1024) {
|
||||
return 128 * 1024;
|
||||
}
|
||||
// 32-bit next power of 2, from:
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
|
||||
aHint--;
|
||||
aHint |= aHint >> 1;
|
||||
aHint |= aHint >> 2;
|
||||
aHint |= aHint >> 4;
|
||||
aHint |= aHint >> 8;
|
||||
aHint |= aHint >> 16;
|
||||
aHint++;
|
||||
return aHint;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MediaResourceIndex::IndexInCache(int64_t aOffsetInFile) const
|
||||
{
|
||||
|
|
|
@ -265,9 +265,6 @@ private:
|
|||
uint32_t aCount,
|
||||
uint32_t* aBytes);
|
||||
|
||||
// Select the next power of 2 (in range 32B-128KB, or 0 -> no cache)
|
||||
static uint32_t SelectCacheSize(uint32_t aHint);
|
||||
|
||||
// Maps a file offset to a mCachedBlock index.
|
||||
uint32_t IndexInCache(int64_t aOffsetInFile) const;
|
||||
|
||||
|
|
|
@ -209,8 +209,10 @@ already_AddRefed<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType)
|
|||
name = "MediaPlayback";
|
||||
break;
|
||||
}
|
||||
|
||||
static const uint32_t kMediaThreadPoolDefaultCount = 4;
|
||||
return SharedThreadPool::
|
||||
Get(nsDependentCString(name), MediaPrefs::MediaThreadPoolDefaultCount());
|
||||
Get(nsDependentCString(name), kMediaThreadPoolDefaultCount);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -51,7 +51,7 @@ AudioSink::AudioSink(AbstractThread* aThread,
|
|||
bool resampling = MediaPrefs::AudioSinkResampling();
|
||||
|
||||
if (resampling) {
|
||||
mOutputRate = MediaPrefs::AudioSinkResampleRate();
|
||||
mOutputRate = 48000;
|
||||
} else if (mInfo.mRate == 44100 || mInfo.mRate == 48000) {
|
||||
// The original rate is of good quality and we want to minimize unecessary
|
||||
// resampling. The common scenario being that the sampling rate is one or
|
||||
|
|
|
@ -74,15 +74,9 @@ WMFDecoderModule::GetNumDecoderThreads()
|
|||
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 = WMF_DECODER_DEFAULT;
|
||||
if (XRE_GetProcessType() != GeckoProcessType_GPU) {
|
||||
prefThreadCount = MediaPrefs::PDMWMFThreadCount();
|
||||
}
|
||||
if (prefThreadCount != WMF_DECODER_DEFAULT) {
|
||||
return std::max(prefThreadCount, 1);
|
||||
} else if (numCores > 4) {
|
||||
// On an 8 core machine, WMF chooses 4 decoder threads.
|
||||
static const int WMF_DECODER_DEFAULT = -1;
|
||||
if (numCores > 4) {
|
||||
return WMF_DECODER_DEFAULT;
|
||||
}
|
||||
return std::max(numCores - 1, 1);
|
||||
|
|
|
@ -333,10 +333,6 @@ pref("media.memory_cache_max_size", 8192);
|
|||
pref("media.memory_caches_combined_limit_kb", 524288);
|
||||
pref("media.memory_caches_combined_limit_pc_sysmem", 5);
|
||||
|
||||
// Cache size hint (in bytes) for each MediaResourceIndex.
|
||||
// 0 -> no cache. Will use next power of 2, clamped to 32B-128KB.
|
||||
pref("media.cache.resource-index", 8192);
|
||||
|
||||
// We'll throttle the download if the download rate is throttle-factor times
|
||||
// the estimated playback rate, AND we satisfy the cache readahead_limit
|
||||
// above. The estimated playback rate is time_duration/length_in_bytes.
|
||||
|
@ -368,7 +364,6 @@ pref("media.mp4.enabled", true);
|
|||
pref("media.use-blank-decoder", false);
|
||||
#ifdef MOZ_WMF
|
||||
pref("media.wmf.enabled", true);
|
||||
pref("media.wmf.decoder.thread-count", -1);
|
||||
pref("media.wmf.dxva.enabled", true);
|
||||
pref("media.wmf.dxva.d3d11.enabled", true);
|
||||
pref("media.wmf.dxva.max-videos", 8);
|
||||
|
|
Загрузка…
Ссылка в новой задаче