1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/base/media.h"
7 #include "base/files/file_path.h"
8 #include "base/lazy_instance.h"
9 #include "base/path_service.h"
10 #include "base/synchronization/lock.h"
11 #include "base/trace_event/trace_event.h"
12 #include "build/build_config.h"
13 #include "media/base/yuv_convert.h"
15 #if !defined(MEDIA_DISABLE_FFMPEG)
16 #include "media/ffmpeg/ffmpeg_common.h"
21 // Media must only be initialized once, so use a LazyInstance to ensure this.
22 class MediaInitializer
{
24 friend struct base::DefaultLazyInstanceTraits
<MediaInitializer
>;
27 TRACE_EVENT_WARMUP_CATEGORY("audio");
28 TRACE_EVENT_WARMUP_CATEGORY("media");
30 // Perform initialization of libraries which require runtime CPU detection.
31 InitializeCPUSpecificYUVConversions();
33 #if !defined(MEDIA_DISABLE_FFMPEG)
34 // Initialize CPU flags outside of the sandbox as this may query /proc for
35 // details on the current CPU for NEON, VFP, etc optimizations.
38 // Disable logging as it interferes with layout tests.
39 av_log_set_level(AV_LOG_QUIET
);
41 #if defined(ALLOCATOR_SHIM)
42 // Remove allocation limit from ffmpeg, so calls go down to shim layer.
44 #endif // defined(ALLOCATOR_SHIM)
46 #endif // !defined(MEDIA_DISABLE_FFMPEG)
50 NOTREACHED() << "MediaInitializer should be leaky!";
53 DISALLOW_COPY_AND_ASSIGN(MediaInitializer
);
56 static base::LazyInstance
<MediaInitializer
>::Leaky g_media_library
=
57 LAZY_INSTANCE_INITIALIZER
;
59 void InitializeMediaLibrary() {
60 g_media_library
.Get();