Skip to content

Commit

Permalink
only doing callback stuff when USE_THREADS is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Leich committed Dec 15, 2010
1 parent 4aa27a8 commit 8e0230c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/Mixer/Channels.xs
Expand Up @@ -22,6 +22,7 @@ static int sdl_perl_use_smpeg_audio = 0;
#endif
#endif

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

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

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

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

#ifdef USE_THREADS

void
mixchan_channel_finished( fn )
SV* fn
CODE:
parent_perl = 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

0 comments on commit 8e0230c

Please sign in to comment.