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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/*++
Copyright (c) Microsoft Corporation All Rights Reserved
Module Name:
minwavertstream.h
Abstract:
Definition of wavert miniport class.
--*/
#ifndef _SIMPLEAUDIOSAMPLE_MINWAVERTSTREAM_H_
#define _SIMPLEAUDIOSAMPLE_MINWAVERTSTREAM_H_
#include "savedata.h"
#include "ToneGenerator.h"
//
// Structure to store notifications events in a protected list
//
typedef struct _NotificationListEntry
{
LIST_ENTRY ListEntry;
PKEVENT NotificationEvent;
} NotificationListEntry;
EXT_CALLBACK TimerNotifyRT;
//=============================================================================
// Referenced Forward
//=============================================================================
class CMiniportWaveRT;
typedef CMiniportWaveRT *PCMiniportWaveRT;
//=============================================================================
// Classes
//=============================================================================
///////////////////////////////////////////////////////////////////////////////
// CMiniportWaveRTStream
//
class CMiniportWaveRTStream :
public IDrmAudioStream,
public IMiniportWaveRTStreamNotification,
public IMiniportWaveRTInputStream,
public IMiniportWaveRTOutputStream,
public CUnknown
{
protected:
PPORTWAVERTSTREAM m_pPortStream;
LIST_ENTRY m_NotificationList;
PEX_TIMER m_pNotificationTimer;
ULONG m_ulNotificationIntervalMs;
ULONG m_ulCurrentWritePosition;
LONG m_IsCurrentWritePositionUpdated;
public:
DECLARE_STD_UNKNOWN();
DEFINE_STD_CONSTRUCTOR(CMiniportWaveRTStream);
~CMiniportWaveRTStream();
IMP_IMiniportWaveRTStream;
IMP_IMiniportWaveRTStreamNotification;
IMP_IMiniportWaveRTInputStream;
IMP_IMiniportWaveRTOutputStream;
IMP_IMiniportWaveRT;
IMP_IDrmAudioStream;
NTSTATUS Init
(
_In_ PCMiniportWaveRT Miniport,
_In_ PPORTWAVERTSTREAM Stream,
_In_ ULONG Channel,
_In_ BOOLEAN Capture,
_In_ PKSDATAFORMAT DataFormat,
_In_ GUID SignalProcessingMode
);
// Friends
friend class CMiniportWaveRT;
friend EXT_CALLBACK TimerNotifyRT;
protected:
CMiniportWaveRT* m_pMiniport;
ULONG m_ulPin;
BOOLEAN m_bCapture;
BOOLEAN m_bUnregisterStream;
ULONG m_ulDmaBufferSize;
BYTE* m_pDmaBuffer;
ULONG m_ulNotificationsPerBuffer;
KSSTATE m_KsState;
PKTIMER m_pTimer;
PRKDPC m_pDpc;
ULONGLONG m_ullPlayPosition;
ULONGLONG m_ullWritePosition;
ULONGLONG m_ullLinearPosition;
ULONGLONG m_ullPresentationPosition;
ULONG m_ulLastOsReadPacket;
ULONG m_ulLastOsWritePacket;
LONGLONG m_llPacketCounter;
ULONGLONG m_ullDmaTimeStamp;
LARGE_INTEGER m_ullPerformanceCounterFrequency;
ULONGLONG m_hnsElapsedTimeCarryForward;
ULONGLONG m_ullLastDPCTimeStamp;
ULONGLONG m_hnsDPCTimeCarryForward;
ULONG m_byteDisplacementCarryForward;
ULONG m_ulDmaMovementRate;
BOOL m_bLfxEnabled;
PBOOL m_pbMuted;
PLONG m_plVolumeLevel;
PLONG m_plPeakMeter;
PWAVEFORMATEXTENSIBLE m_pWfExt;
ULONG m_ulContentId;
CSaveData m_SaveData;
ToneGenerator m_ToneGenerator;
GUID m_SignalProcessingMode;
BOOLEAN m_bEoSReceived;
BOOLEAN m_bLastBufferRendered;
KSPIN_LOCK m_PositionSpinLock;
// Member variable as config params for tone generator
ULONG m_ulHostCaptureToneFrequency;
// If abs(m_dwHostCaptureToneAmplitude) + abs(m_dwHostCaptureToneDCValue) > 100
// m_dwHostCaptureToneDCValue will be compensated to make the sum equal to 100
DWORD m_dwHostCaptureToneAmplitude; // must be between -100 to 100
DWORD m_dwLoopbackCaptureToneAmplitude; // must be between -100 to 100
DWORD m_dwHostCaptureToneDCOffset; // must be between -100 to 100
DWORD m_dwLoopbackCaptureToneDCOffset; // must be between -100 to 100
DWORD m_dwHostCaptureToneInitialPhase; // must be between -31416 to 31416
DWORD m_dwLoopbackCaptureToneInitialPhase; // must be between -31416 to 31416
// Member variable as config params for tone generator
public:
//presentation
NTSTATUS GetPresentationPosition
(
_Out_ KSAUDIO_PRESENTATION_POSITION *_pPresentationPosition
);
ULONG GetCurrentWaveRTWritePosition()
{
return m_ulCurrentWritePosition;
};
// To support simple underrun validation.
BOOL IsCurrentWaveRTWritePositionUpdated()
{
return InterlockedExchange(&m_IsCurrentWritePositionUpdated, 0) ? TRUE : FALSE;
};
GUID GetSignalProcessingMode()
{
return m_SignalProcessingMode;
}
private:
//
// Helper functions.
//
#pragma code_seg()
VOID WriteBytes
(
_In_ ULONG ByteDisplacement
);
VOID ReadBytes
(
_In_ ULONG ByteDisplacement
);
VOID UpdatePosition
(
_In_ LARGE_INTEGER ilQPC
);
NTSTATUS SetCurrentWritePositionInternal
(
_In_ ULONG ulCurrentWritePosition
);
NTSTATUS GetPositions
(
_Out_opt_ ULONGLONG * _pullLinearBufferPosition,
_Out_opt_ ULONGLONG * _pullPresentationPosition,
_Out_opt_ LARGE_INTEGER * _pliQPCTime
);
NTSTATUS ReadRegistrySettings();
};
typedef CMiniportWaveRTStream *PCMiniportWaveRTStream;
#endif // _SIMPLEAUDIOSAMPLE_MINWAVERTSTREAM_H_
|