From a987b67801e39b3ad5d349253ef53070b7d3272b Mon Sep 17 00:00:00 2001
From: kub <derkub@gmail.com>
Date: Thu, 31 Mar 2022 22:02:48 +0000
Subject: [PATCH] sound, fix config save/load for native quality mode

---
 platform/common/config_file.c | 9 +++++++--
 platform/common/menu_pico.c   | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/platform/common/config_file.c b/platform/common/config_file.c
index 1c4b00cf..5c2311eb 100644
--- a/platform/common/config_file.c
+++ b/platform/common/config_file.c
@@ -275,8 +275,13 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
 		case MA_OPT_SOUND_QUALITY:
 			if (strcasecmp(var, "Sound Quality") != 0) return 0;
 			PicoIn.sndRate = strtoul(val, &tmp, 10);
-			if (PicoIn.sndRate < 8000 || PicoIn.sndRate > 53267)
-				PicoIn.sndRate = 22050;
+			if (PicoIn.sndRate < 8000 || PicoIn.sndRate > 53267) {
+				if  (strncasecmp(tmp, "native", 6) == 0) {
+					tmp += 6;
+					PicoIn.sndRate = 53000;
+				} else
+					PicoIn.sndRate = 22050;
+			}
 			if (*tmp == 'H' || *tmp == 'h') tmp++;
 			if (*tmp == 'Z' || *tmp == 'z') tmp++;
 			while (*tmp == ' ') tmp++;
diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c
index fc9e769e..ea0fbdcf 100644
--- a/platform/common/menu_pico.c
+++ b/platform/common/menu_pico.c
@@ -631,7 +631,7 @@ static const char *mgn_opt_sound(int id, int *offs)
 	*offs = -8;
 	str2 = (PicoIn.opt & POPT_EN_STEREO) ? "stereo" : "mono";
 	if (PicoIn.sndRate > 52000)
-		sprintf(static_buff, "native %s\n", str2);
+		sprintf(static_buff, "native %s", str2);
 	else	sprintf(static_buff, "%5iHz %s", PicoIn.sndRate, str2);
 	return static_buff;
 }
-- 
2.39.5