mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
[BugFix] pitch screen load config fd wasn't closed
check file_exist(PITCH_CFG_FILE) close fd when finished If you already have a setting saved and you reenter the pitch plugin with differing pitch settings you will be asked to restore your default settings update manual entry to be a clearer Change-Id: Iaaaf08983a355f9848412d1c6b0bba25d6ea8f39
This commit is contained in:
parent
a8f6ddc5ed
commit
c4ceea40bf
4 changed files with 49 additions and 31 deletions
|
@ -197,26 +197,29 @@ void INIT_ATTR audio_init(void)
|
||||||
char* name;
|
char* name;
|
||||||
char* value;
|
char* value;
|
||||||
int32_t num;
|
int32_t num;
|
||||||
|
if (file_exists(PITCH_CFG_FILE))
|
||||||
fd = open_utf8(PITCH_CFG_FILE, O_RDONLY);
|
|
||||||
if (fd >= 0)
|
|
||||||
{
|
{
|
||||||
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))
|
while (read_line(fd, line, sizeof line) > 0)
|
||||||
continue;
|
|
||||||
if (strcasecmp(name, "pitch") == 0)
|
|
||||||
{
|
{
|
||||||
num = atoi(value);
|
if (!settings_parseline(line, &name, &value))
|
||||||
if (num != PITCH_SPEED_100)
|
continue;
|
||||||
sound_set_pitch(num);
|
if (strcasecmp(name, "pitch") == 0)
|
||||||
}
|
{
|
||||||
if (strcasecmp(name, "stretch") == 0)
|
num = atoi(value);
|
||||||
{
|
if (num != PITCH_SPEED_100)
|
||||||
num = atoi(value);
|
sound_set_pitch(num);
|
||||||
if (num != PITCH_SPEED_100)
|
}
|
||||||
dsp_set_timestretch(num);
|
if (strcasecmp(name, "stretch") == 0)
|
||||||
|
{
|
||||||
|
num = atoi(value);
|
||||||
|
if (num != PITCH_SPEED_100)
|
||||||
|
dsp_set_timestretch(num);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,13 @@
|
||||||
|
|
||||||
static void get_cfg_filename(char* buf, int buf_len, const char* filename)
|
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
|
#ifdef APPLICATION
|
||||||
rb->snprintf(buf, buf_len, PLUGIN_DATA_DIR "/%s", filename);
|
rb->snprintf(buf, buf_len, PLUGIN_DATA_DIR "/%s", filename);
|
||||||
#else
|
#else
|
||||||
|
@ -49,14 +56,8 @@ int configfile_save(const char *filename, const struct configdata *cfg,
|
||||||
int i;
|
int i;
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
|
get_cfg_filename(buf, MAX_PATH, filename);
|
||||||
if (rb->strncmp(filename, ROCKBOX_DIR, sizeof(ROCKBOX_DIR) - 1) != 0)
|
fd = rb->creat(buf, 0666);
|
||||||
{
|
|
||||||
get_cfg_filename(buf, MAX_PATH, filename);
|
|
||||||
fd = rb->creat(buf, 0666);
|
|
||||||
}
|
|
||||||
else /* allow saving to the rockbox directory */
|
|
||||||
fd = rb->creat(filename, 0666);
|
|
||||||
|
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return fd*10 - 1;
|
return fd*10 - 1;
|
||||||
|
|
|
@ -1241,6 +1241,21 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
rb->settings_save();
|
rb->settings_save();
|
||||||
}
|
}
|
||||||
gui = true;
|
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
|
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 (pitch_vars.pitch != cur.pitch || pitch_vars.stretch != cur.stretch)
|
||||||
{
|
{
|
||||||
if (configfile_save(CFG_FILE, pitchcfg, 2, CFG_VER) >= 0)
|
if (configfile_save(CFG_FILE, pitchcfg, 2, CFG_VER) < 0)
|
||||||
rb->splash(HZ, ID2P(LANG_SETTINGS_SAVED));
|
|
||||||
else
|
|
||||||
rb->splash(HZ, ID2P(LANG_ERROR_WRITING_CONFIG));
|
rb->splash(HZ, ID2P(LANG_ERROR_WRITING_CONFIG));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,8 +288,9 @@ This may even be the whole track.
|
||||||
|
|
||||||
The value of the rate, pitch and speed
|
The value of the rate, pitch and speed
|
||||||
is persistent, i.e. when the \dap\ is turned on it will
|
is persistent, i.e. when the \dap\ is turned on it will
|
||||||
always be set to your last value. Selecting \setting{Pitch} again
|
always be set to your last value set by \setting{Pitch Screen}.
|
||||||
will now display a menu with \setting{Pitch} and \setting{Reset Setting}.
|
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.
|
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
|
However the rate, pitch and speed information will be stored in any bookmarks
|
||||||
you may create (see \reference{ref:Bookmarkconfigactual})
|
you may create (see \reference{ref:Bookmarkconfigactual})
|
||||||
|
@ -297,8 +298,8 @@ This may even be the whole track.
|
||||||
playing back those bookmarks.
|
playing back those bookmarks.
|
||||||
|
|
||||||
\note{ If a bookmark has changed pitch, settings will remain till
|
\note{ If a bookmark has changed pitch, settings will remain till
|
||||||
the \dap{} is restarted and your (possibly different or default)
|
changed again or the \dap{} is restarted and your (default) settings will then be
|
||||||
persistent settings will then be restored.}
|
restored}
|
||||||
|
|
||||||
\begin{btnmap}
|
\begin{btnmap}
|
||||||
\ActionPsToggleMode
|
\ActionPsToggleMode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue