[Scummvm-git-logs] scummvm master -> 2927be02805bd7de9ac6900a1804f768a4f254c4

spleen1981 noreply at scummvm.org
Mon Feb 5 23:23:47 UTC 2024


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

Summary:
f30910e636 LIBRETRO: fix free audio buffers
cf30fe324f LIBRETRO: refactor and improve audio run loop
3d5c3d7afa LIBRETRO: remove THREAD_SWITCH_UPDATE short loop
fc097c3dbf LIBRETRO: add setLibretroDir
2927be0280 LIBRETRO: add retroarch playlist path retrieving


Commit: f30910e6364085acd4884208a4866458dd4b8d8e
    https://github.com/scummvm/scummvm/commit/f30910e6364085acd4884208a4866458dd4b8d8e
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-02-05T23:20:13+01:00

Commit Message:
LIBRETRO: fix free audio buffers

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


diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index 5bb1f5d9de5..658dc469e2a 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -805,7 +805,14 @@ void retro_init(void) {
 
 void retro_deinit(void) {
 	LIBRETRO_G_SYSTEM->destroy();
-	free(sound_buffer);
+	if (sound_buffer) {
+		free(sound_buffer);
+		sound_buffer = NULL;
+	}
+	if (sound_buffer_empty) {
+		free(sound_buffer_empty);
+		sound_buffer_empty = NULL;
+	}
 	log_scummvm_exit_code();
 }
 


Commit: cf30fe324f26f952bf2a8367b2f0eeaf3f7f1b8f
    https://github.com/scummvm/scummvm/commit/cf30fe324f26f952bf2a8367b2f0eeaf3f7f1b8f
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-02-05T23:20:30+01:00

Commit Message:
LIBRETRO: refactor and improve audio run loop

Changed paths:
    backends/platform/libretro/include/libretro-defs.h
    backends/platform/libretro/src/libretro-core.cpp


diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index c33f7b8c375..b9698df8540 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -18,6 +18,11 @@
 #ifndef LIBRETRO_DEFS_H
 #define LIBRETRO_DEFS_H
 
+/* Workaround for a RetroArch audio driver
+ * limitation: a maximum of 1024 frames
+ * can be written per call of audio_batch_cb() */
+#define AUDIO_BATCH_FRAMES_MAX 1024
+
 // System analog stick range is -0x8000 to 0x8000
 #define ANALOG_RANGE 0x8000
 
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index 658dc469e2a..767202a757c 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -100,11 +100,10 @@ static uint32 perf_ref_audio_buff_occupancy = 0;
 
 static float frame_rate = 0;
 static uint16 sample_rate = 0;
-static uint16 samples_per_frame = 0;               // length in samples per frame
-static size_t samples_per_frame_buffer_size = 0;
+static float audio_samples_per_frame   = 0.0f; // length in samples per frame
+static float audio_samples_accumulator = 0.0f;
 
-static int16 *sound_buffer = NULL;               // pointer to output buffer
-static int16 *sound_buffer_empty = NULL;         // pointer to zeroed output buffer, to regulate GUI FPS
+static int16 *audio_sample_buffer = NULL; // pointer to output buffer
 
 static bool input_bitmask_supported = false;
 static bool updating_variables = false;
@@ -121,20 +120,50 @@ static void log_scummvm_exit_code(void) {
 }
 
 static void audio_buffer_init(uint16 sample_rate, uint16 frame_rate) {
-	samples_per_frame = sample_rate / frame_rate;
+	audio_samples_accumulator = 0.0f;
+	audio_samples_per_frame   = (float)sample_rate / (float)frame_rate;
+	uint32 audio_sample_buffer_size  = ((uint32)audio_samples_per_frame + 1) * 2 * sizeof(int16);
+	audio_sample_buffer       = audio_sample_buffer ? (int16 *)realloc(audio_sample_buffer, audio_sample_buffer_size) : (int16 *)malloc(audio_sample_buffer_size);
 
-	samples_per_frame_buffer_size = samples_per_frame << sizeof(int16);
+	if (audio_sample_buffer)
+		memset(audio_sample_buffer, 0, audio_sample_buffer_size);
+	else
+		retro_log_cb(RETRO_LOG_ERROR, "audio_buffer_init error.\n");
+}
 
-	sound_buffer = sound_buffer ? (int16 *)realloc(sound_buffer, samples_per_frame_buffer_size) : (int16 *)malloc(samples_per_frame_buffer_size);
-	sound_buffer_empty = sound_buffer_empty ? (int16 *)realloc(sound_buffer_empty, samples_per_frame_buffer_size) : (int16 *)malloc(samples_per_frame_buffer_size);
+static void audio_run(void) {
+	int16 *audio_buffer_ptr;
+	uint32 samples_to_read;
+	uint32 samples_produced;
 
-	if (sound_buffer && sound_buffer_empty) {
-		memset(sound_buffer, 0, samples_per_frame_buffer_size);
-		memset(sound_buffer_empty, 0, samples_per_frame_buffer_size);
-	} else
-		retro_log_cb(RETRO_LOG_ERROR, "audio_buffer_init error.\n");
+	/* Audio_samples_per_frame is decimal;
+	 * get integer component */
+	samples_to_read = (uint32)audio_samples_per_frame;
+
+	/* Account for fractional component */
+	audio_samples_accumulator += audio_samples_per_frame - (float)samples_to_read;
+
+	if (audio_samples_accumulator >= 1.0f) {
+		samples_to_read++;
+		audio_samples_accumulator -= 1.0f;
+	}
+
+	samples_produced = ((Audio::MixerImpl *)g_system->getMixer())->mixCallback((byte *) audio_sample_buffer, samples_to_read * 2 * sizeof(int16));
+	audio_status = samples_produced ? (audio_status & ~AUDIO_STATUS_MUTE) : (audio_status | AUDIO_STATUS_MUTE);
+
+	/* Workaround for a RetroArch audio driver
+	 * limitation: a maximum of 1024 frames
+	 * can be written per call of audio_batch_cb(),
+	 * so we have to send samples in chunks */
+	audio_buffer_ptr = audio_sample_buffer;
+	while (samples_produced > 0) {
+		uint32 samples_to_write = (samples_produced > AUDIO_BATCH_FRAMES_MAX) ? AUDIO_BATCH_FRAMES_MAX : samples_produced;
 
-	audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
+		audio_batch_cb(audio_buffer_ptr, samples_to_write);
+
+		samples_produced -= samples_to_write;
+		audio_buffer_ptr += samples_to_write << 1;
+	}
 }
 
 static void retro_audio_buff_status_cb(bool active, unsigned occupancy, bool underrun_likely) {
@@ -805,14 +834,13 @@ void retro_init(void) {
 
 void retro_deinit(void) {
 	LIBRETRO_G_SYSTEM->destroy();
-	if (sound_buffer) {
-		free(sound_buffer);
-		sound_buffer = NULL;
-	}
-	if (sound_buffer_empty) {
-		free(sound_buffer_empty);
-		sound_buffer_empty = NULL;
-	}
+
+	if (audio_sample_buffer)
+		free(audio_sample_buffer);
+
+	audio_sample_buffer       = NULL;
+	audio_samples_per_frame   = 0.0f;
+	audio_samples_accumulator = 0.0f;
 	log_scummvm_exit_code();
 }
 
@@ -1037,6 +1065,7 @@ void retro_run(void) {
 					frameskip_events = 0;
 				}
 			}
+
 			/* Switch to ScummVM thread, unless frameskipping is ongoing */
 			if (!skip_frame)
 				retro_switch_to_emu_thread();
@@ -1047,23 +1076,14 @@ void retro_run(void) {
 			}
 
 			/* Retrieve audio */
-			samples_count = 0;
 			if (audio_video_enable & 2)
-				samples_count = ((Audio::MixerImpl *)g_system->getMixer())->mixCallback((byte *) sound_buffer, samples_per_frame_buffer_size);
-
-			audio_status = samples_count ? (audio_status & ~AUDIO_STATUS_MUTE) : (audio_status | AUDIO_STATUS_MUTE);
+				audio_run();
 
 			/* Retrieve video */
 			if ((audio_video_enable & 1) && !skip_frame) {
 				const Graphics::Surface &screen = LIBRETRO_G_SYSTEM->getScreen();
 				video_cb(screen.getPixels(), screen.w, screen.h, screen.pitch);
 			}
-
-			if (audio_status & AUDIO_STATUS_MUTE)
-				audio_batch_cb((int16 *) sound_buffer_empty, samples_per_frame_buffer_size >> sizeof(int16));
-			else
-				audio_batch_cb((int16 *) sound_buffer, samples_count);
-
 			current_frame++;
 
 		} while (LIBRETRO_G_SYSTEM->getThreadSwitchCaller() & THREAD_SWITCH_UPDATE);


Commit: 3d5c3d7afa8b3f3518cc6330d5f1cc8a3eed080e
    https://github.com/scummvm/scummvm/commit/3d5c3d7afa8b3f3518cc6330d5f1cc8a3eed080e
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-02-05T23:20:46+01:00

Commit Message:
LIBRETRO: remove THREAD_SWITCH_UPDATE short loop

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


diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index 767202a757c..74569ad1198 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -1015,78 +1015,71 @@ void retro_run(void) {
 
 	if (g_system) {
 
-		/* ScummVM is not based on fixed framerate like libretro, and engines/scripts
-		can call multiple screen updates between two retro_run calls. Hence if consecutive screen updates
-		are detected we will loop within the same retro_run call until next pollEvent or
-		delayMillis call in ScummVM thread. */
-		do {
-			/* Determine frameskip need based on settings */
-			if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON))
-				skip_frame = (audio_status & AUDIO_STATUS_BUFFER_UNDERRUN);
-			else if (frameskip_type == 1)
-				skip_frame = !(current_frame % frameskip_no == 0);
-			else if (frameskip_type == 3)
-				skip_frame = (retro_audio_buff_occupancy < frameskip_threshold);
-
-			/* No frame skipping if
-			- no incoming audio (e.g. GUI)
-			- doing a THREAD_SWITCH_UPDATE loop */
-			skip_frame = skip_frame && !(audio_status & AUDIO_STATUS_MUTE) && !(LIBRETRO_G_SYSTEM->getThreadSwitchCaller() & THREAD_SWITCH_UPDATE);
-
-			/* Reset frameskip counter if not flagged */
-			if ((!skip_frame && frameskip_counter) || frameskip_counter >= FRAMESKIP_MAX) {
-				retro_log_cb(RETRO_LOG_DEBUG, "%d frame(s) skipped (%ld)\n", frameskip_counter, current_frame);
-				skip_frame = false;
-				frameskip_counter = 0;
+		/* Determine frameskip need based on settings */
+		if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON))
+			skip_frame = (audio_status & AUDIO_STATUS_BUFFER_UNDERRUN);
+		else if (frameskip_type == 1)
+			skip_frame = !(current_frame % frameskip_no == 0);
+		else if (frameskip_type == 3)
+			skip_frame = (retro_audio_buff_occupancy < frameskip_threshold);
+
+		/* No frame skipping if
+		- no incoming audio (e.g. GUI)
+		- doing a THREAD_SWITCH_UPDATE loop */
+		skip_frame = skip_frame && !(audio_status & AUDIO_STATUS_MUTE);
+
+		/* Reset frameskip counter if not flagged */
+		if ((!skip_frame && frameskip_counter) || frameskip_counter >= FRAMESKIP_MAX) {
+			retro_log_cb(RETRO_LOG_DEBUG, "%d frame(s) skipped (%ld)\n", frameskip_counter, current_frame);
+			skip_frame = false;
+			frameskip_counter = 0;
 			/* Keep on skipping frames if flagged */
-			} else if (skip_frame) {
-				frameskip_counter++;
-				/* Performance counter */
-				if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
-					frameskip_events += frameskip_counter;
-					if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
-						increase_performance();
-						frameskip_events = 0;
-						perf_ref_frame = current_frame;
-						perf_ref_audio_buff_occupancy = 0;
-					}
-				}
-			}
-
-			/* Performance tuner reset if average buffer occupacy is above the required threshold again */
-			if (!skip_frame && (performance_switch & PERF_SWITCH_ON) && performance_switch > PERF_SWITCH_ON) {
-				perf_ref_audio_buff_occupancy += retro_audio_buff_occupancy;
-				if ((current_frame - perf_ref_frame) % (PERF_SWITCH_RESET_REST) == 0) {
-					uint32 avg_audio_buff_occupancy = perf_ref_audio_buff_occupancy / (current_frame + 1 - perf_ref_frame);
-					if (avg_audio_buff_occupancy > PERF_SWITCH_RESET_THRESHOLD || avg_audio_buff_occupancy == retro_audio_buff_occupancy)
-						increase_accuracy();
-					perf_ref_frame = current_frame - 1;
-					perf_ref_audio_buff_occupancy = 0;
+		} else if (skip_frame) {
+			frameskip_counter++;
+			/* Performance counter */
+			if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
+				frameskip_events += frameskip_counter;
+				if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
+					increase_performance();
 					frameskip_events = 0;
+					perf_ref_frame = current_frame;
+					perf_ref_audio_buff_occupancy = 0;
 				}
 			}
