File: XAPOFX.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 (90 lines) | stat: -rw-r--r-- 1,785 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
#include "xaudio2.h"
#include "XAPOBase.h"
#include "XAPOFX.h"

class XAPOFXWrapper : public CXAPOParametersBase
{
public:
	XAPOFXWrapper(void *object) :
		fapo_object(object),
		CXAPOParametersBase(reinterpret_cast<FAPOBase*>(object))
	{
	}

	COM_METHOD(void) Process(
		UINT32 InputProcessParameterCount,
		const XAPO_PROCESS_BUFFER_PARAMETERS *pInputProcessParameters,
		UINT32 OutputProcessParameterCount,
		XAPO_PROCESS_BUFFER_PARAMETERS *pOutputProcessParameters,
		BOOL IsEnabled
	) {
		reinterpret_cast<FAPO*>(fapo_object)->Process(
			fapo_object,
			InputProcessParameterCount,
			pInputProcessParameters,
			OutputProcessParameterCount,
			pOutputProcessParameters,
			IsEnabled
		);
	}

private:
	void *fapo_object;
};

void* CDECL XAPOFX_INTERNAL_Malloc(size_t size)
{
	return CoTaskMemAlloc(size);
}
void CDECL XAPOFX_INTERNAL_Free(void* ptr)
{
	CoTaskMemFree(ptr);
}
void* CDECL XAPOFX_INTERNAL_Realloc(void* ptr, size_t size)
{
	return CoTaskMemRealloc(ptr, size);
}

void* CreateFXInternal(
	REFCLSID clsid,
	const void *pInitData,
	uint32_t InitDataByteSize
) {
	FAPO *fapo_object = NULL;
	FAPOFX_CreateFXWithCustomAllocatorEXT(
		&clsid,
		&fapo_object,
		pInitData,
		InitDataByteSize,
		XAPOFX_INTERNAL_Malloc,
		XAPOFX_INTERNAL_Free,
		XAPOFX_INTERNAL_Realloc
	);
	return new XAPOFXWrapper(fapo_object);
}

#if XAUDIO2_VERSION >=8
FAPOFXCPP_API CreateFX(
	REFCLSID clsid,
	IUnknown **pEffect,
	const void *pInitData,
	UINT32 InitDataByteSize
) {
	*pEffect = reinterpret_cast<IUnknown*>(CreateFXInternal(
		clsid,
		pInitData,
		InitDataByteSize
	));
	return S_OK;
}
#else
FAPOFXCPP_API CreateFX(REFCLSID clsid, IUnknown **pEffect)
{
	*pEffect = reinterpret_cast<IUnknown*>(CreateFXInternal(
		clsid,
		NULL,
		0
	));
	return S_OK;
}
#endif // XAUDIO2_VERSION >=8