-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AudioFunctions.h
67 lines (56 loc) · 1.87 KB
/
AudioFunctions.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <functional>
#include <map>
#include <string>
enum class AudioDeviceRole {
DEFAULT,
COMMUNICATION,
};
enum class AudioDeviceDirection {
OUTPUT,
INPUT,
};
enum class MuteAction {
UNMUTE,
MUTE,
TOGGLE,
};
enum class AudioDeviceState {
CONNECTED,
DEVICE_NOT_PRESENT,// USB device unplugged
DEVICE_DISABLED,
DEVICE_PRESENT_NO_CONNECTION,// device present, but nothing's plugged into it,
// e.g. headphone jack with nothing plugged in
};
struct AudioDeviceInfo {
std::string id;
std::string interfaceName;// e.g. "Generic USB Audio Device"
std::string endpointName;// e.g. "Speakers"
std::string displayName;// e.g. "Generic USB Audio Device (Speakers)"
AudioDeviceDirection direction;
AudioDeviceState state;
};
std::map<std::string, AudioDeviceInfo> GetAudioDeviceList(AudioDeviceDirection);
AudioDeviceState GetAudioDeviceState(const std::string& id);
std::string GetDefaultAudioDeviceID(AudioDeviceDirection, AudioDeviceRole);
void SetDefaultAudioDeviceID(
AudioDeviceDirection,
AudioDeviceRole,
const std::string& deviceID);
bool IsAudioDeviceMuted(const std::string& deviceID);
void SetIsAudioDeviceMuted(const std::string& deviceID, MuteAction);
typedef void* AUDIO_DEVICE_MUTE_CALLBACK_HANDLE;
AUDIO_DEVICE_MUTE_CALLBACK_HANDLE AddAudioDeviceMuteUnmuteCallback(
const std::string& deviceID,
std::function<void(bool isMuted)>);
void RemoveAudioDeviceMuteUnmuteCallback(AUDIO_DEVICE_MUTE_CALLBACK_HANDLE);
typedef void* DEFAULT_AUDIO_DEVICE_CHANGE_CALLBACK_HANDLE;
DEFAULT_AUDIO_DEVICE_CHANGE_CALLBACK_HANDLE
AddDefaultAudioDeviceChangeCallback(
std::function<
void(AudioDeviceDirection, AudioDeviceRole, const std::string&)>);
void RemoveDefaultAudioDeviceChangeCallback(
DEFAULT_AUDIO_DEVICE_CHANGE_CALLBACK_HANDLE);
#ifdef HAVE_FEEDBACK_SOUNDS
void PlayFeedbackSound(MuteAction action);
#endif