lr: don't terminate emu on deinit. gl4: buffer wasn't released on term()

shared libraries containing gnuc unique symbols are never unloaded on
linux, and possibly other platforms. So don't terminate the emulator on
deinit and init it only once.
Issue #566

gl4: buffer not released on term() was causing crashes or black screen when restarted.
This commit is contained in:
Flyinghead 2022-04-05 14:53:47 +02:00
parent bf61f5cfe8
commit e0058c17ff
2 changed files with 16 additions and 4 deletions

View File

@ -393,7 +393,7 @@ void termABuffer()
glDeleteVertexArrays(1, &g_quadVertexArray);
g_quadVertexArray = 0;
}
g_quadIndexBuffer.reset();
g_quadBuffer.reset();
g_quadIndexBuffer.reset();
glcache.DeleteProgram(g_abuffer_final_shader.program);
g_abuffer_final_shader.program = 0;

View File

@ -289,6 +289,8 @@ static void retro_keyboard_event(bool down, unsigned keycode, uint32_t character
// Now comes the interesting stuff
void retro_init()
{
static bool emuInited;
// Logging
struct retro_log_callback log;
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
@ -322,6 +324,12 @@ void retro_init()
os_InstallFaultHandler();
MapleConfigMap::UpdateVibration = updateVibration;
#if defined(__GNUC__) && !defined(_WIN32)
if (!emuInited)
#endif
emu.init();
emuInited = true;
}
void retro_deinit()
@ -335,6 +343,12 @@ void retro_deinit()
std::lock_guard<std::mutex> lock(mtx_serialization);
}
os_UninstallFaultHandler();
#if defined(__GNUC__) && !defined(_WIN32)
_vmem_release();
#else
emu.term();
#endif
libretro_supports_bitmasks = false;
categoriesSupported = false;
platformIsDreamcast = true;
@ -1913,13 +1927,11 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i
void retro_unload_game()
{
INFO_LOG(COMMON, "Flycast unloading game");
emu.stop();
emu.unloadGame();
game_data.clear();
disk_paths.clear();
disk_labels.clear();
blankVmus();
emu.term();
}