alAuxEffectSlot.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef _AL_AUXEFFECTSLOT_H_
  2. #define _AL_AUXEFFECTSLOT_H_
  3. #include "alMain.h"
  4. #include "alEffect.h"
  5. #include "align.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. struct ALeffectStateVtable;
  10. struct ALeffectslot;
  11. typedef struct ALeffectState {
  12. const struct ALeffectStateVtable *vtbl;
  13. } ALeffectState;
  14. struct ALeffectStateVtable {
  15. void (*const Destruct)(ALeffectState *state);
  16. ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device);
  17. void (*const update)(ALeffectState *state, ALCdevice *device, const struct ALeffectslot *slot);
  18. void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE], ALuint numChannels);
  19. void (*const Delete)(void *ptr);
  20. };
  21. #define DEFINE_ALEFFECTSTATE_VTABLE(T) \
  22. DECLARE_THUNK(T, ALeffectState, void, Destruct) \
  23. DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
  24. DECLARE_THUNK2(T, ALeffectState, void, update, ALCdevice*, const ALeffectslot*) \
  25. DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloat*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \
  26. static void T##_ALeffectState_Delete(void *ptr) \
  27. { return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
  28. \
  29. static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \
  30. T##_ALeffectState_Destruct, \
  31. \
  32. T##_ALeffectState_deviceUpdate, \
  33. T##_ALeffectState_update, \
  34. T##_ALeffectState_process, \
  35. \
  36. T##_ALeffectState_Delete, \
  37. }
  38. struct ALeffectStateFactoryVtable;
  39. typedef struct ALeffectStateFactory {
  40. const struct ALeffectStateFactoryVtable *vtbl;
  41. } ALeffectStateFactory;
  42. struct ALeffectStateFactoryVtable {
  43. ALeffectState *(*const create)(ALeffectStateFactory *factory);
  44. };
  45. #define DEFINE_ALEFFECTSTATEFACTORY_VTABLE(T) \
  46. DECLARE_THUNK(T, ALeffectStateFactory, ALeffectState*, create) \
  47. \
  48. static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = { \
  49. T##_ALeffectStateFactory_create, \
  50. }
  51. typedef struct ALeffectslot {
  52. ALenum EffectType;
  53. ALeffectProps EffectProps;
  54. volatile ALfloat Gain;
  55. volatile ALboolean AuxSendAuto;
  56. ATOMIC(ALenum) NeedsUpdate;
  57. ALeffectState *EffectState;
  58. alignas(16) ALfloat WetBuffer[1][BUFFERSIZE];
  59. RefCount ref;
  60. /* Self ID */
  61. ALuint id;
  62. } ALeffectslot;
  63. inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
  64. { return (struct ALeffectslot*)LookupUIntMapKey(&context->EffectSlotMap, id); }
  65. inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
  66. { return (struct ALeffectslot*)RemoveUIntMapKey(&context->EffectSlotMap, id); }
  67. ALenum InitEffectSlot(ALeffectslot *slot);
  68. ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
  69. ALeffectStateFactory *ALnullStateFactory_getFactory(void);
  70. ALeffectStateFactory *ALreverbStateFactory_getFactory(void);
  71. ALeffectStateFactory *ALautowahStateFactory_getFactory(void);
  72. ALeffectStateFactory *ALchorusStateFactory_getFactory(void);
  73. ALeffectStateFactory *ALcompressorStateFactory_getFactory(void);
  74. ALeffectStateFactory *ALdistortionStateFactory_getFactory(void);
  75. ALeffectStateFactory *ALechoStateFactory_getFactory(void);
  76. ALeffectStateFactory *ALequalizerStateFactory_getFactory(void);
  77. ALeffectStateFactory *ALflangerStateFactory_getFactory(void);
  78. ALeffectStateFactory *ALmodulatorStateFactory_getFactory(void);
  79. ALeffectStateFactory *ALdedicatedStateFactory_getFactory(void);
  80. ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect);
  81. void InitEffectFactoryMap(void);
  82. void DeinitEffectFactoryMap(void);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif