Add option to prevent rewinding to the beginning of a track to prevent
loosing the current resume position.
---
apps/cuesheet.c | 14 +++++++++++---
apps/gui/wps.c | 8 +++++++-
apps/lang/english.lang | 42 ++++++++++++++++++++++++++++++++++++++++++
apps/menus/settings_menu.c | 5 ++++-
apps/metadata.c | 8 ++++++++
apps/metadata.h | 1 +
apps/settings.h | 6 ++++++
apps/settings_list.c | 6 ++++++
8 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index a6831fa..814c814 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -319,7 +319,14 @@ bool display_cuesheet_content(char* filename)
bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_pos)
{
int track = cue_find_current_track(cue, curr_pos);
-
+ bool prevent_skipback = false;
+
+#ifdef HAVE_TAGCACHE
+ /* Protect resume position by disallowing skipback to 00:00 of
+ current track? */
+ prevent_skipback = disallow_skipback(audio_current_track());
+#endif
+
if (direction >= 0 && track == cue->track_count - 1)
{
/* we want to get out of the cuesheet */
@@ -334,8 +341,9 @@ bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_
to previous cuesheet segment. If skipping backward after
DEFAULT_SKIP_TRESH seconds have elapsed, skip to the start of the
current cuesheet segment */
- if (direction == 1 ||
- ((curr_pos - cue->tracks[track].offset) < DEFAULT_SKIP_TRESH))
+ if (direction == 1
+ || ((curr_pos - cue->tracks[track].offset) < DEFAULT_SKIP_TRESH)
+ || prevent_skipback)
{
track += direction;
}
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 7d633ad..abfd366 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -465,7 +465,13 @@ static void change_dir(int direction)
static void prev_track(unsigned long skip_thresh)
{
struct wps_state *state = skin_get_global_state();
- if (state->id3->elapsed < skip_thresh)
+ bool prevent_skipback = false;
+
+#ifdef HAVE_TAGCACHE
+ prevent_skipback = disallow_skipback(state->id3);
+#endif
+
+ if (state->id3->elapsed < skip_thresh || prevent_skipback)
{
audio_prev();
return;
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index e932a54..4071c79 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -12821,3 +12821,45 @@
*: "Genre tag substrings (comma-separated)"
+
+ id: LANG_AUTORESUME_SKIPBACK
+ desc: Skipback settings menu to enable/disable resume
+ user: core
+
+ *: "Allow skip back to intro"
+
+
+ *: "Allow skip back to intro"
+
+
+ *: "Allow skip back to intro"
+
+
+
+ id: LANG_AUTORESUME_SKIPBACK_ALWAYS
+ desc: Skipback settings menu to enable/disable resume
+ user: core
+
+ *: "Always (may loose resume position)"
+
+
+ *: "Always (may loose resume position)"
+
+
+ *: "Always. May loose resume position"
+
+
+
+ id: LANG_AUTORESUME_SKIPBACK_NONRESUME
+ desc: Skipback settings menu to enable/disable resume
+ user: core
+
+ *: "Non-resumable tracks only"
+
+
+ *: "Non-resumable tracks only"
+
+
+ *: "Non-resumable tracks only"
+
+
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index b783155..5bb3191 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -379,6 +379,8 @@ static void edit_name_buf(char *textbuf)
MENUITEM_SETTING(autoresume_enable, &global_settings.autoresume_enable, NULL);
MENUITEM_SETTING(autoresume_automatic, &global_settings.autoresume_automatic,
NULL);
+MENUITEM_SETTING(autoresume_skipback, &global_settings.autoresume_skipback,
+ NULL);
MENUITEM_SETTING(autoresume_custom, &global_settings.autoresume_custom, NULL);
MENUITEM_FUNCTION(autoresume_pathsub, MENU_FUNC_USEPARAM,
@@ -396,7 +398,8 @@ MAKE_MENU(autoresume_custom_menu, ID2P(LANG_AUTORESUME_CUSTOM_MENU),
MAKE_MENU(autoresume_menu, ID2P(LANG_AUTORESUME),
0, Icon_NOICON,
- &autoresume_enable, &autoresume_custom_menu, &autoresume_automatic);
+ &autoresume_enable, &autoresume_custom_menu, &autoresume_automatic,
+ &autoresume_skipback);
#endif /* HAVE_TAGCACHE */
/* AUTORESUME MENU */
diff --git a/apps/metadata.c b/apps/metadata.c
index 9f61783..e355343 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -474,4 +474,12 @@ bool autoresumable(struct mp3entry *id3)
return is_resumable;
}
+bool disallow_skipback(struct mp3entry *id3)
+{
+ return global_settings.autoresume_enable
+ && global_settings.autoresume_skipback != AUTORESUME_SKIPBACK_ALWAYS
+ && (global_settings.autoresume_skipback == AUTORESUME_SKIPBACK_NEVER
+ || autoresumable(id3));
+}
+
#endif /* HAVE_TAGCACHE */
diff --git a/apps/metadata.h b/apps/metadata.h
index 13310fc..d4f5cd3 100644
--- a/apps/metadata.h
+++ b/apps/metadata.h
@@ -288,6 +288,7 @@ void strip_tags(int handle_id);
#ifdef HAVE_TAGCACHE
bool autoresumable(struct mp3entry *id3);
+bool disallow_skipback(struct mp3entry *id3);
#endif
#endif
diff --git a/apps/settings.h b/apps/settings.h
index af6398f..2b5d37b 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -125,6 +125,10 @@ enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL };
/* scrollbar visibility/position */
enum { SCROLLBAR_OFF = 0, SCROLLBAR_LEFT, SCROLLBAR_RIGHT };
+/* autoresume settings */
+enum { AUTORESUME_SKIPBACK_ALWAYS = 0, AUTORESUME_SKIPBACK_NONRESUME,
+ AUTORESUME_SKIPBACK_NEVER };
+
/* Alarm settings */
#ifdef HAVE_RTC_ALARM
enum { ALARM_START_WPS = 0,
@@ -582,6 +586,8 @@ struct user_settings
bool autoresume_custom; /* resume only for files matching file/tag below? */
unsigned char autoresume_pathsub[MAX_PATHNAME+1]; /* comma-separated list */
unsigned char autoresume_tagsub[MAX_PATHNAME+1]; /* dito */
+ int autoresume_skipback; /* skipback for resumable tracks? 0=do skip back,
+ 1=only for nonresumable tracks, 2=always */
bool runtimedb; /* runtime database active? */
#endif /* HAVE_TAGCACHE */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 01d1cde..12f06f4 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1300,6 +1300,12 @@ const struct settings_list settings[] = {
"podcast,audiobook", NULL, NULL),
TEXT_SETTING(0, autoresume_tagsub, "autoresume tag substring",
"podcast,audiobook", NULL, NULL),
+ CHOICE_SETTING(0, autoresume_skipback, LANG_AUTORESUME_SKIPBACK,
+ AUTORESUME_SKIPBACK_NONRESUME,
+ "autoresume skipback", "always,nonresumable,never", NULL, 3,
+ ID2P(LANG_AUTORESUME_SKIPBACK_ALWAYS),
+ ID2P(LANG_AUTORESUME_SKIPBACK_NONRESUME),
+ ID2P(LANG_NEVER)),
OFFON_SETTING(0, runtimedb, LANG_RUNTIMEDB_ACTIVE, false,
"gather runtime data", NULL),
--
1.7.1