null.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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), ALfloat (*restrict samplesOut)[BUFFERSIZE])
  36. {
  37. /* NOTE: Couldn't use the UNUSED macro on samplesOut due to the way GCC's
  38. * __attribute__ declaration interacts with the parenthesis. */
  39. (void)samplesOut;
  40. }
  41. /* This frees the memory used by the object, after it has been destructed. */
  42. static void ALnullState_Delete(ALnullState *state)
  43. {
  44. free(state);
  45. }
  46. /* Define the forwards and the ALeffectState vtable for this type. */
  47. DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
  48. typedef struct ALnullStateFactory {
  49. DERIVE_FROM_TYPE(ALeffectStateFactory);
  50. } ALnullStateFactory;
  51. /* Creates ALeffectState objects of the appropriate type. */
  52. ALeffectState *ALnullStateFactory_create(ALnullStateFactory *UNUSED(factory))
  53. {
  54. ALnullState *state;
  55. state = calloc(1, sizeof(*state));
  56. if(!state) return NULL;
  57. /* Set vtables for inherited types. */
  58. SET_VTABLE2(ALnullState, ALeffectState, state);
  59. return STATIC_CAST(ALeffectState, state);
  60. }
  61. /* Define the ALeffectStateFactory vtable for this type. */
  62. DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
  63. ALeffectStateFactory *ALnullStateFactory_getFactory(void)
  64. {
  65. static ALnullStateFactory NullFactory = { { GET_VTABLE2(ALnullStateFactory, ALeffectStateFactory) } };
  66. return STATIC_CAST(ALeffectStateFactory, &NullFactory);
  67. }
  68. void ALnull_setParami(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val))
  69. {
  70. switch(param)
  71. {
  72. default:
  73. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  74. }
  75. }
  76. void ALnull_setParamiv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals))
  77. {
  78. switch(param)
  79. {
  80. default:
  81. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  82. }
  83. }
  84. void ALnull_setParamf(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
  85. {
  86. switch(param)
  87. {
  88. default:
  89. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  90. }
  91. }
  92. void ALnull_setParamfv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals))
  93. {
  94. switch(param)
  95. {
  96. default:
  97. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  98. }
  99. }
  100. void ALnull_getParami(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val))
  101. {
  102. switch(param)
  103. {
  104. default:
  105. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  106. }
  107. }
  108. void ALnull_getParamiv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals))
  109. {
  110. switch(param)
  111. {
  112. default:
  113. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  114. }
  115. }
  116. void ALnull_getParamf(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val))
  117. {
  118. switch(param)
  119. {
  120. default:
  121. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  122. }
  123. }
  124. void ALnull_getParamfv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals))
  125. {
  126. switch(param)
  127. {
  128. default:
  129. SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
  130. }
  131. }
  132. DEFINE_ALEFFECT_VTABLE(ALnull);