-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathWASAPIManager.h
72 lines (55 loc) · 1.95 KB
/
WASAPIManager.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
//--------------------------------------------------------------------------------------
// WASAPIManager.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#include "pch.h"
#include "DeviceState.h"
#include "WASAPIRenderer.h"
#include "WAVFileReader.h"
ref class WASAPIManager sealed
{
public:
WASAPIManager();
void StartDevice();
void RestartDevice();
void StopDevice();
void PauseDevice();
void PlayPauseToggle();
void SetVolume( unsigned int volume );
//--------------------------------------------------------------------------------------
// Name: IsStopped
// Desc: Returns true if the renderer doesn't exist or it does exist and it's in the
// DeviceStateStopped state.
//--------------------------------------------------------------------------------------
bool IsStopped()
{
bool bStopped = true;
if ( m_Renderer != nullptr )
{
bStopped = ( m_StateChangedEvent->GetState() == DeviceState::DeviceStateStopped );
}
return bStopped;
}
bool IsPlaying()
{
bool bPlaying = false;
if (m_Renderer != nullptr)
{
bPlaying = (m_StateChangedEvent->GetState() == DeviceState::DeviceStatePlaying);
}
return bPlaying;
}
void OnRenderDeviceChange(Platform::Object^,
Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^);
private:
~WASAPIManager();
void OnDeviceStateChange( Object^ sender, DeviceStateChangedEventArgs^ e );
void InitializeDevice();
Windows::Foundation::EventRegistrationToken m_DeviceStateChangeToken;
DeviceStateChangedEvent^ m_StateChangedEvent;
Microsoft::WRL::ComPtr<WASAPIRenderer> m_Renderer;
Windows::Foundation::EventRegistrationToken m_renderEventToken;
};