PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Core/objects/AudioCVT.xs

http://github.com/PerlGameDev/SDL
Unknown | 162 lines | 144 code | 18 blank | 0 comment | 0 complexity | 830bd9fd86681c9e6207dfdf4e216d08 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#include <SDL_audio.h>
 12
 13=for documentation
 14
 15typedef struct{
 16  int needed;
 17  Uint16 src_format;
 18  Uint16 dest_format;
 19  double rate_incr;
 20  Uint8 *buf;
 21  int len;
 22  int len_cvt;
 23  int len_mult;
 24  double len_ratio;
 25  void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
 26  int filter_index;
 27} SDL_AudioCVT;
 28
 29=cut
 30
 31MODULE = SDL::AudioCVT 	PACKAGE = SDL::AudioCVT    PREFIX = audiocvt_
 32
 33SDL_AudioCVT* 
 34audiocvt_new(CLASS)
 35	char* CLASS
 36	CODE:
 37		RETVAL = safemalloc(sizeof(SDL_AudioCVT));
 38	OUTPUT:
 39		RETVAL
 40
 41SDL_AudioCVT* 
 42audiocvt_build(CLASS, src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)
 43	char* CLASS
 44	Uint16 src_format
 45	Uint8 src_channels
 46	int src_rate
 47	Uint16 dst_format
 48	Uint8 dst_channels
 49	int dst_rate
 50	CODE:
 51		RETVAL = (SDL_AudioCVT *)safemalloc(sizeof(SDL_AudioCVT));
 52		if(SDL_BuildAudioCVT(RETVAL, src_format, src_channels, src_rate,
 53		                             dst_format, dst_channels, dst_rate))
 54		{ 
 55			safefree(RETVAL);
 56			RETVAL = NULL;
 57		}
 58	OUTPUT:
 59		RETVAL
 60
 61int
 62audiocvt_needed(self, ...)
 63	SDL_AudioCVT* self
 64	CODE:
 65		if( items > 1 )
 66		{
 67			self->needed = SvIV( ST(1) );
 68		}
 69		RETVAL = self->needed;
 70	OUTPUT:
 71		RETVAL
 72
 73Uint16
 74audiocvt_src_format(self, ...)
 75	SDL_AudioCVT* self
 76	CODE:
 77		if( items > 1 )
 78		{
 79			self->src_format = SvIV( ST(1) );
 80		}
 81		RETVAL = self->src_format;
 82	OUTPUT:
 83		RETVAL
 84
 85Uint16
 86audiocvt_dest_format(self, ...)
 87	SDL_AudioCVT* self
 88	CODE:
 89		if( items > 1 )
 90		{
 91			self->dst_format = SvIV( ST(1) );
 92		}
 93		RETVAL = self->dst_format;
 94	OUTPUT:
 95		RETVAL
 96
 97
 98double
 99audiocvt_rate_incr(self, ...)
100	SDL_AudioCVT* self
101	CODE:
102		if( items > 1 )
103		{
104			self->rate_incr = SvIV( ST(1) );
105		}
106		RETVAL = self->rate_incr;
107	OUTPUT:
108		RETVAL
109
110int
111audiocvt_len(self, ...)
112	SDL_AudioCVT* self
113	CODE:
114		if( items > 1 )
115		{
116			self->len = SvIV( ST(1) );
117		}
118		RETVAL = self->len;
119	OUTPUT:
120		RETVAL
121
122int
123audiocvt_len_cvt(self, ...)
124	SDL_AudioCVT* self
125	CODE:
126		if( items > 1 )
127		{
128			self->len_cvt = SvIV( ST(1) );
129		}
130		RETVAL = self->len_cvt;
131	OUTPUT:
132		RETVAL
133
134int
135audiocvt_len_mult(self, ...)
136	SDL_AudioCVT* self
137	CODE:
138		if( items > 1 )
139		{
140			self->len_mult = SvIV( ST(1) );
141		}
142		RETVAL = self->len_mult;
143	OUTPUT:
144		RETVAL
145
146int
147audiocvt_len_ratio(self, ...)
148	SDL_AudioCVT* self
149	CODE:
150		if( items > 1 )
151		{
152			self->len_ratio = SvIV( ST(1) );
153		}
154		RETVAL = self->len_ratio;
155	OUTPUT:
156		RETVAL
157
158void
159audiocvt_DESTROY(self)
160	SDL_AudioCVT* self
161	CODE:
162		safefree(self);