Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PerlGameDev/SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
kthakore committed Dec 16, 2010
2 parents 90c4131 + 8e0230c commit 310623e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Revision history for Perl extension SDL_perl.
- Fixed typo in MANIFEST.SKIP file, scripts-folder is now in dist [FROGGS]
- Setting LD_LIBRARY_PATH to Alien::SDL's libdir for OpenBSD [FROGGS]
- Using UV instead of IV for SDL::Event attributes [kthakore]
- (experimental) Changing *_TLS_CONTEXT to parent perls context in SDL::Mixer::Channels [FROGGS]

* 2.524
- Fix for t/mixer_channels.t.bak
Expand Down
33 changes: 21 additions & 12 deletions src/Mixer/Channels.xs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "XSUB.h"
#define NEED_sv_2pv_flag
#include "ppport.h"
#include "defines.h"

#ifndef aTHX_
#define aTHX_
Expand All @@ -21,15 +22,12 @@ static int sdl_perl_use_smpeg_audio = 0;
#endif
#endif

PerlInterpreter * context = NULL;
static SV * cb = (SV*)NULL;
#ifdef USE_THREADS
static SV * cb = (SV*)NULL;

void callback(int channel)
{
if(NULL == context)
return;

PERL_SET_CONTEXT(context);
PERL_SET_CONTEXT(parent_perl);

dSP;
ENTER;
Expand All @@ -45,6 +43,7 @@ void callback(int channel)
FREETMPS;
LEAVE;
}
#endif

MODULE = SDL::Mixer::Channels PACKAGE = SDL::Mixer::Channels PREFIX = mixchan_

Expand Down Expand Up @@ -159,20 +158,30 @@ mixchan_fade_out_channel ( which, ms )
OUTPUT:
RETVAL

#ifdef USE_THREADS

void
mixchan_channel_finished( fn )
SV* fn
CODE:
if(context == NULL)
context = PERL_GET_CONTEXT;

if (cb == (SV*)NULL)
cb = newSVsv(fn);
cb = newSVsv(fn);
else
SvSetSV(cb, fn);

SvSetSV(cb, fn);

parent_perl = PERL_GET_CONTEXT;
Mix_ChannelFinished(&callback);

#else

void
mixchan_channel_finished( fn )
SV* fn
CODE:
warn("Perl need to be compiled with 'useithreads' for SDL::Mixer::Channels::channel_finished( cb )");

#endif

int
mixchan_playing( channel )
int channel
Expand Down
14 changes: 11 additions & 3 deletions src/Mixer/objects/MixChunk.xs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include "helper.h"
#include "defines.h"

#ifndef aTHX_
#define aTHX_
Expand All @@ -11,6 +13,12 @@

#ifdef HAVE_SDL_MIXER
#include <SDL_mixer.h>

void _free_mixchunk(void *object)
{
Mix_FreeChunk((Mix_Chunk *)object);
}

#endif

MODULE = SDL::Mixer::MixChunk PACKAGE = SDL::Mixer::MixChunk PREFIX = mixchunk_
Expand Down Expand Up @@ -48,9 +56,9 @@ mixchunk_volume ( mixchunk, ... )
RETVAL

void
mixchunk_DESTROY(mixchunk)
Mix_Chunk *mixchunk
mixchunk_DESTROY(bag)
SV *bag
CODE:
Mix_FreeChunk(mixchunk);
objDESTROY(bag, _free_mixchunk);

#endif

0 comments on commit 310623e

Please sign in to comment.