From: Leon Brocard Date: Fri, 6 Nov 2009 14:21:57 +0000 (+0000) Subject: Rename, move MixChunk and MixMusic to the right place X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f745fcad311577f2dee0967874ae0f4b865a713;p=sdlgit%2FSDL_perl.git Rename, move MixChunk and MixMusic to the right place --- diff --git a/.gitignore b/.gitignore index 72a84f6..2562487 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ blib lib/SDL/Config.pm lib/SDL/*.c lib/SDL/*.xs +lib/SDL/Mixer/*.c +lib/SDL/Mixer/*.xs SDL_perl.c SDL_perl.xs stage diff --git a/Build.PL b/Build.PL index 0fc45b1..41a47a6 100644 --- a/Build.PL +++ b/Build.PL @@ -177,15 +177,15 @@ my %subsystems = }, MixChunk => { file => { - from => 'src/Core/objects/MixChunk.xs', - to => 'lib/SDL/MixChunk.xs', + from => 'src/Mixer/objects/MixChunk.xs', + to => 'lib/SDL/Mixer/MixChunk.xs', }, libraries => [qw( SDL SDL_mixer )], }, MixMusic => { file => { - from => 'src/Core/objects/MixMusic.xs', - to => 'lib/SDL/MixMusic.xs', + from => 'src/Mixer/objects/MixMusic.xs', + to => 'lib/SDL/Mixer/MixMusic.xs', }, libraries => [qw( SDL SDL_mixer )], }, diff --git a/lib/SDL/MixChunk.pm b/lib/SDL/Mixer/MixChunk.pm similarity index 62% rename from lib/SDL/MixChunk.pm rename to lib/SDL/Mixer/MixChunk.pm index 4ae4370..a857a9d 100644 --- a/lib/SDL/MixChunk.pm +++ b/lib/SDL/Mixer/MixChunk.pm @@ -1,9 +1,9 @@ -package SDL::MixChunk; +package SDL::Mixer::MixChunk; use strict; use warnings; require Exporter; require DynaLoader; our @ISA = qw(Exporter DynaLoader); -bootstrap SDL::MixChunk; +bootstrap SDL::Mixer::MixChunk; 1; diff --git a/lib/SDL/MixMusic.pm b/lib/SDL/Mixer/MixMusic.pm similarity index 62% rename from lib/SDL/MixMusic.pm rename to lib/SDL/Mixer/MixMusic.pm index 1db704d..99731e2 100644 --- a/lib/SDL/MixMusic.pm +++ b/lib/SDL/Mixer/MixMusic.pm @@ -1,9 +1,9 @@ -package SDL::MixMusic; +package SDL::Mixer::MixMusic; use strict; use warnings; require Exporter; require DynaLoader; our @ISA = qw(Exporter DynaLoader); -bootstrap SDL::MixMusic; +bootstrap SDL::Mixer::MixMusic; 1; diff --git a/src/Core/objects/MixChunk.xs b/src/Mixer/objects/MixChunk.xs similarity index 89% rename from src/Core/objects/MixChunk.xs rename to src/Mixer/objects/MixChunk.xs index 71c5652..24c0464 100644 --- a/src/Core/objects/MixChunk.xs +++ b/src/Mixer/objects/MixChunk.xs @@ -9,7 +9,7 @@ #include #include -MODULE = SDL::MixChunk PACKAGE = SDL::MixChunk PREFIX = mixchunk_ +MODULE = SDL::Mixer::MixChunk PACKAGE = SDL::Mixer::MixChunk PREFIX = mixchunk_ =for documentation diff --git a/src/Core/objects/MixMusic.xs b/src/Mixer/objects/MixMusic.xs similarity index 80% rename from src/Core/objects/MixMusic.xs rename to src/Mixer/objects/MixMusic.xs index 12a333c..60989e8 100644 --- a/src/Core/objects/MixMusic.xs +++ b/src/Mixer/objects/MixMusic.xs @@ -9,7 +9,7 @@ #include #include -MODULE = SDL::MixMusic PACKAGE = SDL::MixMusic PREFIX = mixmusic_ +MODULE = SDL::Mixer::MixMusic PACKAGE = SDL::Mixer::MixMusic PREFIX = mixmusic_ =for documentation diff --git a/src/SDL.xs b/src/SDL.xs index 9b91a17..5e2a2e3 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -1190,7 +1190,7 @@ Mix_Chunk * MixLoadWAV ( filename ) char *filename PREINIT: - char * CLASS = "SDL::MixChunk"; + char * CLASS = "SDL::Mixer::MixChunk"; CODE: Mix_Chunk * mixchunk; mixchunk = Mix_LoadWAV(filename); @@ -1205,7 +1205,7 @@ Mix_Music * MixLoadMUS ( filename ) char *filename PREINIT: - char * CLASS = "SDL::MixMusic"; + char * CLASS = "SDL::Mixer::MixMusic"; CODE: Mix_Music * mixmusic; mixmusic = Mix_LoadMUS(filename); @@ -1220,7 +1220,7 @@ Mix_Chunk * MixQuickLoadWAV ( buf ) Uint8 *buf PREINIT: - char * CLASS = "SDL::MixChunk"; + char * CLASS = "SDL::Mixer::MixChunk"; CODE: RETVAL = Mix_QuickLoad_WAV(buf); OUTPUT: diff --git a/t/core_mixchunk.t b/t/core_mixchunk.t index 773d7c4..9d36725 100644 --- a/t/core_mixchunk.t +++ b/t/core_mixchunk.t @@ -2,16 +2,21 @@ use strict; use warnings; use SDL; -use SDL::MixChunk; -use Test::More tests => 7; +use SDL::Mixer::MixChunk; +use Test::More; -is( SDL::init(SDL_INIT_AUDIO), 0, '[init] returns 0 on success' ); +if ( SDL::init(SDL_INIT_AUDIO) < 0 ) { + plan( skip_all => 'No sound card?' ); + +} else { + plan( tests => 6 ); +} is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), 0, 'MixOpenAudio passed' ); my $mix_chunk = SDL::MixLoadWAV('test/data/sample.wav'); -isa_ok( $mix_chunk, 'SDL::MixChunk' ); +isa_ok( $mix_chunk, 'SDL::Mixer::MixChunk' ); is( $mix_chunk->volume, 128, 'Default volume is 128' ); $mix_chunk->volume(100); diff --git a/t/core_mixmusic.t b/t/core_mixmusic.t index 795b6a5..0583bc4 100644 --- a/t/core_mixmusic.t +++ b/t/core_mixmusic.t @@ -2,10 +2,15 @@ use strict; use warnings; use SDL; -use SDL::MixMusic; -use Test::More tests => 4; +use SDL::Mixer::MixMusic; +use Test::More; -is( SDL::init(SDL_INIT_AUDIO), 0, '[init] returns 0 on success' ); +if ( SDL::init(SDL_INIT_AUDIO) < 0 ) { + plan( skip_all => 'No sound card?' ); + +} else { + plan( tests => 3 ); +} is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), 0, 'MixOpenAudio passed' ); @@ -16,7 +21,7 @@ my $mix_music = SDL::MixLoadMUS('test/data/sample.wav'); local $TODO = 1; # I'm not sure why this fails - isa_ok( $mix_music, 'SDL::MixMusic' ); + isa_ok( $mix_music, 'SDL::Mixer::MixMusic' ); }; SDL::MixPlayMusic( $mix_music, 0 ); diff --git a/t/mixer_mixchunk.t b/t/mixer_mixchunk.t new file mode 100644 index 0000000..1f32c70 --- /dev/null +++ b/t/mixer_mixchunk.t @@ -0,0 +1,28 @@ +#!perl +use strict; +use warnings; +use SDL; +use SDL::Mixer::MixChunk; +use Test::More tests => 7; + +is( SDL::init(SDL_INIT_AUDIO), 0, '[init] returns 0 on success' ); + +is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), + 0, 'MixOpenAudio passed' ); + +my $mix_chunk = SDL::MixLoadWAV('test/data/sample.wav'); +isa_ok( $mix_chunk, 'SDL::Mixer::MixChunk' ); + +is( $mix_chunk->volume, 128, 'Default volume is 128' ); +$mix_chunk->volume(100); +is( $mix_chunk->volume, 100, 'Can change volume to 100' ); + +is( $mix_chunk->alen, 1926848, 'Alen is 1926848' ); + +SDL::MixPlayChannel( -1, $mix_chunk, 0 ); + +# we close straight away so no audio is actually played + +SDL::MixCloseAudio; + +ok( 1, 'Got to the end' ); diff --git a/t/mixer_mixmusic.t b/t/mixer_mixmusic.t new file mode 100644 index 0000000..c741a61 --- /dev/null +++ b/t/mixer_mixmusic.t @@ -0,0 +1,28 @@ +#!perl +use strict; +use warnings; +use SDL; +use SDL::Mixer::MixMusic; +use Test::More tests => 4; + +is( SDL::init(SDL_INIT_AUDIO), 0, '[init] returns 0 on success' ); + +is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), + 0, 'MixOpenAudio passed' ); + +my $mix_music = SDL::MixLoadMUS('test/data/sample.wav'); + +{ + local $TODO = 1; + + # I'm not sure why this fails + isa_ok( $mix_music, 'SDL::Mixer::MixMusic' ); +}; + +SDL::MixPlayMusic( $mix_music, 0 ); + +# we close straight away so no audio is actually played + +SDL::MixCloseAudio; + +ok( 1, 'Got to the end' );