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

Unified Diff: media/base/media_win.cc

Issue 6537022: Move media library path resolution into Chrome path provider. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: And again, this time with working tests... Created 9 years, 10 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_win.cc
diff --git a/media/base/media_win.cc b/media/base/media_win.cc
index 87a9aa332a3fb78f12c518676ca086248e6b9bb7..5247c8a383ae01846200b752559630b621cbdf67 100644
--- a/media/base/media_win.cc
+++ b/media/base/media_win.cc
@@ -46,11 +46,16 @@ FilePath::CharType* GetDLLName(FFmpegDLLKeys dll_key) {
}
}
+static bool g_media_library_is_initialized = false;
+
} // namespace
// Attempts to initialize the media library (loading DLLs, DSOs, etc.).
// Returns true if everything was successfully initialized, false otherwise.
-bool InitializeMediaLibrary(const FilePath& base_path) {
+void InitializeMediaLibrary(const FilePath& base_path) {
+ if (g_media_library_is_initialized)
+ return;
+
FFmpegDLLKeys path_keys[] = {
media::FILE_LIBAVCODEC,
media::FILE_LIBAVFORMAT,
@@ -82,15 +87,19 @@ bool InitializeMediaLibrary(const FilePath& base_path) {
// Check that we loaded all libraries successfully. We only need to check the
// last array element because the loop above will break without initializing
// it on any prior error.
- if (libs[arraysize(libs)-1])
- return true;
-
- // Free any loaded libraries if we weren't successful.
- for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) {
- FreeLibrary(libs[i]);
- libs[i] = NULL; // Just to be safe.
+ g_media_library_is_initialized = (libs[arraysize(libs)-1] != NULL);
awong 2011/02/25 02:41:59 Remove outer parens. Not necessary.
+
+ if (!g_media_library_is_initialized) {
+ // Free any loaded libraries if we weren't successful.
+ for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) {
+ FreeLibrary(libs[i]);
+ libs[i] = NULL; // Just to be safe.
+ }
}
- return false;
+}
+
+bool IsMediaLibraryInitialized() {
+ return g_media_library_is_initialized;
}
bool InitializeOpenMaxLibrary(const FilePath& module_dir) {

Powered by Google App Engine
This is Rietveld 408576698