Skip to content

Commit

Permalink
Mixer fix up to check Config before testign or compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Thakore committed Dec 1, 2009
1 parent c1bddb5 commit 8a89f42
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/Mixer/objects/MixChunk.xs
Expand Up @@ -7,7 +7,10 @@
#endif

#include <SDL.h>

#ifdef HAVE_SDL_MIXER
#include <SDL_mixer.h>
#endif

MODULE = SDL::Mixer::MixChunk PACKAGE = SDL::Mixer::MixChunk PREFIX = mixchunk_

Expand All @@ -24,6 +27,8 @@ SDL_MixChunk - Stores audio data in memory

=cut

#ifdef HAVE_SDL_MIXER

Uint32
mixchunk_alen ( mixchunk )
Mix_Chunk *mixchunk
Expand All @@ -46,3 +51,5 @@ mixchunk_DESTROY(mixchunk)
Mix_Chunk *mixchunk
CODE:
Mix_FreeChunk(mixchunk);

#endif
7 changes: 7 additions & 0 deletions src/Mixer/objects/MixMusic.xs
Expand Up @@ -7,7 +7,10 @@
#endif

#include <SDL.h>

#ifdef HAVE_SDL_MIXER
#include <SDL_mixer.h>
#endif

MODULE = SDL::Mixer::MixMusic PACKAGE = SDL::Mixer::MixMusic PREFIX = mixmusic_

Expand All @@ -19,8 +22,12 @@ SDL_mixmusic - This is an opaque data type used for Music data

=cut

#ifdef HAVE_SDL_MIXER

void
mixmusic_DESTROY(mixmusic)
Mix_Music *mixmusic
CODE:
Mix_FreeMusic(mixmusic);

#endif
11 changes: 11 additions & 0 deletions t/mixer.t
@@ -1,8 +1,19 @@
#!/usr/bin/perl -w
use strict;
use SDL;
use SDL::Config;
use Test::More;

use lib 't/lib';
use SDL::TestTool;

if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
plan( skip_all => 'Failed to init sound' );
}
elsif( !SDL::Config->has('SDL_mixer') )
{
plan( skip_all => 'SDL_mixer support not compiled' );
}
my @done = qw//;

my @left = qw/
Expand Down
17 changes: 13 additions & 4 deletions t/mixer_mixchunk.t
@@ -1,19 +1,28 @@
#!perl
use strict;
use warnings;
use lib 't/lib';
use SDL;
use SDL::Config;
use SDL::Mixer::MixChunk;
use SDL::TestTool;
use Test::More;
use IO::CaptureOutput qw(capture);

use lib 't/lib';

use SDL::TestTool;

if (! SDL::TestTool->init(SDL_INIT_AUDIO) ) {
plan( skip_all => 'Failed to init sound' );
} else {
}
elsif( !SDL::Config->has('SDL_mixer') )
{
plan( skip_all => 'SDL_mixer support not compiled' );
}
else
{
plan( tests => 6 );
}


is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ),
0, 'MixOpenAudio passed' );

Expand Down
16 changes: 12 additions & 4 deletions t/mixer_mixmusic.t
@@ -1,16 +1,24 @@
#!perl
use strict;
use warnings;
use lib 't/lib';
use SDL;
use SDL::Config;
use SDL::Mixer::MixMusic;
use SDL::TestTool;
use Test::More;
use IO::CaptureOutput qw(capture);

use lib 't/lib';

use SDL::TestTool;

if (! SDL::TestTool->init(SDL_INIT_AUDIO) ) {
plan( skip_all => 'Failed to init sound' );
} else {
}
elsif( !SDL::Config->has('SDL_mixer') )
{
plan( skip_all => 'SDL_mixer support not compiled' );
}
else
{
plan( tests => 3 );
}

Expand Down
9 changes: 8 additions & 1 deletion t/mixerpm.t
Expand Up @@ -8,13 +8,20 @@ use SDL::TestTool;

if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
plan( skip_all => 'Failed to init sound' );
} else {
}
elsif( !SDL::Config->has('SDL_mixer') )
{
plan( skip_all => 'SDL_mixer support not compiled' );
}
else
{
plan( tests => 3 );
}





use_ok( 'SDL::Mixer' );

can_ok ('SDL::Mixer', qw/
Expand Down

0 comments on commit 8a89f42

Please sign in to comment.