PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Mixer/Samples.xs

http://github.com/PerlGameDev/SDL
Unknown | 137 lines | 110 code | 27 blank | 0 comment | 0 complexity | b68d125f37294c1ed12c44a744a34889 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
 23
 24
 25MODULE = SDL::Mixer::Samples 	PACKAGE = SDL::Mixer::Samples    PREFIX = mixsam_
 26
 27=for documentation
 28
 29SDL_mixer bindings
 30
 31See: http:/*www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html */
 32
 33=cut
 34
 35#ifdef HAVE_SDL_MIXER
 36
 37
 38#if (SDL_MIXER_MAJOR_VERSION >= 1 && SDL_MIXER_MINOR_VERSION >= 2 && SDL_MIXER_PATCHLEVEL >= 10)
 39
 40int 
 41mixsam_get_num_chunk_decoders()
 42	CODE:
 43		RETVAL = Mix_GetNumChunkDecoders();
 44	OUTPUT:
 45		RETVAL
 46
 47char * 
 48mixsam_get_chunk_decoder( index )
 49	int index
 50	CODE:
 51		RETVAL = (char *)Mix_GetChunkDecoder(index);
 52	OUTPUT:
 53		RETVAL
 54
 55#else
 56
 57int
 58mixsam_get_num_chunk_decoders( )
 59	CODE:
 60		warn("SDL_mixer >= 1.2.10 needed for SDL::Mixer::Samples::get_num_chunk_decoders()");
 61		XSRETURN_UNDEF;
 62	OUTPUT:
 63		RETVAL
 64
 65char *
 66mixsam_get_chunk_decoder( index )
 67	int index
 68	CODE:
 69		warn("SDL_mixer >= 1.2.10 needed for SDL::Mixer::Samples::get_chunk_decoder( index )");
 70		XSRETURN_UNDEF;
 71	OUTPUT:
 72		RETVAL
 73
 74#endif
 75
 76Mix_Chunk *
 77mixsam_load_WAV ( filename )
 78	char *filename
 79	PREINIT:
 80		char * CLASS = "SDL::Mixer::MixChunk";
 81	CODE:
 82		Mix_Chunk * mixchunk;
 83		mixchunk = Mix_LoadWAV(filename);
 84		RETVAL = mixchunk;
 85	OUTPUT:
 86		RETVAL
 87
 88Mix_Chunk *
 89mixsam_load_WAV_RW ( src, freesrc)
 90	SDL_RWops * src
 91	int freesrc
 92	PREINIT:
 93		char * CLASS = "SDL::Mixer::MixChunk";
 94	CODE:
 95		Mix_Chunk * mixchunk;
 96		mixchunk = Mix_LoadWAV_RW(src, freesrc);
 97		RETVAL = mixchunk;
 98	OUTPUT:
 99		RETVAL
100
101Mix_Chunk *
102mixsam_quick_load_WAV ( buf )
103	Uint8 *buf
104	PREINIT:
105		char * CLASS = "SDL::Mixer::MixChunk";
106	CODE:
107		RETVAL = Mix_QuickLoad_WAV(buf);
108	OUTPUT:
109		RETVAL
110
111Mix_Chunk *
112mixsam_quick_load_RAW ( buf , len)
113	Uint8 *buf
114	int len
115	PREINIT:
116		char * CLASS = "SDL::Mixer::MixChunk";
117	CODE:
118		RETVAL = Mix_QuickLoad_RAW( buf, len );
119	OUTPUT:
120		RETVAL
121
122int
123mixsam_volume_chunk ( chunk, volume )
124	Mix_Chunk *chunk
125	int volume
126	CODE:
127		RETVAL = Mix_VolumeChunk(chunk,volume);
128	OUTPUT:
129		RETVAL
130
131void
132mixsam_free_chunk( chunk )
133	Mix_Chunk *chunk
134	CODE:
135		Mix_FreeChunk(chunk);
136
137#endif