PageRenderTime 53ms CodeModel.GetById 50ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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