diff --git a/apps/audio_thread.c b/apps/audio_thread.c index bb380a4eef..867dc696a2 100644 --- a/apps/audio_thread.c +++ b/apps/audio_thread.c @@ -197,26 +197,29 @@ void INIT_ATTR audio_init(void) char* name; char* value; int32_t num; - - fd = open_utf8(PITCH_CFG_FILE, O_RDONLY); - if (fd >= 0) + if (file_exists(PITCH_CFG_FILE)) { - while (read_line(fd, line, sizeof line) > 0) + fd = open_utf8(PITCH_CFG_FILE, O_RDONLY); + if (fd >= 0) { - if (!settings_parseline(line, &name, &value)) - continue; - if (strcasecmp(name, "pitch") == 0) + while (read_line(fd, line, sizeof line) > 0) { - num = atoi(value); - if (num != PITCH_SPEED_100) - sound_set_pitch(num); - } - if (strcasecmp(name, "stretch") == 0) - { - num = atoi(value); - if (num != PITCH_SPEED_100) - dsp_set_timestretch(num); + if (!settings_parseline(line, &name, &value)) + continue; + if (strcasecmp(name, "pitch") == 0) + { + num = atoi(value); + if (num != PITCH_SPEED_100) + sound_set_pitch(num); + } + if (strcasecmp(name, "stretch") == 0) + { + num = atoi(value); + if (num != PITCH_SPEED_100) + dsp_set_timestretch(num); + } } + close(fd); } } #endif diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c index 0bfddc71f6..918a3291ce 100644 --- a/apps/plugins/lib/configfile.c +++ b/apps/plugins/lib/configfile.c @@ -23,6 +23,13 @@ static void get_cfg_filename(char* buf, int buf_len, const char* filename) { + if (rb->strncmp(filename, ROCKBOX_DIR, sizeof(ROCKBOX_DIR) - 1) == 0) + { + /* allow the rockbox directory */ + rb->snprintf(buf, buf_len, "/%s", filename); + return; + } + #ifdef APPLICATION rb->snprintf(buf, buf_len, PLUGIN_DATA_DIR "/%s", filename); #else @@ -49,14 +56,8 @@ int configfile_save(const char *filename, const struct configdata *cfg, int i; char buf[MAX_PATH]; - - if (rb->strncmp(filename, ROCKBOX_DIR, sizeof(ROCKBOX_DIR) - 1) != 0) - { - get_cfg_filename(buf, MAX_PATH, filename); - fd = rb->creat(buf, 0666); - } - else /* allow saving to the rockbox directory */ - fd = rb->creat(filename, 0666); + get_cfg_filename(buf, MAX_PATH, filename); + fd = rb->creat(buf, 0666); if(fd < 0) return fd*10 - 1; diff --git a/apps/plugins/pitch_screen.c b/apps/plugins/pitch_screen.c index 5e5d70fc54..e203ec3990 100644 --- a/apps/plugins/pitch_screen.c +++ b/apps/plugins/pitch_screen.c @@ -1241,6 +1241,21 @@ enum plugin_status plugin_start(const void* parameter) rb->settings_save(); } gui = true; + if (rb->file_exists(CFG_FILE)) + { + if (configfile_load(CFG_FILE, pitchcfg, 2, CFG_VER) >= 0) + { + if (pitch_vars.pitch != cur.pitch || pitch_vars.stretch != cur.stretch) + { + if (rb->yesno_pop(ID2P(LANG_REVERT_TO_DEFAULT_SETTINGS))) + { + rb->sound_set_pitch(pitch_vars.pitch); + rb->dsp_set_timestretch(pitch_vars.stretch); + } + } + } + } + } else { @@ -1294,9 +1309,7 @@ enum plugin_status plugin_start(const void* parameter) if (pitch_vars.pitch != cur.pitch || pitch_vars.stretch != cur.stretch) { - if (configfile_save(CFG_FILE, pitchcfg, 2, CFG_VER) >= 0) - rb->splash(HZ, ID2P(LANG_SETTINGS_SAVED)); - else + if (configfile_save(CFG_FILE, pitchcfg, 2, CFG_VER) < 0) rb->splash(HZ, ID2P(LANG_ERROR_WRITING_CONFIG)); } } diff --git a/manual/rockbox_interface/wps.tex b/manual/rockbox_interface/wps.tex index a81cce753d..35e3d0cd8a 100644 --- a/manual/rockbox_interface/wps.tex +++ b/manual/rockbox_interface/wps.tex @@ -288,8 +288,9 @@ This may even be the whole track. The value of the rate, pitch and speed is persistent, i.e. when the \dap\ is turned on it will - always be set to your last value. Selecting \setting{Pitch} again - will now display a menu with \setting{Pitch} and \setting{Reset Setting}. + always be set to your last value set by \setting{Pitch Screen}. + Selecting \setting{Pitch} again will now display a menu with + \setting{Pitch} and \setting{Reset Setting}. Selecting \setting{Reset Setting} will reset the pitch to 100\% now and at next boot. However the rate, pitch and speed information will be stored in any bookmarks you may create (see \reference{ref:Bookmarkconfigactual}) @@ -297,8 +298,8 @@ This may even be the whole track. playing back those bookmarks. \note{ If a bookmark has changed pitch, settings will remain till - the \dap{} is restarted and your (possibly different or default) - persistent settings will then be restored.} + changed again or the \dap{} is restarted and your (default) settings will then be + restored} \begin{btnmap} \ActionPsToggleMode