OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #include "media/base/media.h" | |
6 | |
7 #include <windows.h> | |
8 #if defined(_WIN32_WINNT_WIN8) | |
9 // The Windows 8 SDK defines FACILITY_VISUALCPP in winerror.h. | |
10 #undef FACILITY_VISUALCPP | |
11 #endif | |
12 #include <delayimp.h> | |
13 | |
14 #include "base/files/file_path.h" | |
15 #include "base/metrics/sparse_histogram.h" | |
16 #include "media/ffmpeg/ffmpeg_common.h" | |
17 | |
18 #pragma comment(lib, "delayimp.lib") | |
19 | |
20 namespace media { | |
21 namespace internal { | |
22 | |
23 bool InitializeMediaLibraryInternal(const base::FilePath& module_dir) { | |
24 // LoadLibraryEx(..., LOAD_WITH_ALTERED_SEARCH_PATH) cannot handle | |
25 // relative path. | |
26 if (!module_dir.IsAbsolute()) | |
27 return false; | |
28 | |
29 // Use alternate DLL search path so we don't load dependencies from the | |
30 // system path. Refer to http://crbug.com/35857 | |
31 static const char kFFmpegDLL[] = "ffmpegsumo.dll"; | |
32 HMODULE lib = ::LoadLibraryEx( | |
33 module_dir.AppendASCII(kFFmpegDLL).value().c_str(), NULL, | |
34 LOAD_WITH_ALTERED_SEARCH_PATH); | |
35 | |
36 bool initialized = (lib != NULL); | |
37 | |
38 // TODO(scherkus): Remove all the bool-ness from these functions as we no | |
39 // longer support disabling HTML5 media at runtime. http://crbug.com/440892 | |
40 if (!initialized) { | |
41 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.Initialize.Windows", GetLastError()); | |
42 return false; | |
43 } | |
44 | |
45 // VS2013 has a bug where FMA3 instructions will be executed on CPUs that | |
46 // support them despite them being disabled at the OS level, causing illegal | |
47 // instruction exceptions. Because Web Audio's FFT code *might* run before | |
48 // HTML5 media code, call av_log_set_level() to force library initialziation. | |
49 // See http://crbug.com/440892 for details. | |
50 av_log_set_level(AV_LOG_QUIET); | |
51 | |
52 return initialized; | |
53 } | |
54 | |
55 } // namespace internal | |
56 } // namespace media | |
OLD | NEW |