+		}
 
-			/* Switch to ScummVM thread, unless frameskipping is ongoing */
-			if (!skip_frame)
-				retro_switch_to_emu_thread();
-
-			if (retro_emu_thread_exited()) {
-				exit_to_frontend();
-				return;
+		/* Performance tuner reset if average buffer occupacy is above the required threshold again */
+		if (!skip_frame && (performance_switch & PERF_SWITCH_ON) && performance_switch > PERF_SWITCH_ON) {
+			perf_ref_audio_buff_occupancy += retro_audio_buff_occupancy;
+			if ((current_frame - perf_ref_frame) % (PERF_SWITCH_RESET_REST) == 0) {
+				uint32 avg_audio_buff_occupancy = perf_ref_audio_buff_occupancy / (current_frame + 1 - perf_ref_frame);
+				if (avg_audio_buff_occupancy > PERF_SWITCH_RESET_THRESHOLD || avg_audio_buff_occupancy == retro_audio_buff_occupancy)
+					increase_accuracy();
+				perf_ref_frame = current_frame - 1;
+				perf_ref_audio_buff_occupancy = 0;
+				frameskip_events = 0;
 			}
+		}
 
-			/* Retrieve audio */
-			if (audio_video_enable & 2)
-				audio_run();
+		/* Switch to ScummVM thread, unless frameskipping is ongoing */
+		if (!skip_frame)
+			retro_switch_to_emu_thread();
 
-			/* Retrieve video */
-			if ((audio_video_enable & 1) && !skip_frame) {
-				const Graphics::Surface &screen = LIBRETRO_G_SYSTEM->getScreen();
-				video_cb(screen.getPixels(), screen.w, screen.h, screen.pitch);
-			}
-			current_frame++;
+		if (retro_emu_thread_exited()) {
+			exit_to_frontend();
+			return;
+		}
+
+		/* Retrieve audio */
+		if (audio_video_enable & 2)
+			audio_run();
 
-		} while (LIBRETRO_G_SYSTEM->getThreadSwitchCaller() & THREAD_SWITCH_UPDATE);
+		/* Retrieve video */
+		if ((audio_video_enable & 1) && !skip_frame) {
+			const Graphics::Surface &screen = LIBRETRO_G_SYSTEM->getScreen();
+			video_cb(screen.getPixels(), screen.w, screen.h, screen.pitch);
+		}
+		current_frame++;
 
 		poll_cb();
 		LIBRETRO_G_SYSTEM->processInputs();


