faudio: Import upstream release 24.02.
[wine.git] / libs / faudio / src / FAPOFX.c
blob5e9c3b82c2122f9bcd72233824aacf939c566c64
1 /* FAudio - XAudio Reimplementation for FNA
3 * Copyright (c) 2011-2024 Ethan Lee, Luigi Auriemma, and the MonoGame Team
5 * This software is provided 'as-is', without any express or implied warranty.
6 * In no event will the authors be held liable for any damages arising from
7 * the use of this software.
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software in a
15 * product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source distribution.
23 * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
27 #include "FAPOFX.h"
28 #include "FAudio_internal.h"
30 uint32_t FAPOFX_CreateFX(
31 const FAudioGUID *clsid,
32 FAPO **pEffect,
33 const void *pInitData,
34 uint32_t InitDataByteSize
35 ) {
36 return FAPOFX_CreateFXWithCustomAllocatorEXT(
37 clsid,
38 pEffect,
39 pInitData,
40 InitDataByteSize,
41 FAudio_malloc,
42 FAudio_free,
43 FAudio_realloc
47 uint32_t FAPOFX_CreateFXWithCustomAllocatorEXT(
48 const FAudioGUID *clsid,
49 FAPO **pEffect,
50 const void *pInitData,
51 uint32_t InitDataByteSize,
52 FAudioMallocFunc customMalloc,
53 FAudioFreeFunc customFree,
54 FAudioReallocFunc customRealloc
55 ) {
56 #define CHECK_AND_RETURN(effect) \
57 if (FAudio_memcmp(clsid, &FAPOFX_CLSID_FX##effect, sizeof(FAudioGUID)) == 0) \
58 { \
59 return FAPOFXCreate##effect( \
60 pEffect, \
61 pInitData, \
62 InitDataByteSize, \
63 customMalloc, \
64 customFree, \
65 customRealloc, \
66 0 \
67 ); \
68 } \
69 else if (FAudio_memcmp(clsid, &FAPOFX_CLSID_FX##effect##_LEGACY, sizeof(FAudioGUID)) == 0) \
70 { \
71 return FAPOFXCreate##effect( \
72 pEffect, \
73 pInitData, \
74 InitDataByteSize, \
75 customMalloc, \
76 customFree, \
77 customRealloc, \
78 1 \
79 ); \
81 CHECK_AND_RETURN(EQ)
82 CHECK_AND_RETURN(MasteringLimiter)
83 CHECK_AND_RETURN(Reverb)
84 CHECK_AND_RETURN(Echo)
85 #undef CHECK_AND_RETURN
86 return -1;
89 /* vim: set noexpandtab shiftwidth=8 tabstop=8: */