7 croak "Could not initialize SDL: ", SDL::GetError()
8 if ( 0 > SDL::Init(SDL_INIT_AUDIO));
10 $ARGV[0] ||= 'data/sample.wav';
12 croak "usage: $0 [wavefile]\n"
13 if ( in $ARGV[0], qw/ -h --help -? /);
15 my ($wav_spec,$wav_buffer,$wav_len,$wav_pos) = (0,0,0,0);
22 $wav_ptr = $wav_buffer + $wav_pos;
23 $wav_remainder = $wav_len - $wav_pos;
25 while ( $wav_remainder <= $len ) {
26 SDL::MixAudio($data,$wav_ptr,$wav_remainder,SDL_MIX_MAXVOLUME);
27 $data += $wav_remainder;
28 $len -= $wav_remainder;
29 $wav_ptr = $wav_buffer;
30 $wav_remainder = $wav_len;
33 SDL::MixAudio($data,$wav_ptr,$len,SDL_MIX_MAXVOLUME);
46 $spec = SDL::NewAudioSpec(44100,AUDIO_S16,2,4096);
48 $wave = SDL::LoadWAV($ARGV[0],$spec);
50 ($wav_spec,$wav_buffer,$wav_len) = @$wave;
52 croak "Could not load wav file $ARGV[0], ", SDL::GetError(), "\n" unless ( $wav_len );
54 croak "Could not open audio ", SDL::GetError()
55 if (0 > SDL::OpenAudio($wav_spec,$fillerup));
59 print "Using audio driver: ", SDL::AudioDriverName(), "\n";
61 while (! $done && ( SDL::GetAudioStatus() == SDL_AUDIO_PLAYING)) {