Commit: fc097c3dbf06688360feffa09a9f7958f1b66167
    https://github.com/scummvm/scummvm/commit/fc097c3dbf06688360feffa09a9f7958f1b66167
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-02-05T23:21:01+01:00

Commit Message:
LIBRETRO: add setLibretroDir

Changed paths:
    backends/platform/libretro/include/libretro-os.h
    backends/platform/libretro/src/libretro-os-base.cpp


diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index b6d44b8ebf2..3ab1b30601e 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -113,6 +113,7 @@ public:
 	void quit() override {}
 private:
 	bool checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory = true);
+	void setLibretroDir(const char * path; Common::String &var);
 
 	/* Graphics */
 public:
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 4adbade369a..448aabb423f 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -41,13 +41,8 @@
 OSystem_libretro::OSystem_libretro() : _mousePaletteEnabled(false), _mouseVisible(false), _mouseX(0), _mouseY(0), _mouseXAcc(0.0), _mouseYAcc(0.0), _mouseHotspotX(0), _mouseHotspotY(0), _dpadXAcc(0.0), _dpadYAcc(0.0), _dpadXVel(0.0f), _dpadYVel(0.0f), _mouseKeyColor(0), _mouseDontScale(false), _mixer(0), _startTime(0), _threadSwitchCaller(0), _cursorStatus(0) {
 	_fsFactory = new FS_SYSTEM_FACTORY();
 
-	s_systemDir = retro_get_system_dir();
-	if (s_systemDir.empty() || ! LibRetroFilesystemNode(s_systemDir).isDirectory())
-		s_systemDir.clear();
-
-	s_saveDir = retro_get_save_dir();
-	if (s_saveDir.empty() || ! LibRetroFilesystemNode(s_saveDir).isDirectory())
-		s_saveDir.clear();
+	setLibretroDir(retro_get_system_dir(), s_systemDir);
+	setLibretroDir(retro_get_save_dir(), s_saveDir);
 
 	memset(_mouseButtons, 0, sizeof(_mouseButtons));
 
@@ -182,3 +177,10 @@ bool OSystem_libretro::checkPathSetting(const char *setting, Common::String cons
 			ConfMan.set(setting, defaultPath);
 	return true;
 }
+
+void OSystem_libretro::setLibretroDir(const char * path; Common::String &var) {
+	var = Common::String(path ? path : "");
+	if (! LibRetroFilesystemNode(var).isDirectory())
+		var.clear();
+	return;
+}


Commit: 2927be02805bd7de9ac6900a1804f768a4f254c4
    https://github.com/scummvm/scummvm/commit/2927be02805bd7de9ac6900a1804f768a4f254c4
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-02-05T23:21:23+01:00

Commit Message:
LIBRETRO: add retroarch playlist path retrieving

Changed paths:
    backends/platform/libretro/include/libretro-core.h
    backends/platform/libretro/include/libretro-defs.h
    backends/platform/libretro/include/libretro-os.h
    backends/platform/libretro/src/libretro-core.cpp
    backends/platform/libretro/src/libretro-os-base.cpp


diff --git a/backends/platform/libretro/include/libretro-core.h b/backends/platform/libretro/include/libretro-core.h
index ef48cbe209b..c3ec8f9ef09 100644
--- a/backends/platform/libretro/include/libretro-core.h
+++ b/backends/platform/libretro/include/libretro-core.h
@@ -30,6 +30,7 @@ int retro_get_input_device(void);
 const char * retro_get_core_dir(void);
 const char * retro_get_system_dir(void);
 const char * retro_get_save_dir(void);
+const char * retro_get_playlist_dir(void);
 
 bool retro_setting_get_timing_inaccuracies_enabled(void);
 float retro_setting_get_frame_rate(void);
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index b9698df8540..dafd3e56a58 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -26,6 +26,12 @@
 // System analog stick range is -0x8000 to 0x8000
 #define ANALOG_RANGE 0x8000
 
+/* TODO: remove the following definition when libretro-common
+will be updated to include it */
+#ifndef RETRO_ENVIRONMENT_GET_PLAYLIST_DIRECTORY
+#define RETRO_ENVIRONMENT_GET_PLAYLIST_DIRECTORY 79
+#endif
+
 #define DEFAULT_SAMPLE_RATE     	48000
 #define DEFAULT_REFRESH_RATE    	60
 #define FRAMESKIP_MAX           	DEFAULT_REFRESH_RATE / 2
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index 3ab1b30601e..32c05607c95 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -81,6 +81,7 @@ private:
 	uint8 _cursorStatus;
 	Common::String s_systemDir;
 	Common::String s_saveDir;
+	Common::String s_playlistDir;
 	static Common::List<Common::Event> _events;
 
 public:
@@ -113,7 +114,7 @@ public:
 	void quit() override {}
 private:
 	bool checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory = true);
