File: XAPOBase.cpp

package info (click to toggle)
faudio 21.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,576 kB
  • sloc: ansic: 25,642; cpp: 10,815; cs: 1,899; sh: 82; makefile: 21
file content (292 lines) | stat: -rw-r--r-- 6,600 bytes parent folder | download
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#include "XAPOBase.h"
#include <assert.h>

///////////////////////////////////////////////////////////////////////////////
//
// CXAPOBase
//

void* CDECL XAPOBase_INTERNAL_Malloc(size_t size)
{
	return CoTaskMemAlloc(size);
}
void CDECL XAPOBase_INTERNAL_Free(void* ptr)
{
	CoTaskMemFree(ptr);
}
void* CDECL XAPOBase_INTERNAL_Realloc(void* ptr, size_t size)
{
	return CoTaskMemRealloc(ptr, size);
}

CXAPOBase::CXAPOBase(FAPOBase *base) 
	: fapo_base(base), 
	  own_fapo_base(false) 
{
}

CXAPOBase::CXAPOBase(const XAPO_REGISTRATION_PROPERTIES* pRegistrationProperties,
	BYTE* pParameterBlocks,
	UINT32 uParameterBlockByteSize,
	BOOL fProducer) 
	: fapo_base(new FAPOBase()),
	own_fapo_base(true) 
{
	CreateFAPOBaseWithCustomAllocatorEXT(
		fapo_base,
		pRegistrationProperties,
		pParameterBlocks,
		uParameterBlockByteSize,
		fProducer,
		XAPOBase_INTERNAL_Malloc,
		XAPOBase_INTERNAL_Free,
		XAPOBase_INTERNAL_Realloc
	);
}

CXAPOBase::~CXAPOBase() 
{
	if (own_fapo_base) 
	{
		delete fapo_base;
	} 
	else if (fapo_base->Destructor) 
	{
		fapo_base->Destructor(fapo_base);
	}
}

HRESULT CXAPOBase::QueryInterface(REFIID riid, void** ppInterface) 
{
	if (guid_equals(riid, IID_IXAPO))
	{
		*ppInterface = static_cast<IXAPO *>(this);
	} 
	else if (guid_equals(riid, IID_IUnknown))
	{
		*ppInterface = static_cast<IUnknown *>(this);
	} 
	else 
	{
		*ppInterface = NULL;
		return E_NOINTERFACE;
	}

	reinterpret_cast<IUnknown *>(*ppInterface)->AddRef();

	return S_OK;
}

ULONG CXAPOBase::AddRef() 
{
	return FAPOBase_AddRef(fapo_base);
}

ULONG CXAPOBase::Release() 
{
	ULONG refcount = FAPOBase_Release(fapo_base);
	if (refcount == 0) 
	{
		delete this;
	}

	return refcount;
}

HRESULT CXAPOBase::GetRegistrationProperties(XAPO_REGISTRATION_PROPERTIES** ppRegistrationProperties) 
{
	assert(fapo_base->base.GetRegistrationProperties != NULL);
	return fapo_base->base.GetRegistrationProperties(fapo_base, ppRegistrationProperties);
}

HRESULT CXAPOBase::IsInputFormatSupported(
	const WAVEFORMATEX* pOutputFormat,
	const WAVEFORMATEX* pRequestedInputFormat,
	WAVEFORMATEX** ppSupportedInputFormat
) {
	assert(fapo_base->base.IsInputFormatSupported != NULL);
	return fapo_base->base.IsInputFormatSupported(
		fapo_base, 
		pOutputFormat, 
		pRequestedInputFormat, 
		ppSupportedInputFormat);
}

HRESULT CXAPOBase::IsOutputFormatSupported(
	const WAVEFORMATEX* pInputFormat,
	const WAVEFORMATEX* pRequestedOutputFormat,
	WAVEFORMATEX** ppSupportedOutputFormat
) {
	assert(fapo_base->base.IsOutputFormatSupported != NULL);
	return fapo_base->base.IsOutputFormatSupported(
		fapo_base, 
		pInputFormat, 
		pRequestedOutputFormat, 
		ppSupportedOutputFormat);
}

HRESULT CXAPOBase::Initialize(const void*pData, UINT32 DataByteSize) 
{
	assert(fapo_base->base.Initialize != NULL);
	return fapo_base->base.Initialize(fapo_base, pData, DataByteSize);
}

void CXAPOBase::Reset() 
{
	assert(fapo_base->base.Reset != NULL);
	fapo_base->base.Reset(fapo_base);
}

