Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1274)

Side by Side Diff: media/base/media.cc

Issue 1141703002: Chromium changes for static linking ffmpeg (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaking our x86inc.asm Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/media.h" 5 #include "media/base/media.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "media/base/yuv_convert.h" 12 #include "media/base/yuv_convert.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 namespace internal { 16 namespace internal {
17 // Platform specific initialization method. 17 // Platform specific initialization method.
18 extern bool InitializeMediaLibraryInternal(const base::FilePath& module_dir); 18 extern void InitializeMediaLibraryInternal();
M-A Ruel 2015/05/15 23:51:29 The function is not external. Also per coding styl
DaleCurtis 2015/05/15 23:57:45 Yeah this isn't really necessary anymore since we
chcunningham 2015/05/16 04:36:25 Done. I used the existing define MEDIA_DISABLE_FFM
DaleCurtis 2015/05/18 23:33:14 Doesn't seem deleted yet?
chcunningham 2015/05/21 22:10:27 Woops, fixed.
19 } // namespace internal 19 } // namespace internal
20 20
21 // Media must only be initialized once, so use a LazyInstance to ensure this. 21 // Media must only be initialized once, so use a LazyInstance to ensure this.
22 class MediaInitializer { 22 class MediaInitializer {
23 public: 23 public:
24 bool Initialize(const base::FilePath& module_dir) { 24 void Initialize() {
25 base::AutoLock auto_lock(lock_); 25 base::AutoLock auto_lock(lock_);
26 if (!tried_initialize_) { 26 if (!initialized_) {
27 tried_initialize_ = true; 27 internal::InitializeMediaLibraryInternal();
28 initialized_ = internal::InitializeMediaLibraryInternal(module_dir); 28 initialized_ = true;
29 } 29 }
30 return initialized_;
31 } 30 }
32 31
33 bool IsInitialized() { 32 bool IsInitialized() {
34 base::AutoLock auto_lock(lock_); 33 base::AutoLock auto_lock(lock_);
35 return initialized_; 34 return initialized_;
36 } 35 }
37
38 private: 36 private:
39 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; 37 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>;
40 38
41 MediaInitializer() 39 MediaInitializer() : initialized_(false) {
42 : initialized_(false),
43 tried_initialize_(false) {
44 // Perform initialization of libraries which require runtime CPU detection. 40 // Perform initialization of libraries which require runtime CPU detection.
45 InitializeCPUSpecificYUVConversions(); 41 InitializeCPUSpecificYUVConversions();
46 } 42 }
47 43
48 ~MediaInitializer() { 44 ~MediaInitializer() {
49 NOTREACHED() << "MediaInitializer should be leaky!"; 45 NOTREACHED() << "MediaInitializer should be leaky!";
50 } 46 }
51 47
52 base::Lock lock_; 48 base::Lock lock_;
53 bool initialized_; 49 bool initialized_;
54 bool tried_initialize_;
55 50
56 DISALLOW_COPY_AND_ASSIGN(MediaInitializer); 51 DISALLOW_COPY_AND_ASSIGN(MediaInitializer);
57 }; 52 };
58 53
59 static base::LazyInstance<MediaInitializer>::Leaky g_media_library = 54 static base::LazyInstance<MediaInitializer>::Leaky g_media_library =
60 LAZY_INSTANCE_INITIALIZER; 55 LAZY_INSTANCE_INITIALIZER;
61 56
57 void InitializeMediaLibrary() {
58 g_media_library.Get().Initialize();
59 }
60
62 bool InitializeMediaLibrary(const base::FilePath& module_dir) { 61 bool InitializeMediaLibrary(const base::FilePath& module_dir) {
63 return g_media_library.Get().Initialize(module_dir); 62 // TODO(chcunningham): Remove this method in favor of the zero-argument
63 // version. Because ffmpeg is now statically linked, path is no longer needed
64 // and return will always be true.
65 InitializeMediaLibrary();
66 return true;
64 } 67 }
65 68
66 void InitializeMediaLibraryForTesting() { 69 void InitializeMediaLibraryForTesting() {
67 base::FilePath module_dir; 70 // TODO(chcunningham): Delete this method. Testing path is now the same as
68 CHECK(PathService::Get(base::DIR_EXE, &module_dir)); 71 // production path.
69 CHECK(g_media_library.Get().Initialize(module_dir)); 72 InitializeMediaLibrary();
70 } 73 }
71 74
72 bool IsMediaLibraryInitialized() { 75 bool IsMediaLibraryInitialized() {
76 // TODO(chcunningham): Delete this method. Users should just call Initialize
77 // blindly and let it bail if its already been done.
73 return g_media_library.Get().IsInitialized(); 78 return g_media_library.Get().IsInitialized();
74 } 79 }
75 80
76 void InitializeCPUSpecificMediaFeatures() { 81 void InitializeCPUSpecificMediaFeatures() {
77 // Force initialization of the media initializer, but don't call Initialize(). 82 // Force initialization of the media initializer, but don't call Initialize().
78 g_media_library.Get(); 83 g_media_library.Get();
79 } 84 }
80 85
81 } // namespace media 86 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media.h ('k') | media/base/media_init.cc » ('j') | media/media.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698