/t/mixer_mixmusic.t

http://github.com/PerlGameDev/SDL · Raku · 64 lines · 44 code · 17 blank · 3 comment · 7 complexity · 225094dc0fb6d8c9b2869e69cbbabff7 MD5 · raw file

  1. use strict;
  2. use warnings;
  3. use SDL;
  4. use SDL::Config;
  5. my $audiodriver;
  6. BEGIN {
  7. use Config;
  8. if ( !$Config{'useithreads'} ) {
  9. print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
  10. exit(0);
  11. }
  12. use Test::More;
  13. use lib 't/lib';
  14. use SDL::TestTool;
  15. $audiodriver = $ENV{SDL_AUDIODRIVER};
  16. $ENV{SDL_AUDIODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
  17. if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
  18. plan( skip_all => 'Failed to init sound' );
  19. } elsif ( !SDL::Config->has('SDL_mixer') ) {
  20. plan( skip_all => 'SDL_mixer support not compiled' );
  21. } else {
  22. plan( tests => 6 );
  23. }
  24. }
  25. use_ok('SDL::Mixer');
  26. use_ok('SDL::Mixer::Music');
  27. use_ok('SDL::Mixer::MixMusic');
  28. is( SDL::Mixer::open_audio( 44100, SDL::Audio::AUDIO_S16SYS, 2, 4096 ),
  29. 0, 'open_audio passed'
  30. );
  31. my $mix_music = SDL::Mixer::Music::load_MUS('test/data/tribe_i.wav')
  32. ; # from Matthew Newman, http://opengameart.org/content/vocal-grunts-tribeiwav
  33. #warn 'Error:'. SDL::get_error() if (!$mix_music);
  34. {
  35. # I'm not sure why this fails
  36. isa_ok( $mix_music, 'SDL::Mixer::MixMusic' );
  37. };
  38. SDL::Mixer::Music::play_music( $mix_music, 0 );
  39. # we close straight away so no audio is actually played
  40. SDL::Mixer::close_audio();
  41. ok( 1, 'Got to the end' );
  42. if ($audiodriver) {
  43. $ENV{SDL_AUDIODRIVER} = $audiodriver;
  44. } else {
  45. delete $ENV{SDL_AUDIODRIVER};
  46. }
  47. sleep(2);