feat: Clean up resources on garbage collect
This commit is contained in:
parent
8c09fc4e7a
commit
1da668d7d6
1 changed files with 13 additions and 1 deletions
|
@ -71,8 +71,20 @@ pulseaudio_new(lua_State* L)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Implement `__gc` meta method to free the inner `pa_glib_mainloop`
|
/**
|
||||||
|
* Free the PulseAudio object
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
pulseaudio__gc(lua_State* L)
|
||||||
|
{
|
||||||
|
pulseaudio* pa = luaL_checkudata(L, 1, LUA_PULSEAUDIO);
|
||||||
|
pa_glib_mainloop_free(pa->mainloop);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const struct luaL_Reg pulseaudio_mt [] = {
|
static const struct luaL_Reg pulseaudio_mt [] = {
|
||||||
|
{"__gc", pulseaudio__gc},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue