null.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #include "config.h"
  2. #include <stdlib.h>
  3. #include "AL/al.h"
  4. #include "AL/alc.h"
  5. #include "alMain.h"
  6. #include "alAuxEffectSlot.h"
  7. #include "alError.h"
  8. typedef struct ALnullState {
  9. DERIVE_FROM_TYPE(ALeffectState);
  10. } ALnullState;
  11. /* Forward-declare "virtual" functions to define the vtable with. */
  12. static ALvoid ALnullState_Destruct(ALnullState *state);
  13. static ALboolean ALnullState_deviceUpdate(ALnullState *state, ALCdevice *device);
  14. static ALvoid ALnullState_update(ALnullState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props);
  15. static ALvoid ALnullState_process(ALnullState *state, ALuint samplesToDo, const ALfloatBUFFERSIZE*restrict samplesIn, ALfloatBUFFERSIZE*restrict samplesOut, ALuint NumChannels);
  16. static void *ALnullState_New(size_t size);
  17. static void ALnullState_Delete(void *ptr);
  18. /* Define the ALeffectState vtable for this type. */
  19. DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
  20. /* This constructs the effect state. It's called when the object is first
  21. * created. Make sure to call the parent Construct function first, and set the
  22. * vtable!
  23. */
  24. static void ALnullState_Construct(ALnullState *state)
  25. {
  26. ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
  27. SET_VTABLE2(ALnullState, ALeffectState, state);
  28. }
  29. /* This destructs (not free!) the effect state. It's called only when the
  30. * effect slot is no longer used. Make sure to call the parent Destruct
  31. * function before returning!
  32. */
  33. static ALvoid ALnullState_Destruct(ALnullState *state)
  34. {
  35. ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
  36. }
  37. /* This updates the device-dependant effect state. This is called on
  38. * initialization and any time the device parameters (eg. playback frequency,
  39. * format) have been changed.
  40. */
  41. static ALboolean ALnullState_deviceUpdate(ALnullState* UNUSED(state), ALCdevice* UNUSED(device))
  42. {
  43. return AL_TRUE;
  44. }
  45. /* This updates the effect state. This is called any time the effect is
  46. * (re)loaded into a slot.
  47. */
  48. static ALvoid ALnullState_update(ALnullState* UNUSED(state), const ALCdevice* UNUSED(device), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props))
  49. {
  50. }
  51. /* This processes the effect state, for the given number of samples from the
  52. * input to the output buffer. The result should be added to the output buffer,
  53. * not replace it.
  54. */
  55. static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALuint UNUSED(samplesToDo), const ALfloatBUFFERSIZE*restrict UNUSED(samplesIn), ALfloatBUFFERSIZE*restrict UNUSED(samplesOut), ALuint UNUSED(NumChannels))
  56. {
  57. }
  58. /* This allocates memory to store the object, before it gets constructed.
  59. * DECLARE_DEFAULT_ALLOCATORS can be used to declare a default method.
  60. */
  61. static void *ALnullState_New(size_t size)
  62. {
  63. return al_malloc(16, size);
  64. }
  65. /* This frees the memory used by the object, after it has been destructed.
  66. * DECLARE_DEFAULT_ALLOCATORS can be used to declare a default method.
  67. */
  68. static void ALnullState_Delete(void *ptr)
  69. {
  70. al_free(ptr);
  71. }
  72. typedef struct ALnullStateFactory {
  73. DERIVE_FROM_TYPE(ALeffectStateFactory);
  74. } ALnullStateFactory;
  75. /* Creates ALeffectState objects of the appropriate type. */
  76. ALeffectState *ALnullStateFactory_create(ALnullStateFactory *UNUSED(factory))
  77. {
  78. ALnullState *state;
  79. NEW_OBJ0(state, ALnullState)();
  80. if(!state) return NULL;
  81. return STATIC_CAST(ALeffectState, state);
  82. }
  83. /* Define the ALeffectStateFactory vtable for this type. */
  84. DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
  85. ALeffectStateFactory *ALnullStateFactory_getFactory(void)
  86. {
  87. static ALnullStateFactory NullFactory = { { GET_VTABLE2(ALnullStateFactory, ALeffectStateFactory) } };
  88. return STATIC_CAST(ALeffectStateFactory, &NullFactory);
  89. }
  90. void ALnull_setParami(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val))
  91. {
  92. switch(param)
  93. {
  94. default:
  95. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  96. }
  97. }
  98. void ALnull_setParamiv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals))
  99. {
  100. switch(param)
  101. {
  102. default:
  103. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  104. }
  105. }
  106. void ALnull_setParamf(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
  107. {
  108. switch(param)
  109. {
  110. default:
  111. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  112. }
  113. }
  114. void ALnull_setParamfv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals))
  115. {
  116. switch(param)
  117. {
  118. default:
  119. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  120. }
  121. }
  122. void ALnull_getParami(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val))
  123. {
  124. switch(param)
  125. {
  126. default:
  127. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  128. }
  129. }
  130. void ALnull_getParamiv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals))
  131. {
  132. switch(param)
  133. {
  134. default:
  135. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  136. }
  137. }
  138. void ALnull_getParamf(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val))
  139. {
  140. switch(param)
  141. {
  142. default:
  143. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  144. }
  145. }
  146. void ALnull_getParamfv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals))
  147. {
  148. switch(param)
  149. {
  150. default:
  151. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  152. }
  153. }
  154. DEFINE_ALEFFECT_VTABLE(ALnull);