summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/CubebUtils.h
blob: 35e3994e140b1ff5b5b605a80c63e447fe4a0d35 (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
42
43
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#ifdef _WIN32
#include "Common/WorkQueueThread.h"
#endif

struct cubeb;

namespace CubebUtils
{
std::shared_ptr<cubeb> GetContext();
std::vector<std::pair<std::string, std::string>> ListInputDevices();
const void* GetInputDeviceById(std::string_view id);

// Helper used to handle Windows COM library for cubeb WASAPI backend
class CoInitSyncWorker
{
public:
  using FunctionType = std::function<void()>;

  CoInitSyncWorker(std::string worker_name);
  ~CoInitSyncWorker();

  bool Execute(FunctionType f);

#ifdef _WIN32
private:
  Common::AsyncWorkThread m_work_queue;
  bool m_coinit_success = false;
  bool m_should_couninit = false;
#endif
};
}  // namespace CubebUtils