Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / media / base / media_win.cc
blob03d78b1d454329bb0c8a8f648b3f0116ddcba75e
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.
5 #include "media/base/media.h"
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>
14 #include "base/files/file_path.h"
15 #include "base/metrics/sparse_histogram.h"
16 #include "media/ffmpeg/ffmpeg_common.h"
18 #pragma comment(lib, "delayimp.lib")
20 namespace media {
21 namespace internal {
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;
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);
36 bool initialized = (lib != NULL);
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;
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);
52 return initialized;
55 } // namespace internal
56 } // namespace media