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

Unified Diff: media/base/win/mf_initializer.cc

Issue 1149203002: Extract re-usable InitializeMediaFoundation() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix linkage of InitializeMediaFoundation() in GN builds Created 5 years, 7 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
« no previous file with comments | « media/base/win/mf_initializer.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/win/mf_initializer.cc
diff --git a/media/base/win/mf_initializer.cc b/media/base/win/mf_initializer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ff62a451e92c79943ecb24d35646e3985e2b6c2b
--- /dev/null
+++ b/media/base/win/mf_initializer.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/win/mf_initializer.h"
+
+#include <mfapi.h>
+
+#include "base/lazy_instance.h"
+#include "base/macros.h"
+
+namespace media {
+
+namespace {
+
+// LazyInstance to initialize the Media Foundation Library.
+class MFInitializer {
+ public:
+ MFInitializer()
+ : mf_started_(MFStartup(MF_VERSION, MFSTARTUP_LITE) == S_OK) {}
+
+ ~MFInitializer() {
+ if (mf_started_)
+ MFShutdown();
+ }
+
+ private:
+ const bool mf_started_;
+
+ DISALLOW_COPY_AND_ASSIGN(MFInitializer);
+};
+
+base::LazyInstance<MFInitializer> g_mf_initializer = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+void InitializeMediaFoundation() {
+ g_mf_initializer.Get();
+}
+
+} // namespace media
« no previous file with comments | « media/base/win/mf_initializer.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698