-
Notifications
You must be signed in to change notification settings - Fork 226
/
DeviceState.h
86 lines (72 loc) · 2.08 KB
/
DeviceState.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//--------------------------------------------------------------------------------------
// DeviceState.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
// NB: All states >= DeviceStateInitialized will allow some methods
// to be called successfully on the Audio Client
enum class DeviceState
{
DeviceStateUnInitialized,
DeviceStateInError,
DeviceStateDiscontinuity,
DeviceStateFlushing,
DeviceStateActivated,
DeviceStateInitialized,
DeviceStateStarting,
DeviceStatePlaying,
DeviceStateCapturing,
DeviceStatePausing,
DeviceStatePaused,
DeviceStateStopping,
DeviceStateStopped
};
// Class for DeviceStateChanged events
ref class DeviceStateChangedEventArgs sealed
{
internal:
DeviceStateChangedEventArgs(DeviceState newState, HRESULT hr) :
m_DeviceState(newState),
m_hr(hr)
{};
property DeviceState State
{
DeviceState get() { return m_DeviceState; }
};
property int hr
{
int get() { return m_hr; }
}
private:
DeviceState m_DeviceState;
HRESULT m_hr;
};
// DeviceStateChanged delegate
delegate void DeviceStateChangedHandler(Platform::Object^ sender, DeviceStateChangedEventArgs^ e);
// DeviceStateChanged Event
ref class DeviceStateChangedEvent sealed
{
public:
DeviceStateChangedEvent() :
m_DeviceState(DeviceState::DeviceStateUnInitialized)
{};
internal:
DeviceState GetState() { return m_DeviceState; };
void SetState(DeviceState newState, HRESULT hr, bool FireEvent) {
if (m_DeviceState != newState)
{
m_DeviceState = newState;
if (FireEvent)
{
DeviceStateChangedEventArgs^ e = ref new DeviceStateChangedEventArgs(m_DeviceState, hr);
StateChangedEvent(this, e);
}
}
};
public:
static event DeviceStateChangedHandler^ StateChangedEvent;
private:
DeviceState m_DeviceState;
};