Rename, move MixChunk and MixMusic to the right place
Leon Brocard [Fri, 6 Nov 2009 14:21:57 +0000 (14:21 +0000)]
.gitignore
Build.PL
lib/SDL/Mixer/MixChunk.pm [moved from lib/SDL/MixChunk.pm with 62% similarity]
lib/SDL/Mixer/MixMusic.pm [moved from lib/SDL/MixMusic.pm with 62% similarity]
src/Mixer/objects/MixChunk.xs [moved from src/Core/objects/MixChunk.xs with 89% similarity]
src/Mixer/objects/MixMusic.xs [moved from src/Core/objects/MixMusic.xs with 80% similarity]
src/SDL.xs
t/core_mixchunk.t
t/core_mixmusic.t
t/mixer_mixchunk.t [new file with mode: 0644]
t/mixer_mixmusic.t [new file with mode: 0644]

index 72a84f6..2562487 100644 (file)
@@ -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
index 0fc45b1..41a47a6 100644 (file)
--- 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 )],
        },
similarity index 62%
rename from lib/SDL/MixChunk.pm
rename to lib/SDL/Mixer/MixChunk.pm
index 4ae4370..a857a9d 100644 (file)
@@ -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;
similarity index 62%
rename from lib/SDL/MixMusic.pm
rename to lib/SDL/Mixer/MixMusic.pm
index 1db704d..99731e2 100644 (file)
@@ -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;
similarity index 89%
rename from src/Core/objects/MixChunk.xs
rename to src/Mixer/objects/MixChunk.xs
index 71c5652..24c0464 100644 (file)
@@ -9,7 +9,7 @@
 #include <SDL.h>
 #include <SDL_mixer.h>
 
-MODULE = SDL::MixChunk         PACKAGE = SDL::MixChunk    PREFIX = mixchunk_
+MODULE = SDL::Mixer::MixChunk  PACKAGE = SDL::Mixer::MixChunk    PREFIX = mixchunk_
 
 =for documentation
 
similarity index 80%
rename from src/Core/objects/MixMusic.xs
rename to src/Mixer/objects/MixMusic.xs
index 12a333c..60989e8 100644 (file)
@@ -9,7 +9,7 @@
 #include <SDL.h>
 #include <SDL_mixer.h>
 
-MODULE = SDL::MixMusic         PACKAGE = SDL::MixMusic    PREFIX = mixmusic_
+MODULE = SDL::Mixer::MixMusic  PACKAGE = SDL::Mixer::MixMusic    PREFIX = mixmusic_
 
 =for documentation
 
index 9b91a17..5e2a2e3 100644 (file)
@@ -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:
index 773d7c4..9d36725 100644 (file)
@@ -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);
index 795b6a5..0583bc4 100644 (file)
@@ -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 (file)
index 0000000..1f32c70
--- /dev/null
@@ -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 (file)
index 0000000..c741a61
--- /dev/null
@@ -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' );