summaryrefslogtreecommitdiffstats
path: root/media/base/win/mf_initializer.cc
blob: ff62a451e92c79943ecb24d35646e3985e2b6c2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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