mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-25 03:41:02 +00:00
Do music fade callback on main thread
Fixes music fades crashing the game sometimes
Backport from SRB2
See: 0aa763df85
Credits to Lactozilla
This commit is contained in:
parent
62294dfe35
commit
a7164a5d8f
1 changed files with 11 additions and 3 deletions
|
@ -90,6 +90,7 @@ static UINT32 fading_timer;
|
|||
static UINT32 fading_duration;
|
||||
static INT32 fading_id;
|
||||
static void (*fading_callback)(void);
|
||||
static boolean fading_do_callback;
|
||||
|
||||
#ifdef HAVE_LIBGME
|
||||
static Music_Emu *gme;
|
||||
|
@ -106,6 +107,7 @@ static void var_cleanup(void)
|
|||
is_fading = false;
|
||||
|
||||
fading_callback = NULL;
|
||||
fading_do_callback = false;
|
||||
|
||||
internal_volume = 100;
|
||||
}
|
||||
|
@ -202,6 +204,13 @@ void I_ShutdownSound(void)
|
|||
|
||||
void I_UpdateSound(void)
|
||||
{
|
||||
if (fading_do_callback)
|
||||
{
|
||||
if (fading_callback)
|
||||
(*fading_callback)();
|
||||
fading_callback = NULL;
|
||||
fading_do_callback = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
@ -526,9 +535,8 @@ static UINT32 get_adjusted_position(UINT32 position)
|
|||
|
||||
static void do_fading_callback(void)
|
||||
{
|
||||
if (fading_callback)
|
||||
(*fading_callback)();
|
||||
fading_callback = NULL;
|
||||
// TODO: Should I use a mutex here or something?
|
||||
fading_do_callback = true;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
|
Loading…
Reference in a new issue