PageRenderTime 61ms CodeModel.GetById 56ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 8#ifndef aTHX_
 9#define aTHX_
10#endif
11
12#include <SDL.h>
13
14#ifdef HAVE_SDL_MIXER
15#include <SDL_mixer.h>
16
17void _free_mixchunk(void *object)
18{
19	/* int allocated: if 1 struct has its own allocated buffer, if 0 abuf should not be freed */
20	if(((Mix_Chunk *)object)->allocated)
21		Mix_FreeChunk((Mix_Chunk *)object);
22}
23
24#endif
25
26MODULE = SDL::Mixer::MixChunk 	PACKAGE = SDL::Mixer::MixChunk    PREFIX = mixchunk_
27
28=for documentation
29
30SDL_MixChunk - Stores audio data in memory
31
32  typedef struct {
33          int allocated;
34          Uint8 *abuf;
35          Uint32 alen;
36          Uint8 volume;
37  } Mix_Chunk;
38
39=cut
40
41#ifdef HAVE_SDL_MIXER
42
43Uint32
44mixchunk_alen ( mixchunk )
45	Mix_Chunk *mixchunk
46	CODE:
47		RETVAL = mixchunk->alen;
48	OUTPUT:
49		RETVAL
50
51Uint8
52mixchunk_volume ( mixchunk, ... )
53	Mix_Chunk *mixchunk
54	CODE:
55		if (items > 1 ) mixchunk->volume = SvIV(ST(1)); 
56		RETVAL = mixchunk->volume;
57	OUTPUT:
58		RETVAL
59
60void
61mixchunk_DESTROY(bag)
62	SV *bag
63	CODE:
64		objDESTROY(bag, _free_mixchunk);
65
66#endif