Permalink
Browse files

Migrate CD, CDTrack, CDROM. use safemalloc instead of malloc in Audio…

…Spec. Clean warning in Audio.xs. Added CDROM builds to Build.PL.
  • Loading branch information...
1 parent 32bfa0b commit 0ceb9780e23e2c4c5337fb44f61f2b8d8ddfd514 @kthakore kthakore committed Nov 18, 2009
Showing with 266 additions and 171 deletions.
  1. +21 −0 Build.PL
  2. +9 −0 lib/SDL/CD.pm
  3. +9 −0 lib/SDL/CDROM.pm
  4. +9 −0 lib/SDL/CDTrack.pm
  5. +0 −1 src/Core/Audio.xs
  6. +28 −0 src/Core/CDROM.xs
  7. +1 −1 src/Core/objects/AudioSpec.xs
  8. +136 −0 src/Core/objects/CD.xs
  9. +45 −0 src/Core/objects/CDTrack.xs
  10. +0 −164 src/SDL.xs
  11. +5 −0 t/00-load.t
  12. +1 −3 t/core_audio.t
  13. +2 −2 typemap
View
21 Build.PL
@@ -168,6 +168,27 @@ my %subsystems =
},
libraries => [qw( SDL )],
},
+ CDROM => {
+ file => {
+ from => 'src/Core/CDROM.xs',
+ to => 'lib/SDL/CDROM.xs',
+ },
+ libraries => [qw( SDL )],
+ },
+ CDTrack => {
+ file => {
+ from => 'src/Core/objects/CDTrack.xs',
+ to => 'lib/SDL/CDTrack.xs',
+ },
+ libraries => [qw( SDL )],
+ },
+ CD => {
+ file => {
+ from => 'src/Core/objects/CD.xs',
+ to => 'lib/SDL/CD.xs',
+ },
+ libraries => [qw( SDL )],
+ },
TTF_Font => {
file => {
View
9 lib/SDL/CD.pm
@@ -0,0 +1,9 @@
+package SDL::CD;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::CD;
+
+1;
View
9 lib/SDL/CDROM.pm
@@ -0,0 +1,9 @@
+package SDL::CDROM;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::CDROM;
+
+1;
View
9 lib/SDL/CDTrack.pm
@@ -0,0 +1,9 @@
+package SDL::CDTrack;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::CDTrack;
+
+1;
View
1 src/Core/Audio.xs
@@ -60,7 +60,6 @@ audio_load_wav ( filename, spec )
}
else
{
- warn ("sd");
RETVAL = newAV();
RETVAL = sv_2mortal((SV*)RETVAL );
av_push(RETVAL, sv_setref_pv( asref, "SDL::AudioSpec", (void *)temp));
View
28 src/Core/CDROM.xs
@@ -0,0 +1,28 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+MODULE = SDL::CDROM PACKAGE = SDL::CDROM PREFIX = cd_
+
+int
+cd_num_drives ()
+ CODE:
+ RETVAL = SDL_CDNumDrives();
+ OUTPUT:
+ RETVAL
+
+char *
+cd_name ( drive )
+ int drive
+ CODE:
+ RETVAL = strdup(SDL_CDName(drive));
+ OUTPUT:
+ RETVAL
+
+
View
2 src/Core/objects/AudioSpec.xs
@@ -40,7 +40,7 @@ SDL_AudioSpec *
audiospec_new (CLASS)
char* CLASS
CODE:
- RETVAL = malloc(sizeof(SDL_AudioSpec));
+ RETVAL = safemalloc(sizeof(SDL_AudioSpec));
OUTPUT:
RETVAL
View
136 src/Core/objects/CD.xs
@@ -0,0 +1,136 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+MODULE = SDL::CD PACKAGE = SDL::CD PREFIX = cdr_
+
+SDL_CD *
+cdr_new ( CLASS, drive )
+ char* CLASS
+ int drive
+ CODE:
+ RETVAL = SDL_CDOpen(drive);
+ OUTPUT:
+ RETVAL
+
+
+Uint32
+cdr_status ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = SDL_CDStatus(cd);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_play_tracks ( cd, start_track, ntracks, start_frame, nframes )
+ SDL_CD *cd
+ int start_track
+ int ntracks
+ int start_frame
+ int nframes
+ CODE:
+ RETVAL = SDL_CDPlayTracks(cd,start_track,start_frame,ntracks,nframes);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_play ( cd, start, length )
+ SDL_CD *cd
+ int start
+ int length
+ CODE:
+ RETVAL = SDL_CDPlay(cd,start,length);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_pause ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = SDL_CDPause(cd);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_resume ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = SDL_CDResume(cd);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_stop ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = SDL_CDStop(cd);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_eject ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = SDL_CDEject(cd);
+ OUTPUT:
+ RETVAL
+
+int
+cdr_id ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = cd->id;
+ OUTPUT:
+ RETVAL
+
+int
+cdr_num_tracks ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = cd->numtracks;
+ OUTPUT:
+ RETVAL
+
+int
+cdr_cur_track ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = cd->cur_track;
+ OUTPUT:
+ RETVAL
+
+int
+cdr_cur_frame ( cd )
+ SDL_CD *cd
+ CODE:
+ RETVAL = cd->cur_frame;
+ OUTPUT:
+ RETVAL
+
+SDL_CDtrack *
+cdr_track ( cd, number )
+ SDL_CD *cd
+ int number
+ PREINIT:
+ char* CLASS = "SDL::CDTrack";
+ CODE:
+ RETVAL = (SDL_CDtrack *)(cd->track + number);
+ OUTPUT:
+ RETVAL
+
+
+
+void
+cdr_DESTROY ( cd )
+ SDL_CD *cd
+ CODE:
+ SDL_CDClose(cd);
+
+
View
45 src/Core/objects/CDTrack.xs
@@ -0,0 +1,45 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+MODULE = SDL::CDTrack PACKAGE = SDL::CDTrack PREFIX = cdt_
+
+Uint8
+cdt_track_id ( track )
+ SDL_CDtrack *track
+ CODE:
+ RETVAL = track->id;
+ OUTPUT:
+ RETVAL
+
+Uint8
+cdt_track_type ( track )
+ SDL_CDtrack *track
+ CODE:
+ RETVAL = track->type;
+ OUTPUT:
+ RETVAL
+
+Uint16
+cdt_track_length ( track )
+ SDL_CDtrack *track
+ CODE:
+ RETVAL = track->length;
+ OUTPUT:
+ RETVAL
+
+Uint32
+cdt_track_offset ( track )
+ SDL_CDtrack *track
+ CODE:
+ RETVAL = track->offset;
+ OUTPUT:
+ RETVAL
+
+
View
164 src/SDL.xs
@@ -512,170 +512,6 @@ RWclose ( rw )
OUTPUT:
RETVAL
-int
-CDNumDrives ()
- CODE:
- RETVAL = SDL_CDNumDrives();
- OUTPUT:
- RETVAL
-
-char *
-CDName ( drive )
- int drive
- CODE:
- RETVAL = strdup(SDL_CDName(drive));
- OUTPUT:
- RETVAL
-
-SDL_CD *
-CDOpen ( drive )
- int drive
- CODE:
- RETVAL = SDL_CDOpen(drive);
- OUTPUT:
- RETVAL
-
-Uint8
-CDTrackId ( track )
- SDL_CDtrack *track
- CODE:
- RETVAL = track->id;
- OUTPUT:
- RETVAL
-
-Uint8
-CDTrackType ( track )
- SDL_CDtrack *track
- CODE:
- RETVAL = track->type;
- OUTPUT:
- RETVAL
-
-Uint16
-CDTrackLength ( track )
- SDL_CDtrack *track
- CODE:
- RETVAL = track->length;
- OUTPUT:
- RETVAL
-
-Uint32
-CDTrackOffset ( track )
- SDL_CDtrack *track
- CODE:
- RETVAL = track->offset;
- OUTPUT:
- RETVAL
-
-Uint32
-CDStatus ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = SDL_CDStatus(cd);
- OUTPUT:
- RETVAL
-
-int
-CDPlayTracks ( cd, start_track, ntracks, start_frame, nframes )
- SDL_CD *cd
- int start_track
- int ntracks
- int start_frame
- int nframes
- CODE:
- RETVAL = SDL_CDPlayTracks(cd,start_track,start_frame,ntracks,nframes);
- OUTPUT:
- RETVAL
-
-int
-CDPlay ( cd, start, length )
- SDL_CD *cd
- int start
- int length
- CODE:
- RETVAL = SDL_CDPlay(cd,start,length);
- OUTPUT:
- RETVAL
-
-int
-CDPause ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = SDL_CDPause(cd);
- OUTPUT:
- RETVAL
-
-int
-CDResume ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = SDL_CDResume(cd);
- OUTPUT:
- RETVAL
-
-int
-CDStop ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = SDL_CDStop(cd);
- OUTPUT:
- RETVAL
-
-int
-CDEject ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = SDL_CDEject(cd);
- OUTPUT:
- RETVAL
-
-void
-CDClose ( cd )
- SDL_CD *cd
- CODE:
- SDL_CDClose(cd);
-
-int
-CDId ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = cd->id;
- OUTPUT:
- RETVAL
-
-int
-CDNumTracks ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = cd->numtracks;
- OUTPUT:
- RETVAL
-
-int
-CDCurTrack ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = cd->cur_track;
- OUTPUT:
- RETVAL
-
-int
-CDCurFrame ( cd )
- SDL_CD *cd
- CODE:
- RETVAL = cd->cur_frame;
- OUTPUT:
- RETVAL
-
-SDL_CDtrack *
-CDTrack ( cd, number )
- SDL_CD *cd
- int number
- CODE:
- RETVAL = (SDL_CDtrack *)(cd->track + number);
- OUTPUT:
- RETVAL
-
#ifdef HAVE_SDL_IMAGE
SDL_Surface *
View
5 t/00-load.t
@@ -19,6 +19,11 @@ SDL::Event
SDL::Mouse
SDL::Joystick
SDL::Cursor
+SDL::Audio
+SDL::AudioSpec
+SDL::CDROM
+SDL::CDTrack
+SDL::CD
/;
plan tests => scalar @modules;
View
4 t/core_audio.t
@@ -12,7 +12,7 @@ use SDL::TestTool;
if ( SDL::TestTool->init_audio ) {
plan( skip_all => 'Failed to init sound' );
} else {
- plan( tests => 19 );
+ plan( tests => 17 );
}
my @done = qw/
audio_spec
@@ -74,8 +74,6 @@ is( SDL::Audio::get_audio_status, SDL_AUDIO_STOPPED,
my @left = qw/
- load_wav
- free_wav
audio_cvt
build_audio_cvt
convert_audio
View
4 typemap
@@ -34,8 +34,8 @@ SDL_QuitEvent * O_OBJECT
SDL_keysym * O_OBJECT
SDL_Surface * O_OBJECT
SDL_SysWMmsg * T_PTR
-SDL_CD * T_PTR
-SDL_CDtrack * T_PTR
+SDL_CD * O_OBJECT
+SDL_CDtrack * O_OBJECT
SDL_TimerCallback T_PTR
SDL_Rect * O_OBJECT
SDL_Color * O_OBJECT

0 comments on commit 0ceb978

Please sign in to comment.