-	void setLibretroDir(const char * path; Common::String &var);
+	void setLibretroDir(const char * path, Common::String &var);
 
 	/* Graphics */
 public:
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index 74569ad1198..5645bfd178d 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -784,6 +784,14 @@ const char *retro_get_save_dir(void) {
 	return savedir;
 }
 
+const char *retro_get_playlist_dir(void) {
+	const char *playlistdir = NULL;
+
+	environ_cb(RETRO_ENVIRONMENT_GET_PLAYLIST_DIRECTORY, &playlistdir);
+
+	return playlistdir;
+}
+
 void retro_init(void) {
 	struct retro_log_callback log;
 	if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 448aabb423f..b774ab6b45b 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -43,6 +43,7 @@ OSystem_libretro::OSystem_libretro() : _mousePaletteEnabled(false), _mouseVisibl
 
 	setLibretroDir(retro_get_system_dir(), s_systemDir);
 	setLibretroDir(retro_get_save_dir(), s_saveDir);
+	setLibretroDir(retro_get_playlist_dir(), s_playlistDir);
 
 	memset(_mouseButtons, 0, sizeof(_mouseButtons));
 
@@ -92,7 +93,7 @@ void OSystem_libretro::initBackend() {
 		retro_osd_notification("ScummVM extra folder not found. Some engines/features (e.g. Virtual Keyboard) will not work without relevant datafiles.");
 	checkPathSetting("soundfont", s_soundfontPath, false);
 	checkPathSetting("browser_lastpath", s_homeDir);
-	checkPathSetting("libretro_playlist_path", s_homeDir);
+	checkPathSetting("libretro_playlist_path", s_playlistDir.empty() ? s_homeDir : s_playlistDir);
 
 	//Check other settings
 	if (! ConfMan.hasKey("libretro_playlist_version"))
@@ -178,9 +179,10 @@ bool OSystem_libretro::checkPathSetting(const char *setting, Common::String cons
 	return true;
 }
 
-void OSystem_libretro::setLibretroDir(const char * path; Common::String &var) {
+void OSystem_libretro::setLibretroDir(const char * path, Common::String &var) {
 	var = Common::String(path ? path : "");
-	if (! LibRetroFilesystemNode(var).isDirectory())
-		var.clear();
+	if (! var.empty())
+		if (! LibRetroFilesystemNode(var).isDirectory())
+			var.clear();
 	return;
 }




More information about the Scummvm-git-logs mailing list