Index: media/base/media.cc |
diff --git a/media/base/media.cc b/media/base/media.cc |
index 38daf05b8edd18960083a6eec0b38b5f9c298c79..249a2f4a2ff565fcd6dc11eb5b469e88107b8fa6 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,36 @@ class MediaInitializer { |
#endif // !defined(MEDIA_DISABLE_FFMPEG) |
} |
- ~MediaInitializer() { |
- NOTREACHED() << "MediaInitializer should be leaky!"; |
+ void enable_platform_decoder_support() { |
+ has_platform_decoder_support_ = true; |
} |
+ bool has_platform_decoder_support() { return has_platform_decoder_support_; } |
+ |
+ private: |
+ ~MediaInitializer() { NOTREACHED() << "MediaInitializer should be leaky!"; } |
scottmg
2017/01/31 21:10:34
Probably better just to remove this?
Mark Mentovai
2017/01/31 21:33:56
Use
~MediaInitializer() = delete;
instead. Tha
DaleCurtis
2017/01/31 22:04:33
Good idea. Done.
|
+ |
bool has_platform_decoder_support_ = false; |
Mark Mentovai
2017/01/31 21:33:56
I don’t think anything is going to be smart enough
DaleCurtis
2017/01/31 22:04:33
Thanks for the commentary. When I wrote this I jus
|
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() { |