Chromium Code Reviews| Index: media/base/media.cc |
| diff --git a/media/base/media.cc b/media/base/media.cc |
| index 37fc02ae4575c3cb6cf51a94c0f6fdaebc23c9fe..ded05993348c1dcc0387dea7692189b3b760ef4a 100644 |
| --- a/media/base/media.cc |
| +++ b/media/base/media.cc |
| @@ -11,36 +11,37 @@ |
| #include "build/build_config.h" |
| #include "media/base/yuv_convert.h" |
| -namespace media { |
| +#if !defined(MEDIA_DISABLE_FFMPEG) |
| +#include "media/ffmpeg/ffmpeg_common.h" |
| +#endif |
| -namespace internal { |
| -// Platform specific initialization method. |
| -extern bool InitializeMediaLibraryInternal(const base::FilePath& module_dir); |
| -} // namespace internal |
| +namespace media { |
| // Media must only be initialized once, so use a LazyInstance to ensure this. |
| class MediaInitializer { |
| public: |
| - bool Initialize(const base::FilePath& module_dir) { |
| + void Initialize() { |
|
DaleCurtis
2015/06/02 18:21:07
No need for an Initilize() method and a lock anymo
chcunningham
2015/06/03 01:14:16
Done.
|
| base::AutoLock auto_lock(lock_); |
| - if (!tried_initialize_) { |
| - tried_initialize_ = true; |
| - initialized_ = internal::InitializeMediaLibraryInternal(module_dir); |
| - } |
| - return initialized_; |
| - } |
| + if (!initialized_) { |
| +#if !defined(MEDIA_DISABLE_FFMPEG) |
| + // Disable logging as it interferes with layout tests. |
|
DaleCurtis
2015/06/02 18:21:07
Indent is wrong for these, it should be as if the
chcunningham
2015/06/03 01:14:16
Done.
|
| + av_log_set_level(AV_LOG_QUIET); |
| - bool IsInitialized() { |
| - base::AutoLock auto_lock(lock_); |
| - return initialized_; |
| +#if defined(ALLOCATOR_SHIM) |
| + // Remove allocation limit from ffmpeg, so calls go down to shim layer. |
| + av_max_alloc(0); |
| +#endif // defined(ALLOCATOR_SHIM) |
| + |
| +#endif // !defined(MEDIA_DISABLE_FFMPEG) |
| + |
| + initialized_ = true; |
| + } |
| } |
| private: |
| friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; |
| - MediaInitializer() |
| - : initialized_(false), |
| - tried_initialize_(false) { |
| + MediaInitializer() : initialized_(false) { |
| // Perform initialization of libraries which require runtime CPU detection. |
| InitializeCPUSpecificYUVConversions(); |
| } |
| @@ -51,7 +52,6 @@ class MediaInitializer { |
| base::Lock lock_; |
| bool initialized_; |
| - bool tried_initialize_; |
| DISALLOW_COPY_AND_ASSIGN(MediaInitializer); |
| }; |
| @@ -59,18 +59,8 @@ class MediaInitializer { |
| static base::LazyInstance<MediaInitializer>::Leaky g_media_library = |
| LAZY_INSTANCE_INITIALIZER; |
| -bool InitializeMediaLibrary(const base::FilePath& module_dir) { |
| - return g_media_library.Get().Initialize(module_dir); |
| -} |
| - |
| -void InitializeMediaLibraryForTesting() { |
| - base::FilePath module_dir; |
| - CHECK(PathService::Get(base::DIR_EXE, &module_dir)); |
| - CHECK(g_media_library.Get().Initialize(module_dir)); |
| -} |
| - |
| -bool IsMediaLibraryInitialized() { |
| - return g_media_library.Get().IsInitialized(); |
| +void InitializeMediaLibrary() { |
| + g_media_library.Get().Initialize(); |
| } |
| void InitializeCPUSpecificMediaFeatures() { |