Chromium Code Reviews| 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) { |