/src/Mixer/Mixer.xs

http://github.com/PerlGameDev/SDL · Unknown · 118 lines · 91 code · 27 blank · 0 comment · 0 complexity · c6f789dcc21ffaff37545b9a1d54e027 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. #ifdef HAVE_SDL_MIXER
  10. #include <SDL_mixer.h>
  11. #endif
  12. #ifdef HAVE_SMPEG
  13. #include <smpeg/smpeg.h>
  14. #ifdef HAVE_SDL_MIXER
  15. static int sdl_perl_use_smpeg_audio = 0;
  16. #endif
  17. #endif
  18. MODULE = SDL::Mixer PACKAGE = SDL::Mixer PREFIX = mixer_
  19. =for documentation
  20. SDL_mixer bindings
  21. See: http:/*www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html */
  22. =cut
  23. #ifdef HAVE_SDL_MIXER
  24. #if (SDL_MIXER_MAJOR_VERSION >= 1) && (SDL_MIXER_MINOR_VERSION >= 2) && (SDL_MIXER_PATCHLEVEL >= 10)
  25. int
  26. mixer_init( flags )
  27. int flags
  28. CODE:
  29. RETVAL = Mix_Init(flags);
  30. OUTPUT:
  31. RETVAL
  32. void
  33. mixer_quit()
  34. CODE:
  35. Mix_Quit();
  36. #else
  37. int
  38. mixer_init( flags )
  39. int flags
  40. CODE:
  41. warn("SDL_mixer >= 1.2.10 needed for SDL::Mixer::init( flags )");
  42. XSRETURN_UNDEF;
  43. OUTPUT:
  44. RETVAL
  45. void
  46. mixer_quit( index )
  47. CODE:
  48. warn("SDL_mixer >= 1.2.10 needed for SDL::Mixer::quit()");
  49. #endif
  50. const SDL_version *
  51. mixer_linked_version ()
  52. PREINIT:
  53. char* CLASS = "SDL::Version";
  54. SDL_version *version;
  55. CODE:
  56. version = (SDL_version *) safemalloc ( sizeof(SDL_version) );
  57. SDL_version* version_dont_free = (SDL_version *)Mix_Linked_Version();
  58. version->major = version_dont_free->major;
  59. version->minor = version_dont_free->minor;
  60. version->patch = version_dont_free->patch;
  61. RETVAL = version;
  62. OUTPUT:
  63. RETVAL
  64. int
  65. mixer_open_audio ( frequency, format, channels, chunksize )
  66. int frequency
  67. Uint16 format
  68. int channels
  69. int chunksize
  70. CODE:
  71. RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
  72. OUTPUT:
  73. RETVAL
  74. void
  75. mixer_close_audio ()
  76. CODE:
  77. Mix_CloseAudio();
  78. AV *
  79. mixer_query_spec ()
  80. CODE:
  81. int freq, channels, status;
  82. Uint16 format;
  83. status = Mix_QuerySpec(&freq,&format,&channels);
  84. RETVAL = (AV*)sv_2mortal((SV*)newAV());
  85. av_push(RETVAL,newSViv(status));
  86. av_push(RETVAL,newSViv(freq));
  87. av_push(RETVAL,newSViv(format));
  88. av_push(RETVAL,newSViv(channels));
  89. OUTPUT:
  90. RETVAL
  91. #endif