[Scummvm-git-logs] scummvm master -> 3ecc32331b164dddbefe6a17aa4a728e0e15b21d

spleen1981 noreply at scummvm.org
Thu Apr 20 11:08:35 UTC 2023


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6cf91e9438 LIBRETRO: fix emu thread deinit
2b141e63b6 LIBRETRO: add g_system->destroy()
3ecc32331b LIBRETRO: fix retro_get_memory_data return value


Commit: 6cf91e943835c8a11e2b496956fb495fe48db5d7
    https://github.com/scummvm/scummvm/commit/6cf91e943835c8a11e2b496956fb495fe48db5d7
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-20T13:06:51+02:00

Commit Message:
LIBRETRO: fix emu thread deinit

Changed paths:
    backends/platform/libretro/src/libretro-threads.cpp
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro-threads.cpp b/backends/platform/libretro/src/libretro-threads.cpp
index dc1997ccc9e..117ba7c7427 100644
--- a/backends/platform/libretro/src/libretro-threads.cpp
+++ b/backends/platform/libretro/src/libretro-threads.cpp
@@ -78,7 +78,6 @@ static void retro_wrap_emulator(void) {
 	status &= ~EMU_EXITED;
 	scummvm_res = retro_run_emulator();
 	status |= EMU_EXITED;
-
 	retro_exit_to_main_thread();
 }
 
@@ -106,6 +105,8 @@ static void retro_free_emu_thread() {
 }
 
 void retro_switch_to_emu_thread() {
+	if (retro_emu_thread_exited() || !retro_emu_thread_initialized())
+		return;
 #ifdef USE_LIBCO
 	co_switch(emu_thread);
 #else
@@ -169,11 +170,8 @@ bool retro_init_emu_thread(void) {
 }
 
 void retro_deinit_emu_thread() {
-	if (!retro_emu_thread_initialized())
-		return;
-	if (!retro_current_thread_is_main())
-		retro_switch_to_main_thread();
-	retro_free_emu_thread();
+	if (retro_emu_thread_initialized())
+		retro_free_emu_thread();
 }
 
 int retro_get_scummvm_res() {
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index c8027cc4915..ea4a77d2ef9 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -671,15 +671,6 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i
 }
 
 void retro_run(void) {
-
-	if (retro_emu_thread_exited())
-		retro_deinit_emu_thread();
-
-	if (!retro_emu_thread_initialized()) {
-		environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
-		return;
-	}
-
 	bool updated = false;
 	if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated){
 		update_variables();
@@ -763,6 +754,14 @@ void retro_run(void) {
 			if (!skip_frame)
 				retro_switch_to_emu_thread();
 
+			if (retro_emu_thread_exited())
+				retro_deinit_emu_thread();
+
+			if (!retro_emu_thread_initialized()) {
+				environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
+				return;
+			}
+
 			/* Retrieve audio */
 			samples_count = 0;
 			if (audio_video_enable & 2) {
@@ -799,13 +798,13 @@ void retro_run(void) {
 }
 
 void retro_unload_game(void) {
-	if (!retro_emu_thread_initialized())
-		return;
-	while (!retro_emu_thread_exited()) {
-		retroQuit();
-		retro_switch_to_emu_thread();
+	if (retro_emu_thread_initialized()) {
+		while (!retro_emu_thread_exited()) {
+			retroQuit();
+			retro_switch_to_emu_thread();
+		}
+		retro_deinit_emu_thread();
 	}
-	retro_deinit_emu_thread();
 
 	if (retro_get_scummvm_res() == Common::kNoError)
 		log_cb(RETRO_LOG_INFO, "ScummVM exited successfully.\n");


Commit: 2b141e63b62f8f7695edb86092bf1b13f38dcfb3
    https://github.com/scummvm/scummvm/commit/2b141e63b62f8f7695edb86092bf1b13f38dcfb3
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-20T13:07:03+02:00

Commit Message:
LIBRETRO: add g_system->destroy()

Changed paths:
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index ea4a77d2ef9..9fe6928ca03 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -540,6 +540,7 @@ void retro_init(void) {
 }
 
 void retro_deinit(void) {
+	g_system->destroy();
 	free(sound_buffer);
 }
 
@@ -812,7 +813,6 @@ void retro_unload_game(void) {
 		log_cb(RETRO_LOG_WARN, "ScummVM not initialized correctly.\n", frameskip_counter, current_frame);
 	else
 		log_cb(RETRO_LOG_ERROR, "ScummVM exited with error %d.\n", retro_get_scummvm_res());
-	// g_system->destroy(); //TODO: This call causes "pure virtual method called" after frontend "Unloading core symbols". Check if needed at all.
 }
 
 void retro_reset(void) {


Commit: 3ecc32331b164dddbefe6a17aa4a728e0e15b21d
    https://github.com/scummvm/scummvm/commit/3ecc32331b164dddbefe6a17aa4a728e0e15b21d
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-20T13:07:16+02:00

Commit Message:
LIBRETRO: fix retro_get_memory_data return value

Changed paths:
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 9fe6928ca03..abbf94d72c8 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -821,7 +821,7 @@ void retro_reset(void) {
 
 // Stubs
 void *retro_get_memory_data(unsigned type) {
-	return 0;
+	return NULL;
 }
 size_t retro_get_memory_size(unsigned type) {
 	return 0;




More information about the Scummvm-git-logs mailing list