/src/Core/objects/AudioCVT.xs

http://github.com/PerlGameDev/SDL · Unknown · 162 lines · 144 code · 18 blank · 0 comment · 0 complexity · 830bd9fd86681c9e6207dfdf4e216d08 MD5 · raw file

  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include "ppport.h"
  5. #ifndef aTHX_
  6. #define aTHX_
  7. #endif
  8. #include <SDL.h>
  9. #include <SDL_audio.h>
  10. =for documentation
  11. typedef struct{
  12. int needed;
  13. Uint16 src_format;
  14. Uint16 dest_format;
  15. double rate_incr;
  16. Uint8 *buf;
  17. int len;
  18. int len_cvt;
  19. int len_mult;
  20. double len_ratio;
  21. void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
  22. int filter_index;
  23. } SDL_AudioCVT;
  24. =cut
  25. MODULE = SDL::AudioCVT PACKAGE = SDL::AudioCVT PREFIX = audiocvt_
  26. SDL_AudioCVT*
  27. audiocvt_new(CLASS)
  28. char* CLASS
  29. CODE:
  30. RETVAL = safemalloc(sizeof(SDL_AudioCVT));
  31. OUTPUT:
  32. RETVAL
  33. SDL_AudioCVT*
  34. audiocvt_build(CLASS, src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)
  35. char* CLASS
  36. Uint16 src_format
  37. Uint8 src_channels
  38. int src_rate
  39. Uint16 dst_format
  40. Uint8 dst_channels
  41. int dst_rate
  42. CODE:
  43. RETVAL = (SDL_AudioCVT *)safemalloc(sizeof(SDL_AudioCVT));
  44. if(SDL_BuildAudioCVT(RETVAL, src_format, src_channels, src_rate,
  45. dst_format, dst_channels, dst_rate))
  46. {
  47. safefree(RETVAL);
  48. RETVAL = NULL;
  49. }
  50. OUTPUT:
  51. RETVAL
  52. int
  53. audiocvt_needed(self, ...)
  54. SDL_AudioCVT* self
  55. CODE:
  56. if( items > 1 )
  57. {
  58. self->needed = SvIV( ST(1) );
  59. }
  60. RETVAL = self->needed;
  61. OUTPUT:
  62. RETVAL
  63. Uint16
  64. audiocvt_src_format(self, ...)
  65. SDL_AudioCVT* self
  66. CODE:
  67. if( items > 1 )
  68. {
  69. self->src_format = SvIV( ST(1) );
  70. }
  71. RETVAL = self->src_format;
  72. OUTPUT:
  73. RETVAL
  74. Uint16
  75. audiocvt_dest_format(self, ...)
  76. SDL_AudioCVT* self
  77. CODE:
  78. if( items > 1 )
  79. {
  80. self->dst_format = SvIV( ST(1) );
  81. }
  82. RETVAL = self->dst_format;
  83. OUTPUT:
  84. RETVAL
  85. double
  86. audiocvt_rate_incr(self, ...)
  87. SDL_AudioCVT* self
  88. CODE:
  89. if( items > 1 )
  90. {
  91. self->rate_incr = SvIV( ST(1) );
  92. }
  93. RETVAL = self->rate_incr;
  94. OUTPUT:
  95. RETVAL
  96. int
  97. audiocvt_len(self, ...)
  98. SDL_AudioCVT* self
  99. CODE:
  100. if( items > 1 )
  101. {
  102. self->len = SvIV( ST(1) );
  103. }
  104. RETVAL = self->len;
  105. OUTPUT:
  106. RETVAL
  107. int
  108. audiocvt_len_cvt(self, ...)
  109. SDL_AudioCVT* self
  110. CODE:
  111. if( items > 1 )
  112. {
  113. self->len_cvt = SvIV( ST(1) );
  114. }
  115. RETVAL = self->len_cvt;
  116. OUTPUT:
  117. RETVAL
  118. int
  119. audiocvt_len_mult(self, ...)
  120. SDL_AudioCVT* self
  121. CODE:
  122. if( items > 1 )
  123. {
  124. self->len_mult = SvIV( ST(1) );
  125. }
  126. RETVAL = self->len_mult;
  127. OUTPUT:
  128. RETVAL
  129. int
  130. audiocvt_len_ratio(self, ...)
  131. SDL_AudioCVT* self
  132. CODE:
  133. if( items > 1 )
  134. {
  135. self->len_ratio = SvIV( ST(1) );
  136. }
  137. RETVAL = self->len_ratio;
  138. OUTPUT:
  139. RETVAL
  140. void
  141. audiocvt_DESTROY(self)
  142. SDL_AudioCVT* self
  143. CODE:
  144. safefree(self);