Bug 1481176 - P4. Make CanHandleMediaType usable off the main thread. r=bryce

This is done by ensuring that all methods is called are usable off the main thread and creating the required preference accessors.

Differential Revision: https://phabricator.services.mozilla.com/D2790
This commit is contained in:
Jean-Yves Avenard 2018-08-06 17:37:46 +02:00
Родитель c2ba5d1b90
Коммит 11e8a29e1f
6 изменённых файлов: 30 добавлений и 10 удалений

Просмотреть файл

@ -154,8 +154,6 @@ CanPlayStatus
CanHandleMediaType(const MediaContainerType& aType,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(NS_IsMainThread());
#ifdef MOZ_ANDROID_HLS_SUPPORT
if (HLSDecoder::IsSupportedType(aType)) {
return CANPLAY_MAYBE;

Просмотреть файл

@ -18,6 +18,7 @@
#include "mozilla/FloatingPoint.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "Visibility.h"
@ -1265,25 +1266,25 @@ MediaDecoder::SetCDMProxy(CDMProxy* aProxy)
bool
MediaDecoder::IsOpusEnabled()
{
return Preferences::GetBool("media.opus.enabled");
return StaticPrefs::MediaOpusEnabled();
}
bool
MediaDecoder::IsOggEnabled()
{
return Preferences::GetBool("media.ogg.enabled");
return StaticPrefs::MediaOggEnabled();
}
bool
MediaDecoder::IsWaveEnabled()
{
return Preferences::GetBool("media.wave.enabled");
return StaticPrefs::MediaWaveEnabled();
}
bool
MediaDecoder::IsWebMEnabled()
{
return Preferences::GetBool("media.webm.enabled");
return StaticPrefs::MediaWebMEnabled();
}
NS_IMETHODIMP

Просмотреть файл

@ -199,7 +199,7 @@ MP4Decoder::IsAAC(const nsACString& aMimeType)
bool
MP4Decoder::IsEnabled()
{
return StaticPrefs::mediaMp4Enabled();
return StaticPrefs::MediaMp4Enabled();
}
/* static */ nsTArray<UniquePtr<TrackInfo>>

Просмотреть файл

@ -7,8 +7,8 @@
#include "OggDecoder.h"
#include "MediaContainerType.h"
#include "MediaDecoder.h"
#include "nsMimeTypes.h"
#include "mozilla/StaticPrefs.h"
#include "nsMimeTypes.h"
namespace mozilla {

Просмотреть файл

@ -85,7 +85,7 @@ WebMDecoder::GetTracksInfo(const MediaContainerType& aType, MediaResult& aError)
bool
WebMDecoder::IsSupportedType(const MediaContainerType& aContainerType)
{
if (!Preferences::GetBool("media.webm.enabled")) {
if (!StaticPrefs::MediaWebMEnabled()) {
return false;
}

Просмотреть файл

@ -880,6 +880,20 @@ VARCACHE_PREF(
)
#undef PREF_VALUE
// Opus
VARCACHE_PREF(
"media.opus.enabled",
MediaOpusEnabled,
RelaxedAtomicBool, true
)
// Wave
VARCACHE_PREF(
"media.wave.enabled",
MediaWaveEnabled,
RelaxedAtomicBool, true
)
// Ogg
VARCACHE_PREF(
"media.ogg.enabled",
@ -887,6 +901,13 @@ VARCACHE_PREF(
RelaxedAtomicBool, true
)
// WebM
VARCACHE_PREF(
"media.webm.enabled",
MediaWebMEnabled,
RelaxedAtomicBool, true
)
// AV1
VARCACHE_PREF(
"media.av1.enabled",
@ -920,7 +941,7 @@ VARCACHE_PREF(
#endif
VARCACHE_PREF(
"media.mp4.enabled",
mediaMp4Enabled,
MediaMp4Enabled,
RelaxedAtomicBool, PREF_VALUE
)
#undef PREF_VALUE