| Index: media/base/media.cc
|
| diff --git a/media/base/media.cc b/media/base/media.cc
|
| index 38daf05b8edd18960083a6eec0b38b5f9c298c79..08c68bde40100fff8fa983b19f929e522886a5f8 100644
|
| --- a/media/base/media.cc
|
| +++ b/media/base/media.cc
|
| @@ -5,7 +5,6 @@
|
| #include "media/base/media.h"
|
|
|
| #include "base/command_line.h"
|
| -#include "base/lazy_instance.h"
|
| #include "base/macros.h"
|
| #include "base/metrics/field_trial.h"
|
| #include "base/trace_event/trace_event.h"
|
| @@ -23,18 +22,9 @@
|
|
|
| namespace media {
|
|
|
| -// Media must only be initialized once, so use a LazyInstance to ensure this.
|
| +// Media must only be initialized once; use a thread-safe static to do this.
|
| class MediaInitializer {
|
| public:
|
| - void enable_platform_decoder_support() {
|
| - has_platform_decoder_support_ = true;
|
| - }
|
| -
|
| - bool has_platform_decoder_support() { return has_platform_decoder_support_; }
|
| -
|
| - private:
|
| - friend struct base::DefaultLazyInstanceTraits<MediaInitializer>;
|
| -
|
| MediaInitializer() {
|
| TRACE_EVENT_WARMUP_CATEGORY("audio");
|
| TRACE_EVENT_WARMUP_CATEGORY("media");
|
| @@ -58,29 +48,42 @@ class MediaInitializer {
|
| #endif // !defined(MEDIA_DISABLE_FFMPEG)
|
| }
|
|
|
| - ~MediaInitializer() {
|
| - NOTREACHED() << "MediaInitializer should be leaky!";
|
| +#if defined(OS_ANDROID)
|
| + void enable_platform_decoder_support() {
|
| + has_platform_decoder_support_ = true;
|
| + }
|
| +
|
| + bool has_platform_decoder_support() const {
|
| + return has_platform_decoder_support_;
|
| }
|
| +#endif // defined(OS_ANDROID)
|
| +
|
| + private:
|
| + ~MediaInitializer() = delete;
|
|
|
| +#if defined(OS_ANDROID)
|
| bool has_platform_decoder_support_ = false;
|
| +#endif // defined(OS_ANDROID)
|
|
|
| DISALLOW_COPY_AND_ASSIGN(MediaInitializer);
|
| };
|
|
|
| -static base::LazyInstance<MediaInitializer>::Leaky g_media_library =
|
| - LAZY_INSTANCE_INITIALIZER;
|
| +static MediaInitializer* GetMediaInstance() {
|
| + static MediaInitializer* instance = new MediaInitializer();
|
| + return instance;
|
| +}
|
|
|
| void InitializeMediaLibrary() {
|
| - g_media_library.Get();
|
| + GetMediaInstance();
|
| }
|
|
|
| #if defined(OS_ANDROID)
|
| void EnablePlatformDecoderSupport() {
|
| - g_media_library.Pointer()->enable_platform_decoder_support();
|
| + GetMediaInstance()->enable_platform_decoder_support();
|
| }
|
|
|
| bool HasPlatformDecoderSupport() {
|
| - return g_media_library.Pointer()->has_platform_decoder_support();
|
| + return GetMediaInstance()->has_platform_decoder_support();
|
| }
|
|
|
| bool PlatformHasOpusSupport() {
|
| @@ -97,6 +100,6 @@ bool ArePlatformDecodersAvailable() {
|
| ? HasPlatformDecoderSupport()
|
| : MediaCodecUtil::IsMediaCodecAvailable();
|
| }
|
| -#endif
|
| +#endif // defined(OS_ANDROID)
|
|
|
| } // namespace media
|
|
|