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

Unified Diff: media/base/media_posix.cc

Issue 14891002: Remove function level static initializers media library initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar typos. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: media/base/media_posix.cc
diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc
index 01d9e5f14565672f65b8e0274a5c7627e224fe28..98a14e3ea0f08eda1f56022303a24bccedba8351 100644
--- a/media/base/media_posix.cc
+++ b/media/base/media_posix.cc
@@ -22,6 +22,7 @@ using third_party_ffmpeg::StubPathMap;
#endif // !defined(USE_SYSTEM_FFMPEG)
namespace media {
+namespace internal {
// Handy to prevent shooting ourselves in the foot with macro wizardry.
#if !defined(LIBAVCODEC_VERSION_MAJOR) || \
@@ -47,18 +48,12 @@ static const base::FilePath::CharType kSumoLib[] =
#error "Do not know how to construct DSO name for this OS."
#endif
-// Use a global to indicate whether the library has been initialized or not. We
-// rely on function level static initialization in InitializeMediaLibrary() to
-// guarantee this is only set once in a thread safe manner.
-static bool g_media_library_is_initialized = false;
-
-static bool InitializeMediaLibraryInternal(const base::FilePath& module_dir) {
- DCHECK(!g_media_library_is_initialized);
-
+bool InitializeMediaLibraryInternal(const base::FilePath& module_dir,
+ bool for_testing) {
#if defined(USE_SYSTEM_FFMPEG)
// No initialization is necessary when using system ffmpeg,
// we just link directly with system ffmpeg libraries.
- g_media_library_is_initialized = true;
+ return true;
#else
StubPathMap paths;
@@ -74,26 +69,9 @@ static bool InitializeMediaLibraryInternal(const base::FilePath& module_dir) {
paths[kModuleFfmpegsumo].push_back(module_dir.Append(
FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value());
- g_media_library_is_initialized = InitializeStubs(paths);
+ return InitializeStubs(paths);
#endif // !defined(USE_SYSTEM_FFMPEG)
- return g_media_library_is_initialized;
-}
-
-bool InitializeMediaLibrary(const base::FilePath& base_path) {
- static const bool kMediaLibraryInitialized =
- InitializeMediaLibraryInternal(base_path);
- DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized);
- return kMediaLibraryInitialized;
-}
-
-void InitializeMediaLibraryForTesting() {
- base::FilePath file_path;
- CHECK(PathService::Get(base::DIR_EXE, &file_path));
- CHECK(InitializeMediaLibrary(file_path));
-}
-
-bool IsMediaLibraryInitialized() {
- return g_media_library_is_initialized;
}
+} // namespace internal
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698