Browse files

Implement load_wav, free_wav, with failing tests though...

  • Loading branch information...
1 parent 5b92c8d commit 481610374dcbb08b9c3b3b8a47237f552f3dcad0 @acme acme committed Nov 16, 2009
Showing with 38 additions and 25 deletions.
  1. +27 −0 src/Core/Audio.xs
  2. +0 −25 src/SDL.xs
  3. +11 −0 t/core_audio.t
View
27 src/Core/Audio.xs
@@ -42,6 +42,33 @@ audio_unlock_audio ()
CODE:
SDL_UnlockAudio();
+AV *
+audio_load_wav ( filename, spec )
+ char *filename
+ SDL_AudioSpec *spec
+ CODE:
+ SDL_AudioSpec *temp;
+ Uint8 *buf;
+ Uint32 len;
+
+ RETVAL = newAV();
+ temp = SDL_LoadWAV(filename,spec,&buf,&len);
+ if ( ! temp ) goto error;
+ av_push(RETVAL,newSViv(PTR2IV(temp)));
+ av_push(RETVAL,newSViv(PTR2IV(buf)));
+ av_push(RETVAL,newSViv(len));
+error:
+ OUTPUT:
+ Perl_warn("Error in SDL_LoadWAV");
+ RETVAL
+
+void
+audio_free_wav ( audio_buf )
+ Uint8 *audio_buf
+ CODE:
+ SDL_FreeWAV(audio_buf);
+
+
void
audio_close_audio ()
CODE:
View
25 src/SDL.xs
@@ -747,31 +747,6 @@ ConvertAudioData ( cvt, data, len )
OUTPUT:
RETVAL
-void
-FreeWAV ( buf )
- Uint8 *buf
- CODE:
- SDL_FreeWAV(buf);
-
-AV *
-LoadWAV ( filename, spec )
- char *filename
- SDL_AudioSpec *spec
- CODE:
- SDL_AudioSpec *temp;
- Uint8 *buf;
- Uint32 len;
-
- RETVAL = newAV();
- temp = SDL_LoadWAV(filename,spec,&buf,&len);
- if ( ! temp ) goto error;
- av_push(RETVAL,newSViv(PTR2IV(temp)));
- av_push(RETVAL,newSViv(PTR2IV(buf)));
- av_push(RETVAL,newSViv(len));
-error:
- OUTPUT:
- RETVAL
-
=cut
#ifdef HAVE_SDL_MIXER
View
11 t/core_audio.t
@@ -51,6 +51,17 @@ SDL::Audio::close_audio();
is( SDL::Audio::get_audio_status, SDL_AUDIO_STOPPED,
'[get_audio_status stopped]' );
+{
+ local $TODO = 1;
+
+ # I'm not sure why this does give us the correct params
+ my ( $wav_spec, $audio_buf, $audio_len )
+ = @{ SDL::Audio::load_wav( 'test/sample.wav', $obtained ) };
+ isa_ok( $wav_spec, 'SDL::AudioSpec' );
+ isa_ok( $audio_len, 3 );
+ SDL::Audio::free_wav($audio_buf);
+};
+
my @left = qw/
load_wav
free_wav

0 comments on commit 4816103

Please sign in to comment.