HRESULT CXAPOBase::LockForProcess(
	UINT32 InputLockedParameterCount,
	const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS* pInputLockedParameters,
	UINT32 OutputLockedParameterCount,
	const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS* pOutputLockedParameters
) {
	assert(fapo_base->base.LockForProcess != NULL);
	return fapo_base->base.LockForProcess(
		fapo_base, 
		InputLockedParameterCount, 
		pInputLockedParameters, 
		OutputLockedParameterCount, 
		pOutputLockedParameters);
}

void CXAPOBase::UnlockForProcess() 
{
	assert(fapo_base->base.UnlockForProcess != NULL);
	fapo_base->base.UnlockForProcess(fapo_base);
}

UINT32 CXAPOBase::CalcInputFrames(UINT32 OutputFrameCount) 
{
	assert(fapo_base->base.CalcInputFrames != NULL);
	return fapo_base->base.CalcInputFrames(fapo_base, OutputFrameCount);
}

UINT32 CXAPOBase::CalcOutputFrames(UINT32 InputFrameCount) 
{
	assert(fapo_base->base.CalcOutputFrames != NULL);
	return fapo_base->base.CalcOutputFrames(fapo_base, InputFrameCount);
}

// protected functions
HRESULT CXAPOBase::ValidateFormatDefault(WAVEFORMATEX* pFormat, BOOL fOverwrite) 
{
	return FAPOBase_ValidateFormatDefault(fapo_base, pFormat, fOverwrite);
}

HRESULT CXAPOBase::ValidateFormatPair(
	const WAVEFORMATEX* pSupportedFormat,
	WAVEFORMATEX* pRequestedFormat,
	BOOL fOverwrite
) {
	return FAPOBase_ValidateFormatPair(
		fapo_base, 
		pSupportedFormat, 
		pRequestedFormat, 
		fOverwrite);
}

void CXAPOBase::ProcessThru(
	void* pInputBuffer,
	FLOAT32* pOutputBuffer,
	UINT32 FrameCount,
	WORD InputChannelCount,
	WORD OutputChannelCount,
	BOOL MixWithOutput) 
{
	FAPOBase_ProcessThru(
		fapo_base, 
		pInputBuffer, 
		pOutputBuffer, 
		FrameCount, 
		InputChannelCount, 
		OutputChannelCount, 
		MixWithOutput);
}

BOOL CXAPOBase::IsLocked() 
{
	return fapo_base->m_fIsLocked;
}

///////////////////////////////////////////////////////////////////////////////
//
// CXAPOParametersBase
//

CXAPOParametersBase::CXAPOParametersBase(FAPOBase *base)
	: CXAPOBase(base) 
{
}

CXAPOParametersBase::CXAPOParametersBase(
	const XAPO_REGISTRATION_PROPERTIES* pRegistrationProperties,
	BYTE* pParameterBlocks,
	UINT32 uParameterBlockByteSize,
	BOOL fProducer) 
	: CXAPOBase(pRegistrationProperties, pParameterBlocks,
		uParameterBlockByteSize, fProducer)
{
}

CXAPOParametersBase::~CXAPOParametersBase() 
{
}

HRESULT CXAPOParametersBase::QueryInterface(REFIID riid, void** ppInterface) 
{
	if (guid_equals(riid, IID_IXAPOParameters))
	{
		*ppInterface = static_cast<IXAPOParameters *>(this);
		CXAPOBase::AddRef();
		return S_OK;
	} 
	else 
	{
		return CXAPOBase::QueryInterface(riid, ppInterface);
	}
}

ULONG CXAPOParametersBase::AddRef() 
{
	return CXAPOBase::AddRef();
}

ULONG CXAPOParametersBase::Release() 
{
	return CXAPOBase::Release();
}

void CXAPOParametersBase::SetParameters(const void* pParameters, UINT32 ParameterByteSize) 
{
	assert(fapo_base->base.SetParameters);
	fapo_base->base.SetParameters(fapo_base, pParameters, ParameterByteSize);
}

void CXAPOParametersBase::GetParameters(void* pParameters, UINT32 ParameterByteSize) {
	assert(fapo_base->base.GetParameters);
	fapo_base->base.GetParameters(fapo_base, pParameters, ParameterByteSize);
}

void CXAPOParametersBase::OnSetParameters(const void* pParameters, UINT32 ParameterByteSize) 
{
	assert(fapo_base->OnSetParameters);
	fapo_base->OnSetParameters(fapo_base, pParameters, ParameterByteSize);
}

BOOL CXAPOParametersBase::ParametersChanged() 
{
	return FAPOBase_ParametersChanged(fapo_base);
}

BYTE* CXAPOParametersBase::BeginProcess() 
{
	return FAPOBase_BeginProcess(fapo_base);
}

void CXAPOParametersBase::EndProcess() 
{
	FAPOBase_EndProcess(fapo_base);
}