},
libraries => [qw( SDL )],
},
+ MixChunk => {
+ file => {
+ from => 'src/Core/objects/MixChunk.xs',
+ to => 'lib/SDL/MixChunk.xs',
+ },
+ libraries => [qw( SDL )],
+ },
Palette => {
file => {
from => 'src/Core/objects/Palette.xs',
--- /dev/null
+package SDL::MixChunk;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::MixChunk;
+
+1;
--- /dev/null
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+#include <SDL_mixer.h>
+
+MODULE = SDL::MixChunk PACKAGE = SDL::MixChunk PREFIX = mixchunk_
+
+=for documentation
+
+SDL_MixChunk - Stores audio data in memory
+
+ typedef struct {
+ int allocated;
+ Uint8 *abuf;
+ Uint32 alen;
+ Uint8 volume;
+ } Mix_Chunk;
+
+=cut
+
+Uint32
+mixchunk_alen ( mixchunk )
+ Mix_Chunk *mixchunk
+ CODE:
+ RETVAL = mixchunk->alen;
+ OUTPUT:
+ RETVAL
+
+Uint8
+mixchunk_volume ( mixchunk, ... )
+ Mix_Chunk *mixchunk
+ CODE:
+ if (items > 1 ) mixchunk->volume = SvIV(ST(1));
+ RETVAL = mixchunk->volume;
+ OUTPUT:
+ RETVAL
+
+void
+mixchunk_DESTROY(mixchunk)
+ Mix_Chunk *mixchunk
+ CODE:
+ Mix_FreeChunk(mixchunk);
Mix_Chunk *
MixLoadWAV ( filename )
char *filename
+ PREINIT:
+ char * CLASS = "SDL::MixChunk";
CODE:
- RETVAL = Mix_LoadWAV(filename);
+ Mix_Chunk * mixchunk;
+ mixchunk = Mix_LoadWAV(filename);
+ if (mixchunk == NULL) {
+ fprintf(stderr, "Could not load %s\n", filename);
+ }
+ RETVAL = mixchunk;
OUTPUT:
RETVAL
Mix_Chunk *
MixQuickLoadWAV ( buf )
Uint8 *buf
+ PREINIT:
+ char * CLASS = "SDL::MixChunk";
CODE:
RETVAL = Mix_QuickLoad_WAV(buf);
OUTPUT:
--- /dev/null
+#!perl
+use strict;
+use warnings;
+use SDL;
+use SDL::MixChunk;
+use Test::More tests => 6;
+
+is( SDL::init(SDL_INIT_AUDIO), 0, '[init] returns 0 on success' );
+
+is( SDL::MixOpenAudio(
+ SDL::MIX_DEFAULT_FREQUENCY(), SDL::MIX_DEFAULT_FORMAT(),
+ SDL::MIX_DEFAULT_CHANNELS(), 4096
+ ),
+ 0,
+ 'MixOpenAudio passed'
+);
+
+my $mix_chunk = SDL::MixLoadWAV('test/data/sample.wav');
+isa_ok( $mix_chunk, 'SDL::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, 963424, 'Alen is 963424' );
SDL_AudioSpec * T_PTR
SDL_AudioCVT * T_PTR
Mix_Fading T_UV
-Mix_Chunk * T_PTR
+Mix_Chunk * O_OBJECT
Mix_Music * T_PTR
SDL_GLattr T_IV
int * T_PTR