Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved mixer from SDL to SDL::Mixer

  • Loading branch information...
commit 1ffe45eeda54d32dd8aad7f5295d00b1d1475cf7 1 parent 51371fd
Tobias Leich authored
View
242 lib/SDL/Mixer.pm
@@ -1,243 +1,9 @@
-#!/usr/bin/env perl
-#
-# Mixer.pm
-#
-# Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
-#
-# ------------------------------------------------------------------------------
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# ------------------------------------------------------------------------------
-#
-# Please feel free to send questions, suggestions or improvements to:
-#
-# David J. Goehrig
-# dgoehrig@cpan.org
-#
-
package SDL::Mixer;
-
use strict;
use warnings;
-use Carp;
-
-use SDL;
-use SDL::Sound;
-use SDL::Music;
-#bootstrap SDL::Mixer;
-
-BEGIN {
-}
-
-$SDL::Mixer::initialized = 0;
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- my %options = @_;
- my $frequency = $options{-frequency} || $options{-rate} || SDL::MIX_DEFAULT_FREQUENCY();
- my $format = $options{-format} || SDL::MIX_DEFAULT_FORMAT();
- my $channels = $options{-channels} || SDL::MIX_DEFAULT_CHANNELS();
- my $size = $options{-size} || 4096;
- unless ( $SDL::Mixer::initialized ) {
- SDL::MixOpenAudio($frequency,$format,$channels,$size ) &&
- croak SDL::get_error();
- $SDL::Mixer::initialized = 1;
- } else {
- ++$SDL::Mixer::initialized;
- }
- bless $self,$class;
- return $self;
-}
-
-sub DESTROY {
- my $self = shift;
- --$SDL::Mixer::initialized;
- unless ($SDL::Mixer::initialized) {
- SDL::MixCloseAudio();
- }
-}
-
-
-sub query_spec () {
- my ($status,$freq,$format,$channels) = SDL::MixQuerySpec();
- my %hash = ( -status => $status, -frequency => $freq,
- -format => $format, -channels => $channels );
- return \%hash;
-}
-
-sub reserve_channels ($$) {
- my ($self,$channels) = @_;
- return SDL::MixReserveChannels($channels);
-}
-
-sub allocate_channels ($$) {
- my ($self,$channels) = @_;
- return SDL::MixAllocateChannels($channels);
-}
-
-sub group_channel ($$$) {
- my ($self,$channel,$group) = @_;
- return SDL::MixGroupChannel($channel, $group);
-}
-
-sub group_channels ($$$$) {
- my ($self,$from,$to,$group) = @_;
- return SDL::MixGroupChannels($from,$to,$group);
-}
-
-sub group_available ($$) {
- my ($self,$group) = @_;
- return SDL::MixGroupAvailable($group);
-}
-
-sub group_count ($$) {
- my ($self,$group) = @_;
- return SDL::MixGroupCount($group);
-}
-
-sub group_oldest ($$) {
- my ($self,$group) = @_;
- return SDL::MixGroupOldest($group);
-}
-
-sub group_newer ($$) {
- my ($self,$group) = @_;
- return SDL::MixGroupNewer($group);
-}
-
-sub play_channel ($$$$;$) {
- my ($self,$channel,$chunk,$loops,$ticks) = @_;
- $ticks ||= -1;
- return SDL::MixPlayChannelTimed($channel,$$chunk,$loops,$ticks);
-}
-
-sub play_music ($$$) {
- my ($self,$music,$loops) = @_;
- return SDL::MixPlayMusic($$music,$loops);
-}
-
-sub fade_in_channel ($$$$$;$) {
- my ($self,$channel,$chunk,$loops,$ms,$ticks) = @_;
- $ticks ||= -1;
- return SDL::MixFadeInChannelTimed($channel,$$chunk,$loops,$ms,$ticks);
-}
-
-sub fade_in_music ($$$$) {
- my ($self,$music,$loops,$ms) = @_;
- return SDL::MixFadeInMusic($$music,$loops,$ms);
-}
-
-sub channel_volume ($$$) {
- my ($self,$channel,$volume) = @_;
- return SDL::MixVolume($channel,$volume);
-}
-
-sub music_volume ($$) {
- my ($self,$volume) = @_;
- return SDL::MixVolumeMusic($volume);
-}
-
-sub halt_channel ($$) {
- my ($self,$channel) = @_;
- return SDL::MixHaltChannel($channel);
-}
-
-sub halt_group ($$) {
- my ($self,$group) = @_;
- return SDL::MixHaltGroup($group);
-}
-
-sub halt_music (){
- return SDL::MixHaltMusic();
-}
-
-sub channel_expire ($$$) {
- my ($self,$channel,$ticks) = @_;
- return SDL::MixExpireChannel($channel,$ticks);
-}
-
-sub fade_out_channel ($$$) {
- my ($self,$channel,$ms) = @_;
- return SDL::MixFadeOutChannel($channel,$ms);
-}
-
-sub fade_out_group ($$$) {
- my ($self,$group,$ms) = @_;
- return SDL::MixFadeOutGroup($group,$ms);
-}
-
-sub fade_out_music ($$) {
- my ($self,$ms) = @_;
- return SDL::MixFadeOutMusic($ms);
-}
-
-sub fading_music () {
- return SDL::MixFadingMusic();
-}
-
-sub fading_channel ($$) {
- my ($self,$channel) = @_;
- return SDL::MixFadingChannel($channel);
-}
-
-sub pause ($$) {
- my ($self,$channel) = @_;
- SDL::MixPause($channel);
-}
-
-sub resume ($$) {
- my ($self,$channel) = @_;
- SDL::MixResume($channel);
-}
-
-sub paused ($$) {
- my ($self,$channel) = @_;
- return SDL::MixPaused($channel);
-}
-
-sub pause_music () {
- SDL::MixPauseMusic();
-}
-
-sub resume_music () {
- SDL::MixResumeMusic();
-}
-
-sub rewind_music (){
- SDL::MixRewindMusic();
-}
-
-sub music_paused (){
- return SDL::MixPausedMusic();
-}
-
-sub playing ($$) {
- my ($self,$channel) = @_;
- return SDL::MixPlaying($channel);
-}
-
-sub playing_music () {
- return SDL::MixPlayingMusic();
-}
-
-sub set_panning {
- my($self, $channel, $left, $right) = @_;
- return SDL::MixSetPanning($channel, $left, $right);
-}
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Mixer;
1;
View
415 src/Mixer/Mixer.xs
@@ -36,4 +36,419 @@ mixer_init(flags)
#endif
+void
+mixer_mix_audio ( dst, src, len, volume )
+ Uint8 *dst
+ Uint8 *src
+ Uint32 len
+ int volume
+ CODE:
+ SDL_MixAudio(dst,src,len,volume);
+
+int
+mixer_open_audio ( frequency, format, channels, chunksize )
+ int frequency
+ Uint16 format
+ int channels
+ int chunksize
+ CODE:
+ RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_allocate_channels ( number )
+ int number
+ CODE:
+ RETVAL = Mix_AllocateChannels(number);
+ OUTPUT:
+ RETVAL
+
+AV *
+mixer_query_spec ()
+ CODE:
+ int freq, channels, status;
+ Uint16 format;
+ status = Mix_QuerySpec(&freq,&format,&channels);
+ RETVAL = newAV();
+ av_push(RETVAL,newSViv(status));
+ av_push(RETVAL,newSViv(freq));
+ av_push(RETVAL,newSViv(format));
+ av_push(RETVAL,newSViv(channels));
+ OUTPUT:
+ RETVAL
+
+Mix_Chunk *
+mixer_load_WAV ( filename )
+ char *filename
+ PREINIT:
+ char * CLASS = "SDL::Mixer::MixChunk";
+ CODE:
+ Mix_Chunk * mixchunk;
+ mixchunk = Mix_LoadWAV(filename);
+ if (mixchunk == NULL) {
+ fprintf(stderr, "Could not load %s\n", filename);
+ }
+ RETVAL = mixchunk;
+ OUTPUT:
+ RETVAL
+
+Mix_Music *
+mixer_load_MUS ( filename )
+ char *filename
+ PREINIT:
+ char * CLASS = "SDL::Mixer::MixMusic";
+ CODE:
+ Mix_Music * mixmusic;
+ mixmusic = Mix_LoadMUS(filename);
+ if (mixmusic == NULL) {
+ fprintf(stderr, "Could not load %s\n", filename);
+ }
+ RETVAL = mixmusic;
+ OUTPUT:
+ RETVAL
+
+Mix_Chunk *
+mixer_quick_load_WAV ( buf )
+ Uint8 *buf
+ PREINIT:
+ char * CLASS = "SDL::Mixer::MixChunk";
+ CODE:
+ RETVAL = Mix_QuickLoad_WAV(buf);
+ OUTPUT:
+ RETVAL
+
+void
+mixer_free_chunk( chunk )
+ Mix_Chunk *chunk
+ CODE:
+ Mix_FreeChunk(chunk);
+
+void
+mixer_free_music ( music )
+ Mix_Music *music
+ CODE:
+ Mix_FreeMusic(music);
+
+void
+mixer_set_post_mix ( func, arg )
+ void *func
+ void *arg
+ CODE:
+ Mix_SetPostMix(func,arg);
+
+void
+mixer_hook_music ( func, arg )
+ void *func
+ void *arg
+ CODE:
+ Mix_HookMusic(func,arg);
+
+void
+mixer_hook_music_finished ( func )
+ void *func
+ CODE:
+ //mix_music_finished_cv = func;
+ //Mix_HookMusicFinished(sdl_perl_music_finished_callback);
+
+void *
+mixer_get_music_hook_data ()
+ CODE:
+ RETVAL = Mix_GetMusicHookData();
+ OUTPUT:
+ RETVAL
+
+int
+mixer_reverse_channels ( number )
+ int number
+ CODE:
+ RETVAL = Mix_ReserveChannels ( number );
+ OUTPUT:
+ RETVAL
+
+int
+mixer_group_channel ( which, tag )
+ int which
+ int tag
+ CODE:
+ RETVAL = Mix_GroupChannel(which,tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_group_channels ( from, to, tag )
+ int from
+ int to
+ int tag
+ CODE:
+ RETVAL = Mix_GroupChannels(from,to,tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_group_available ( tag )
+ int tag
+ CODE:
+ RETVAL = Mix_GroupAvailable(tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_group_count ( tag )
+ int tag
+ CODE:
+ RETVAL = Mix_GroupCount(tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_group_oldest ( tag )
+ int tag
+ CODE:
+ RETVAL = Mix_GroupOldest(tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_group_newer ( tag )
+ int tag
+ CODE:
+ RETVAL = Mix_GroupNewer(tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_play_channel ( channel, chunk, loops )
+ int channel
+ Mix_Chunk *chunk
+ int loops
+ CODE:
+ RETVAL = Mix_PlayChannel(channel,chunk,loops);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_play_channel_timed ( channel, chunk, loops, ticks )
+ int channel
+ Mix_Chunk *chunk
+ int loops
+ int ticks
+ CODE:
+ RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_play_music ( music, loops )
+ Mix_Music *music
+ int loops
+ CODE:
+ RETVAL = Mix_PlayMusic(music,loops);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_fade_in_channel ( channel, chunk, loops, ms )
+ int channel
+ Mix_Chunk *chunk
+ int loops
+ int ms
+ CODE:
+ RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_fade_in_channel_timed ( channel, chunk, loops, ms, ticks )
+ int channel
+ Mix_Chunk *chunk
+ int loops
+ int ticks
+ int ms
+ CODE:
+ RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_fade_in_music ( music, loops, ms )
+ Mix_Music *music
+ int loops
+ int ms
+ CODE:
+ RETVAL = Mix_FadeInMusic(music,loops,ms);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_volume ( channel, volume )
+ int channel
+ int volume
+ CODE:
+ RETVAL = Mix_Volume(channel,volume);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_volume_chunk ( chunk, volume )
+ Mix_Chunk *chunk
+ int volume
+ CODE:
+ RETVAL = Mix_VolumeChunk(chunk,volume);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_volume_music ( volume )
+ int volume
+ CODE:
+ RETVAL = Mix_VolumeMusic(volume);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_halt_channel ( channel )
+ int channel
+ CODE:
+ RETVAL = Mix_HaltChannel(channel);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_halt_group ( tag )
+ int tag
+ CODE:
+ RETVAL = Mix_HaltGroup(tag);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_halt_music ()
+ CODE:
+ RETVAL = Mix_HaltMusic();
+ OUTPUT:
+ RETVAL
+
+int
+mixer_expire_channel ( channel, ticks )
+ int channel
+ int ticks
+ CODE:
+ RETVAL = Mix_ExpireChannel ( channel,ticks);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_fade_out_channel ( which, ms )
+ int which
+ int ms
+ CODE:
+ RETVAL = Mix_FadeOutChannel(which,ms);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_fade_out_group ( which, ms )
+ int which
+ int ms
+ CODE:
+ RETVAL = Mix_FadeOutGroup(which,ms);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_fade_out_music ( ms )
+ int ms
+ CODE:
+ RETVAL = Mix_FadeOutMusic(ms);
+ OUTPUT:
+ RETVAL
+
+Mix_Fading
+mixer_fading_music()
+ CODE:
+ RETVAL = Mix_FadingMusic();
+ OUTPUT:
+ RETVAL
+
+Mix_Fading
+mixer_fading_channel( which )
+ int which
+ CODE:
+ RETVAL = Mix_FadingChannel(which);
+ OUTPUT:
+ RETVAL
+
+void
+mixer_pause ( channel )
+ int channel
+ CODE:
+ Mix_Pause(channel);
+
+void
+mixer_resume ( channel )
+ int channel
+ CODE:
+ Mix_Resume(channel);
+
+int
+mixer_paused ( channel )
+ int channel
+ CODE:
+ RETVAL = Mix_Paused(channel);
+ OUTPUT:
+ RETVAL
+
+void
+mixer_pause_music ()
+ CODE:
+ Mix_PauseMusic();
+
+void
+mixer_resume_music ()
+ CODE:
+ Mix_ResumeMusic();
+
+void
+mixer_rewind_music ()
+ CODE:
+ Mix_RewindMusic();
+
+int
+mixer_paused_music ()
+ CODE:
+ RETVAL = Mix_PausedMusic();
+ OUTPUT:
+ RETVAL
+
+int
+mixer_playing( channel )
+ int channel
+ CODE:
+ RETVAL = Mix_Playing(channel);
+ OUTPUT:
+ RETVAL
+
+int
+mixer_playing_music()
+ CODE:
+ RETVAL = Mix_PlayingMusic();
+ OUTPUT:
+ RETVAL
+
+int
+mixer_set_panning ( channel, left, right )
+ int channel
+ int left
+ int right
+ CODE:
+ RETVAL = Mix_SetPanning(channel, left, right);
+ OUTPUT:
+ RETVAL
+
+void
+mixer_close_audio ()
+ CODE:
+ Mix_CloseAudio();
+
#endif
View
601 src/SDL.xs
@@ -49,11 +49,6 @@
#include <SDL_image.h>
#endif
-#ifdef HAVE_SDL_MIXER
-#include <SDL_mixer.h>
-void (*mix_music_finished_cv)();
-#endif
-
#ifdef HAVE_SDL_SOUND
#include <SDL_sound.h>
#endif
@@ -62,11 +57,16 @@ void (*mix_music_finished_cv)();
#include <SDL_net.h>
#endif
+//#ifdef HAVE_SDL_MIXER
+//#include <SDL_mixer.h>
+//void (*mix_music_finished_cv)();
+//#endif
+
#ifdef HAVE_SMPEG
#include <smpeg/smpeg.h>
-#ifdef HAVE_SDL_MIXER
-static int sdl_perl_use_smpeg_audio = 0;
-#endif
+//#ifdef HAVE_SDL_MIXER
+//static int sdl_perl_use_smpeg_audio = 0;
+//#endif
#endif
#ifdef HAVE_SDL_GFX
@@ -110,129 +110,131 @@ extern PerlInterpreter *parent_perl;
#endif
-void
-windows_force_driver ()
-{
- const SDL_version *version = SDL_Linked_Version();
- if(version->patch == 14)
- {
- putenv("SDL_VIDEODRIVER=directx");
- }
- else
- {
- putenv("SDL_VIDEODRIVER=windib");
- }
-}
+/*
+#ifdef HAVE_SDL_MIXER
-Uint32
-sdl_perl_timer_callback ( Uint32 interval, void* param )
+void
+sdl_perl_music_callback ( void )
{
- Uint32 retval;
- int back;
- SV* cmd;
+ SV *cmd;
ENTER_TLS_CONTEXT
dSP;
- cmd = (SV*)param;
+ cmd = (SV*)Mix_GetMusicHookData();
ENTER;
SAVETMPS;
PUSHMARK(SP);
- XPUSHs(sv_2mortal(newSViv(interval)));
PUTBACK;
+
+ call_sv(cmd,G_VOID|G_DISCARD);
- if (0 != (back = call_sv(cmd,G_SCALAR))) {
- SPAGAIN;
- if (back != 1 ) Perl_croak (aTHX_ "Timer Callback failed!");
- retval = POPi;
- } else {
- Perl_croak(aTHX_ "Timer Callback failed!");
- }
-
+ PUTBACK;
FREETMPS;
LEAVE;
LEAVE_TLS_CONTEXT
-
- return retval;
}
void
-sdl_perl_audio_callback ( void* data, Uint8 *stream, int len )
+sdl_perl_music_finished_callback ( void )
{
SV *cmd;
ENTER_TLS_CONTEXT
dSP;
- cmd = (SV*)data;
+ cmd = (SV*)mix_music_finished_cv;
+ if ( cmd == NULL ) return;
ENTER;
SAVETMPS;
PUSHMARK(SP);
- XPUSHs(sv_2mortal(newSViv(PTR2IV(stream))));
- XPUSHs(sv_2mortal(newSViv(len)));
PUTBACK;
-
+
call_sv(cmd,G_VOID|G_DISCARD);
PUTBACK;
FREETMPS;
LEAVE;
- LEAVE_TLS_CONTEXT
+ LEAVE_TLS_CONTEXT
}
-#ifdef HAVE_SDL_MIXER
+#endif
+*/
void
-sdl_perl_music_callback ( void )
+windows_force_driver ()
{
- SV *cmd;
+ const SDL_version *version = SDL_Linked_Version();
+ if(version->patch == 14)
+ {
+ putenv("SDL_VIDEODRIVER=directx");
+ }
+ else
+ {
+ putenv("SDL_VIDEODRIVER=windib");
+ }
+}
+
+Uint32
+sdl_perl_timer_callback ( Uint32 interval, void* param )
+{
+ Uint32 retval;
+ int back;
+ SV* cmd;
ENTER_TLS_CONTEXT
dSP;
- cmd = (SV*)Mix_GetMusicHookData();
+ cmd = (SV*)param;
ENTER;
SAVETMPS;
PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSViv(interval)));
PUTBACK;
-
- call_sv(cmd,G_VOID|G_DISCARD);
- PUTBACK;
+ if (0 != (back = call_sv(cmd,G_SCALAR))) {
+ SPAGAIN;
+ if (back != 1 ) Perl_croak (aTHX_ "Timer Callback failed!");
+ retval = POPi;
+ } else {
+ Perl_croak(aTHX_ "Timer Callback failed!");
+ }
+
FREETMPS;
LEAVE;
LEAVE_TLS_CONTEXT
+
+ return retval;
}
void
-sdl_perl_music_finished_callback ( void )
+sdl_perl_audio_callback ( void* data, Uint8 *stream, int len )
{
SV *cmd;
ENTER_TLS_CONTEXT
dSP;
- cmd = (SV*)mix_music_finished_cv;
- if ( cmd == NULL ) return;
+ cmd = (SV*)data;
ENTER;
SAVETMPS;
PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSViv(PTR2IV(stream))));
+ XPUSHs(sv_2mortal(newSViv(len)));
PUTBACK;
-
+
call_sv(cmd,G_VOID|G_DISCARD);
PUTBACK;
FREETMPS;
LEAVE;
- LEAVE_TLS_CONTEXT
+ LEAVE_TLS_CONTEXT
}
-#endif
-
#define INIT_NS_APPLICATION
#define QUIT_NS_APPLICATION
@@ -415,433 +417,6 @@ RemoveTimer ( id )
OUTPUT:
RETVAL
-
-#ifdef HAVE_SDL_MIXER
-
-void
-MixAudio ( dst, src, len, volume )
- Uint8 *dst
- Uint8 *src
- Uint32 len
- int volume
- CODE:
- SDL_MixAudio(dst,src,len,volume);
-
-int
-MixOpenAudio ( frequency, format, channels, chunksize )
- int frequency
- Uint16 format
- int channels
- int chunksize
- CODE:
- RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
- OUTPUT:
- RETVAL
-
-int
-MixAllocateChannels ( number )
- int number
- CODE:
- RETVAL = Mix_AllocateChannels(number);
- OUTPUT:
- RETVAL
-
-AV *
-MixQuerySpec ()
- CODE:
- int freq, channels, status;
- Uint16 format;
- status = Mix_QuerySpec(&freq,&format,&channels);
- RETVAL = newAV();
- av_push(RETVAL,newSViv(status));
- av_push(RETVAL,newSViv(freq));
- av_push(RETVAL,newSViv(format));
- av_push(RETVAL,newSViv(channels));
- OUTPUT:
- RETVAL
-
-Mix_Chunk *
-MixLoadWAV ( filename )
- char *filename
- PREINIT:
- char * CLASS = "SDL::Mixer::MixChunk";
- CODE:
- Mix_Chunk * mixchunk;
- mixchunk = Mix_LoadWAV(filename);
- if (mixchunk == NULL) {
- fprintf(stderr, "Could not load %s\n", filename);
- }
- RETVAL = mixchunk;
- OUTPUT:
- RETVAL
-
-Mix_Music *
-MixLoadMUS ( filename )
- char *filename
- PREINIT:
- char * CLASS = "SDL::Mixer::MixMusic";
- CODE:
- Mix_Music * mixmusic;
- mixmusic = Mix_LoadMUS(filename);
- if (mixmusic == NULL) {
- fprintf(stderr, "Could not load %s\n", filename);
- }
- RETVAL = mixmusic;
- OUTPUT:
- RETVAL
-
-Mix_Chunk *
-MixQuickLoadWAV ( buf )
- Uint8 *buf
- PREINIT:
- char * CLASS = "SDL::Mixer::MixChunk";
- CODE:
- RETVAL = Mix_QuickLoad_WAV(buf);
- OUTPUT:
- RETVAL
-
-void
-MixFreeChunk( chunk )
- Mix_Chunk *chunk
- CODE:
- Mix_FreeChunk(chunk);
-
-void
-MixFreeMusic ( music )
- Mix_Music *music
- CODE:
- Mix_FreeMusic(music);
-
-void
-MixSetPostMixCallback ( func, arg )
- void *func
- void *arg
- CODE:
- Mix_SetPostMix(func,arg);
-
-void*
-PerlMixMusicHook ()
- CODE:
- RETVAL = sdl_perl_music_callback;
- OUTPUT:
- RETVAL
-
-void
-MixSetMusicHook ( func, arg )
- void *func
- void *arg
- CODE:
- Mix_HookMusic(func,arg);
-
-void
-MixSetMusicFinishedHook ( func )
- void *func
- CODE:
- mix_music_finished_cv = func;
- Mix_HookMusicFinished(sdl_perl_music_finished_callback);
-
-void *
-MixGetMusicHookData ()
- CODE:
- RETVAL = Mix_GetMusicHookData();
- OUTPUT:
- RETVAL
-
-int
-MixReverseChannels ( number )
- int number
- CODE:
- RETVAL = Mix_ReserveChannels ( number );
- OUTPUT:
- RETVAL
-
-int
-MixGroupChannel ( which, tag )
- int which
- int tag
- CODE:
- RETVAL = Mix_GroupChannel(which,tag);
- OUTPUT:
- RETVAL
-
-int
-MixGroupChannels ( from, to, tag )
- int from
- int to
- int tag
- CODE:
- RETVAL = Mix_GroupChannels(from,to,tag);
- OUTPUT:
- RETVAL
-
-int
-MixGroupAvailable ( tag )
- int tag
- CODE:
- RETVAL = Mix_GroupAvailable(tag);
- OUTPUT:
- RETVAL
-
-int
-MixGroupCount ( tag )
- int tag
- CODE:
- RETVAL = Mix_GroupCount(tag);
- OUTPUT:
- RETVAL
-
-int
-MixGroupOldest ( tag )
- int tag
- CODE:
- RETVAL = Mix_GroupOldest(tag);
- OUTPUT:
- RETVAL
-
-int
-MixGroupNewer ( tag )
- int tag
- CODE:
- RETVAL = Mix_GroupNewer(tag);
- OUTPUT:
- RETVAL
-
-int
-MixPlayChannel ( channel, chunk, loops )
- int channel
- Mix_Chunk *chunk
- int loops
- CODE:
- RETVAL = Mix_PlayChannel(channel,chunk,loops);
- OUTPUT:
- RETVAL
-
-int
-MixPlayChannelTimed ( channel, chunk, loops, ticks )
- int channel
- Mix_Chunk *chunk
- int loops
- int ticks
- CODE:
- RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
- OUTPUT:
- RETVAL
-
-int
-MixPlayMusic ( music, loops )
- Mix_Music *music
- int loops
- CODE:
- RETVAL = Mix_PlayMusic(music,loops);
- OUTPUT:
- RETVAL
-
-int
-MixFadeInChannel ( channel, chunk, loops, ms )
- int channel
- Mix_Chunk *chunk
- int loops
- int ms
- CODE:
- RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
- OUTPUT:
- RETVAL
-
-int
-MixFadeInChannelTimed ( channel, chunk, loops, ms, ticks )
- int channel
- Mix_Chunk *chunk
- int loops
- int ticks
- int ms
- CODE:
- RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
- OUTPUT:
- RETVAL
-
-int
-MixFadeInMusic ( music, loops, ms )
- Mix_Music *music
- int loops
- int ms
- CODE:
- RETVAL = Mix_FadeInMusic(music,loops,ms);
- OUTPUT:
- RETVAL
-
-int
-MixVolume ( channel, volume )
- int channel
- int volume
- CODE:
- RETVAL = Mix_Volume(channel,volume);
- OUTPUT:
- RETVAL
-
-int
-MixVolumeChunk ( chunk, volume )
- Mix_Chunk *chunk
- int volume
- CODE:
- RETVAL = Mix_VolumeChunk(chunk,volume);
- OUTPUT:
- RETVAL
-
-int
-MixVolumeMusic ( volume )
- int volume
- CODE:
- RETVAL = Mix_VolumeMusic(volume);
- OUTPUT:
- RETVAL
-
-int
-MixHaltChannel ( channel )
- int channel
- CODE:
- RETVAL = Mix_HaltChannel(channel);
- OUTPUT:
- RETVAL
-
-int
-MixHaltGroup ( tag )
- int tag
- CODE:
- RETVAL = Mix_HaltGroup(tag);
- OUTPUT:
- RETVAL
-
-int
-MixHaltMusic ()
- CODE:
- RETVAL = Mix_HaltMusic();
- OUTPUT:
- RETVAL
-
-int
-MixExpireChannel ( channel, ticks )
- int channel
- int ticks
- CODE:
- RETVAL = Mix_ExpireChannel ( channel,ticks);
- OUTPUT:
- RETVAL
-
-int
-MixFadeOutChannel ( which, ms )
- int which
- int ms
- CODE:
- RETVAL = Mix_FadeOutChannel(which,ms);
- OUTPUT:
- RETVAL
-
-int
-MixFadeOutGroup ( which, ms )
- int which
- int ms
- CODE:
- RETVAL = Mix_FadeOutGroup(which,ms);
- OUTPUT:
- RETVAL
-
-int
-MixFadeOutMusic ( ms )
- int ms
- CODE:
- RETVAL = Mix_FadeOutMusic(ms);
- OUTPUT:
- RETVAL
-
-Mix_Fading
-MixFadingMusic()
- CODE:
- RETVAL = Mix_FadingMusic();
- OUTPUT:
- RETVAL
-
-Mix_Fading
-MixFadingChannel( which )
- int which
- CODE:
- RETVAL = Mix_FadingChannel(which);
- OUTPUT:
- RETVAL
-
-void
-MixPause ( channel )
- int channel
- CODE:
- Mix_Pause(channel);
-
-void
-MixResume ( channel )
- int channel
- CODE:
- Mix_Resume(channel);
-
-int
-MixPaused ( channel )
- int channel
- CODE:
- RETVAL = Mix_Paused(channel);
- OUTPUT:
- RETVAL
-
-void
-MixPauseMusic ()
- CODE:
- Mix_PauseMusic();
-
-void
-MixResumeMusic ()
- CODE:
- Mix_ResumeMusic();
-
-void
-MixRewindMusic ()
- CODE:
- Mix_RewindMusic();
-
-int
-MixPausedMusic ()
- CODE:
- RETVAL = Mix_PausedMusic();
- OUTPUT:
- RETVAL
-
-int
-MixPlaying( channel )
- int channel
- CODE:
- RETVAL = Mix_Playing(channel);
- OUTPUT:
- RETVAL
-
-int
-MixPlayingMusic()
- CODE:
- RETVAL = Mix_PlayingMusic();
- OUTPUT:
- RETVAL
-
-int
-MixSetPanning ( channel, left, right )
- int channel
- int left
- int right
- CODE:
- RETVAL = Mix_SetPanning(channel, left, right);
- OUTPUT:
- RETVAL
-
-void
-MixCloseAudio ()
- CODE:
- Mix_CloseAudio();
-
-#endif
-
char*
AudioDriverName ()
CODE:
@@ -967,11 +542,11 @@ NewSMPEG ( filename, info, use_audio )
SMPEG_Info* info
int use_audio
CODE:
-#ifdef HAVE_SDL_MIXER
- RETVAL = SMPEG_new(filename,info,0);
-#else
+//#ifdef HAVE_SDL_MIXER
+// RETVAL = SMPEG_new(filename,info,0);
+//#else
RETVAL = SMPEG_new(filename,info,use_audio);
-#endif
+//#endif
OUTPUT:
RETVAL
@@ -987,9 +562,9 @@ SMPEGEnableAudio ( mpeg , flag )
int flag
CODE:
SMPEG_enableaudio(mpeg,flag);
-#ifdef HAVE_SDL_MIXER
- sdl_perl_use_smpeg_audio = flag;
-#endif
+//#ifdef HAVE_SDL_MIXER
+// sdl_perl_use_smpeg_audio = flag;
+//#endif
void
SMPEGEnableVideo ( mpeg , flag )
@@ -1035,18 +610,18 @@ SMPEGPlay ( mpeg )
SDL_AudioSpec audiofmt;
Uint16 format;
int freq, channels;
-#ifdef HAVE_SDL_MIXER
- if (sdl_perl_use_smpeg_audio ) {
- SMPEG_enableaudio(mpeg, 0);
- Mix_QuerySpec(&freq, &format, &channels);
- audiofmt.format = format;
- audiofmt.freq = freq;
- audiofmt.channels = channels;
- SMPEG_actualSpec(mpeg, &audiofmt);
- Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
- SMPEG_enableaudio(mpeg, 1);
- }
-#endif
+//#ifdef HAVE_SDL_MIXER
+// if (sdl_perl_use_smpeg_audio ) {
+// SMPEG_enableaudio(mpeg, 0);
+// Mix_QuerySpec(&freq, &format, &channels);
+// audiofmt.format = format;
+// audiofmt.freq = freq;
+// audiofmt.channels = channels;
+// SMPEG_actualSpec(mpeg, &audiofmt);
+// Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
+// SMPEG_enableaudio(mpeg, 1);
+// }
+//#endif
SMPEG_play(mpeg);
SMPEGstatus
@@ -1075,9 +650,9 @@ SMPEGStop ( mpeg )
SMPEG* mpeg
CODE:
SMPEG_stop(mpeg);
-#ifdef HAVE_SDL_MIXER
- Mix_HookMusic(NULL, NULL);
-#endif
+//#ifdef HAVE_SDL_MIXER
+// Mix_HookMusic(NULL, NULL);
+//#endif
void
SMPEGRewind ( mpeg )
@@ -1121,10 +696,20 @@ SMPEGGetInfo ( mpeg )
SMPEG_getinfo(mpeg,RETVAL);
OUTPUT:
RETVAL
-
#endif
+//#ifdef HAVE_SDL_MIXER
+//
+//void*
+//PerlMixMusicHook ()
+// CODE:
+// RETVAL = sdl_perl_music_callback;
+// OUTPUT:
+// RETVAL
+//
+//#endif
+
#ifdef HAVE_SDL_GFX
SDL_Surface *
View
10 t/mixer_mixchunk.t
@@ -3,6 +3,7 @@ use strict;
use warnings;
use SDL;
use SDL::Config;
+use SDL::Mixer;
use SDL::Mixer::MixChunk;
use Test::More;
@@ -23,10 +24,9 @@ else
}
-is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ),
- 0, 'MixOpenAudio passed' );
+is( SDL::Mixer::open_audio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), 0, 'open_audio passed' );
-my $mix_chunk = SDL::MixLoadWAV('test/data/sample.wav');
+my $mix_chunk = SDL::Mixer::load_WAV('test/data/sample.wav');
isa_ok( $mix_chunk, 'SDL::Mixer::MixChunk' );
is( $mix_chunk->volume, 128, 'Default volume is 128' );
@@ -35,11 +35,11 @@ is( $mix_chunk->volume, 100, 'Can change volume to 100' );
is( $mix_chunk->alen, 1926848, 'Alen is 1926848' );
-SDL::MixPlayChannel( -1, $mix_chunk, 0 );
+SDL::Mixer::play_channel( -1, $mix_chunk, 0 );
# we close straight away so no audio is actually played
-SDL::MixCloseAudio;
+SDL::Mixer::close_audio();
ok( 1, 'Got to the end' );
SDL::quit;
View
22 t/mixer_mixmusic.t
@@ -1,16 +1,12 @@
-#!perl
use strict;
-use warnings;
use SDL;
use SDL::Config;
-use SDL::Mixer::MixMusic;
use Test::More;
use lib 't/lib';
-
use SDL::TestTool;
-if (! SDL::TestTool->init(SDL_INIT_AUDIO) ) {
+if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
plan( skip_all => 'Failed to init sound' );
}
elsif( !SDL::Config->has('SDL_mixer') )
@@ -19,16 +15,16 @@ elsif( !SDL::Config->has('SDL_mixer') )
}
else
{
- plan( tests => 3 );
+ plan( tests => 5 );
}
-is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ),
- 0, 'MixOpenAudio passed' );
-
-my $mix_music = SDL::MixLoadMUS('test/data/tribe_i.wav'); # from Matthew Newman, http://opengameart.org/content/vocal-grunts-tribeiwav
-#warn 'Error:'. SDL::get_error() if (!$mix_music);
+use_ok( 'SDL::Mixer' );
+use_ok( 'SDL::Mixer::MixMusic' );
+is( SDL::Mixer::open_audio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), 0, 'open_audio passed' );
+my $mix_music = SDL::Mixer::load_MUS('test/data/tribe_i.wav'); # from Matthew Newman, http://opengameart.org/content/vocal-grunts-tribeiwav
+#warn 'Error:'. SDL::get_error() if (!$mix_music);
{
local $TODO = 1;
@@ -37,11 +33,11 @@ my $mix_music = SDL::MixLoadMUS('test/data/tribe_i.wav'); # from Matthew Newman,
isa_ok( $mix_music, 'SDL::Mixer::MixMusic' );
};
-SDL::MixPlayMusic( $mix_music, 0 );
+SDL::Mixer::play_music( $mix_music, 0 );
# we close straight away so no audio is actually played
-SDL::MixCloseAudio;
+SDL::Mixer::close_audio();
ok( 1, 'Got to the end' );
SDL::quit;
View
21 t/mixerpm.t
@@ -15,19 +15,14 @@ elsif( !SDL::Config->has('SDL_mixer') )
}
else
{
- plan( tests => 3 );
+ plan( tests => 2 );
}
-
-
-
-
use_ok( 'SDL::Mixer' );
can_ok ('SDL::Mixer', qw/
- new
query_spec
- reserve_channels
+ reverse_channels
allocate_channels
group_channel
group_channels
@@ -39,12 +34,12 @@ can_ok ('SDL::Mixer', qw/
play_music
fade_in_channel
fade_in_music
- channel_volume
- music_volume
+ volume
+ volume_music
halt_channel
halt_group
halt_music
- channel_expire
+ expire_channel
fade_out_channel
fade_out_group
fade_out_music
@@ -56,13 +51,9 @@ can_ok ('SDL::Mixer', qw/
pause_music
resume_music
rewind_music
- music_paused
+ paused_music
playing
playing_music
/);
-
-# these are exported by default, so main:: should know them:
-my $mixer = SDL::Mixer->new();
-isa_ok($mixer, 'SDL::Mixer', 'Checking if mixer can be build');
sleep(2);
Please sign in to comment.
Something went wrong with that request. Please try again.