From 7800a893a3d1a1e89c28be93c81ddb82ead57467 Mon Sep 17 00:00:00 2001 From: hgy29 Date: Tue, 9 May 2023 15:59:39 +0200 Subject: [PATCH] [audio] Move destructor out of luau GC --- luabinding/audiobinder.cpp | 10 +++++++++- luabinding/audiobinder.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/luabinding/audiobinder.cpp b/luabinding/audiobinder.cpp index 23ad53bff..49c120b6a 100644 --- a/luabinding/audiobinder.cpp +++ b/luabinding/audiobinder.cpp @@ -622,11 +622,19 @@ int AudioBinder::SoundChannel_destruct(void *p) { void *ptr = GIDEROS_DTOR_UDATA(p); GGSoundChannel *soundChannel = static_cast(ptr); - soundChannel->unref(); + lua_postgc(soundChannel->L,SoundChannel_destruct_real,ptr); return 0; } +int AudioBinder::SoundChannel_destruct_real(lua_State *L, void *ptr) +{ + G_UNUSED(L); + GGSoundChannel *soundChannel = static_cast(ptr); + soundChannel->unref(); + + return 0; +} int AudioBinder::SoundChannel_stop(lua_State *L) { diff --git a/luabinding/audiobinder.h b/luabinding/audiobinder.h index 3b466a6d1..8d8d5e28f 100644 --- a/luabinding/audiobinder.h +++ b/luabinding/audiobinder.h @@ -18,6 +18,7 @@ class AudioBinder static int Sound_hasEffect(lua_State *L); static int SoundChannel_destruct(void *p); + static int SoundChannel_destruct_real(lua_State *L,void *p); static int SoundChannel_stop(lua_State *L); static int SoundChannel_setPosition(lua_State *L); static int SoundChannel_getPosition(lua_State *L);