/src/Mixer/objects/MixChunk.xs

http://github.com/PerlGameDev/SDL · Unknown · 66 lines · 51 code · 15 blank · 0 comment · 0 complexity · f374c94f87a0a23f5fa6c51bb882ce84 MD5 · raw file

  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include "ppport.h"
  5. #include "helper.h"
  6. #include "defines.h"
  7. #ifndef aTHX_
  8. #define aTHX_
  9. #endif
  10. #include <SDL.h>
  11. #ifdef HAVE_SDL_MIXER
  12. #include <SDL_mixer.h>
  13. void _free_mixchunk(void *object)
  14. {
  15. /* int allocated: if 1 struct has its own allocated buffer, if 0 abuf should not be freed */
  16. if(((Mix_Chunk *)object)->allocated)
  17. Mix_FreeChunk((Mix_Chunk *)object);
  18. }
  19. #endif
  20. MODULE = SDL::Mixer::MixChunk PACKAGE = SDL::Mixer::MixChunk PREFIX = mixchunk_
  21. =for documentation
  22. SDL_MixChunk - Stores audio data in memory
  23. typedef struct {
  24. int allocated;
  25. Uint8 *abuf;
  26. Uint32 alen;
  27. Uint8 volume;
  28. } Mix_Chunk;
  29. =cut
  30. #ifdef HAVE_SDL_MIXER
  31. Uint32
  32. mixchunk_alen ( mixchunk )
  33. Mix_Chunk *mixchunk
  34. CODE:
  35. RETVAL = mixchunk->alen;
  36. OUTPUT:
  37. RETVAL
  38. Uint8
  39. mixchunk_volume ( mixchunk, ... )
  40. Mix_Chunk *mixchunk
  41. CODE:
  42. if (items > 1 ) mixchunk->volume = SvIV(ST(1));
  43. RETVAL = mixchunk->volume;
  44. OUTPUT:
  45. RETVAL
  46. void
  47. mixchunk_DESTROY(bag)
  48. SV *bag
  49. CODE:
  50. objDESTROY(bag, _free_mixchunk);
  51. #endif