OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/win/mf_initializer.h" | 5 #include "media/base/win/mf_initializer.h" |
6 | 6 |
7 #include <mfapi.h> | 7 #include <mfapi.h> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | |
11 | 10 |
12 namespace media { | 11 namespace media { |
13 | 12 |
14 namespace { | |
15 | |
16 // LazyInstance to initialize the Media Foundation Library. | |
17 class MFInitializer { | |
18 public: | |
19 MFInitializer() | |
20 : mf_started_(MFStartup(MF_VERSION, MFSTARTUP_LITE) == S_OK) {} | |
21 | |
22 ~MFInitializer() { | |
23 if (mf_started_) | |
24 MFShutdown(); | |
25 } | |
26 | |
27 private: | |
28 const bool mf_started_; | |
29 | |
30 DISALLOW_COPY_AND_ASSIGN(MFInitializer); | |
31 }; | |
32 | |
33 base::LazyInstance<MFInitializer> g_mf_initializer = LAZY_INSTANCE_INITIALIZER; | |
34 | |
35 } // namespace | |
36 | |
37 void InitializeMediaFoundation() { | 13 void InitializeMediaFoundation() { |
38 g_mf_initializer.Get(); | 14 static HRESULT result = MFStartup(MF_VERSION, MFSTARTUP_LITE); |
| 15 DCHECK_EQ(result, S_OK); |
39 } | 16 } |
40 | 17 |
41 } // namespace media | 18 } // namespace media |
OLD | NEW |