null.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. /* This destructs (not free!) the effect state. It's called only when the
  12. * effect slot is no longer used.
  13. */
  14. static ALvoid ALnullState_Destruct(ALnullState* UNUSED(state))
  15. {
  16. }
  17. /* This updates the device-dependant effect state. This is called on
  18. * initialization and any time the device parameters (eg. playback frequency,
  19. * format) have been changed.
  20. */
  21. static ALboolean ALnullState_deviceUpdate(ALnullState* UNUSED(state), ALCdevice* UNUSED(device))
  22. {
  23. return AL_TRUE;
  24. }
  25. /* This updates the effect state. This is called any time the effect is
  26. * (re)loaded into a slot.
  27. */
  28. static ALvoid ALnullState_update(ALnullState* UNUSED(state), ALCdevice* UNUSED(device), const ALeffectslot* UNUSED(slot))
  29. {
  30. }
  31. /* This processes the effect state, for the given number of samples from the
  32. * input to the output buffer. The result should be added to the output buffer,
  33. * not replace it.
  34. */
  35. static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALuint UNUSED(samplesToDo), const ALfloat *restrict UNUSED(samplesIn), ALfloatBUFFERSIZE*restrict UNUSED(samplesOut), ALuint UNUSED(NumChannels))
  36. {
  37. }
  38. /* This allocates memory to store the object, before it gets constructed.
  39. * DECLARE_DEFAULT_ALLOCATORS can be used to declate a default method.
  40. */
  41. static void *ALnullState_New(size_t size)
  42. {
  43. return malloc(size);
  44. }
  45. /* This frees the memory used by the object, after it has been destructed.
  46. * DECLARE_DEFAULT_ALLOCATORS can be used to declate a default method.
  47. */
  48. static void ALnullState_Delete(void *ptr)
  49. {
  50. free(ptr);
  51. }
  52. /* Define the forwards and the ALeffectState vtable for this type. */
  53. DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
  54. typedef struct ALnullStateFactory {
  55. DERIVE_FROM_TYPE(ALeffectStateFactory);
  56. } ALnullStateFactory;
  57. /* Creates ALeffectState objects of the appropriate type. */
  58. ALeffectState *ALnullStateFactory_create(ALnullStateFactory *UNUSED(factory))
  59. {
  60. ALnullState *state;
  61. state = ALnullState_New(sizeof(*state));
  62. if(!state) return NULL;
  63. /* Set vtables for inherited types. */
  64. SET_VTABLE2(ALnullState, ALeffectState, state);
  65. return STATIC_CAST(ALeffectState, state);
  66. }
  67. /* Define the ALeffectStateFactory vtable for this type. */
  68. DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
  69. ALeffectStateFactory *ALnullStateFactory_getFactory(void)
  70. {
  71. static ALnullStateFactory NullFactory = { { GET_VTABLE2(ALnullStateFactory, ALeffectStateFactory) } };
  72. return STATIC_CAST(ALeffectStateFactory, &NullFactory);
  73. }
  74. void ALnull_setParami(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val))
  75. {
  76. switch(param)
  77. {
  78. default:
  79. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  80. }
  81. }
  82. void ALnull_setParamiv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals))
  83. {
  84. switch(param)
  85. {
  86. default:
  87. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  88. }
  89. }
  90. void ALnull_setParamf(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
  91. {
  92. switch(param)
  93. {
  94. default:
  95. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  96. }
  97. }
  98. void ALnull_setParamfv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals))
  99. {
  100. switch(param)
  101. {
  102. default:
  103. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  104. }
  105. }
  106. void ALnull_getParami(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val))
  107. {
  108. switch(param)
  109. {
  110. default:
  111. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  112. }
  113. }
  114. void ALnull_getParamiv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals))
  115. {
  116. switch(param)
  117. {
  118. default:
  119. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  120. }
  121. }
  122. void ALnull_getParamf(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val))
  123. {
  124. switch(param)
  125. {
  126. default:
  127. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  128. }
  129. }
  130. void ALnull_getParamfv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals))
  131. {
  132. switch(param)
  133. {
  134. default:
  135. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  136. }
  137. }
  138. DEFINE_ALEFFECT_VTABLE(ALnull);