Skip to content

Commit

Permalink
using parent_perl's context instead of TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Leich committed Mar 19, 2011
1 parent bb29ff1 commit 3650d59
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Mixer/Music.xs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ char *fcb = NULL;

void mix_func(void *udata, Uint8 *stream, int len)
{
ENTER_TLS_CONTEXT;
PERL_SET_CONTEXT(parent_perl);
dSP; /* initialize stack pointer */
ENTER; /* everything created after here */
SAVETMPS; /* ...is a temporary variable. */
Expand Down Expand Up @@ -43,20 +43,18 @@ void mix_func(void *udata, Uint8 *stream, int len)

FREETMPS; /* free that return value */
LEAVE; /* ...and the XPUSHed "mortal" args. */
LEAVE_TLS_CONTEXT;
}

void mix_finished(void)
{
ENTER_TLS_CONTEXT;
PERL_SET_CONTEXT(parent_perl);
dSP; /* initialize stack pointer */
PUSHMARK(SP); /* remember the stack pointer */

if(fcb != NULL)
{
call_pv(fcb, G_DISCARD|G_VOID); /* call the function */
}
LEAVE_TLS_CONTEXT;
}

#endif
Expand Down Expand Up @@ -140,7 +138,7 @@ mixmus_hook_music( func = NULL, arg = 0 )
CODE:
if(func != NULL)
{
GET_TLS_CONTEXT;
parent_perl = PERL_GET_CONTEXT;
cb = func;
void *arg2 = safemalloc(sizeof(int));
*(int*) arg2 = arg;
Expand All @@ -160,7 +158,7 @@ mixmus_hook_music_finished( func = NULL )
CODE:
if(func != NULL)
{
GET_TLS_CONTEXT;
parent_perl = PERL_GET_CONTEXT;
fcb = func;
Mix_HookMusicFinished(&mix_finished);
}
Expand Down

0 comments on commit 3650d59

Please sign in to comment.