Skip to content

Commit

Permalink
Fixed docs for convert in SDL::Audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Thakore committed Nov 26, 2009
1 parent d56b2d8 commit 175d147
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
31 changes: 20 additions & 11 deletions lib/pods/SDL/Audio.pod
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ Loads a WAVE file

Frees previously opened WAV data

=head2 convert_audio
=head2 convert

SDL::Audio->convert_audio( cvt, data, len )
SDL::Audio->convert( cvt, data, len )

Converts audio data to a desired audio format.

Expand All @@ -125,6 +125,9 @@ Example:
use SDL::Audio;
use SDL::AudioSpec;
use SDL::AudioCVT;
use Devel::Peek;

SDL::init(SDL_INIT_AUDIO);

# Converting some WAV data to hardware format

Expand All @@ -138,19 +141,20 @@ Example:
$desired->samples(8192);

# Open the audio device
if( SDL::Audio::open_audio($desired, $obtained) < 0 )
if( SDL::Audio::open($desired, $obtained) < 0 )
{
printf( STDERR "Couldn't open audio: %s\n", SDL::get_error() );
exit(-1);
}

# Load the test.wav
my $wav_ref = SDL::Audio::load_wav('C:/SDL_perl/test/data/sample.wav', $obtained);
my $wav_ref = SDL::Audio::load_wav('../../test/data/sample.wav', $obtained);

unless( $wav_ref )
{
printf( STDERR "Could not open sample.wav: %s\n", SDL::get_error() );
warn("Could not open sample.wav: %s\n", SDL::get_error() );
SDL::Audio::close_audio();
SDL::quit;
exit(-1);
}

Expand All @@ -161,19 +165,24 @@ Example:
$obtained->format, $obtained->channels, $obtained->freq);

# Check that the convert was built
unless( $wav_cvt )
if( $wav_cvt == -1 )
{
printf( STDERR "Couldn't build converter!\n" );
SDL::Audio::close_audio();
warn("Couldn't build converter!\n" );
SDL::Audio::close();
SDL::Audio::free_wav($wav_buf);
SDL::quit();
exit(-1);
}

# And now we're ready to convert
SDL::Audio::convert_audio($wav_cvt, $wav_buf, $wav_len);
SDL::Audio::convert($wav_cvt, $wav_buf, $wav_len);


# We can delete to original WAV data now
# We can freeto original WAV data now
SDL::Audio::free_wav($wav_buf);



B<TODO>: What to do with it? How to use callback? See http://www.libsdl.org/cgi/docwiki.cgi/SDL_ConvertAudio

=head2 MixAudio
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Audio.xs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ audio_load_wav ( filename, spec )
else
{
RETVAL = newAV();
RETVAL = sv_2mortal( (SV*)RETVAL );
RETVAL = sv_2mortal( (SV *)RETVAL );
av_push(RETVAL, sv_setref_pv( asref, "SDL::AudioSpec", (void *)temp));
av_push(RETVAL,newSViv(PTR2IV(buf)));
av_push(RETVAL,newSViv(len));
Expand All @@ -76,7 +76,7 @@ audio_free_wav ( audio_buf )
SDL_FreeWAV(audio_buf);

int
audio_convert_audio( cvt, data, len )
audio_convert( cvt, data, len )
SDL_AudioCVT *cvt
Uint8 *data
int len
Expand All @@ -85,6 +85,8 @@ audio_convert_audio( cvt, data, len )
cvt->len = len;
memcpy(cvt->buf, data, cvt->len);
RETVAL = SDL_ConvertAudio(cvt);


OUTPUT:
RETVAL

Expand Down

0 comments on commit 175d147

Please sign in to comment.