FS#11931 part 2: Allow a short rewind when playback is paused. Patch
by John Morris.
This patch adds an option to rewind the current track by a few seconds
when it is paused. This is useful for audiobooks and podcasts to allow
the listener to recall where the track was left off.
The patch subsumes the existing rewind-on-headphone-unplug feature and
extends it to all invocations of pause: play/pause button (or touch
area), headphone removal, and power-supply unplug in car-adapter
mode. It also subsumes FS#9448 (rewind on fade).
---
apps/gui/wps.c | 9 +++++++++
apps/lang/english.lang | 25 ++++++++++++++++++-------
apps/menus/playback_menu.c | 5 +++--
apps/misc.c | 10 ----------
apps/settings.h | 2 +-
apps/settings_list.c | 6 +++---
6 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index cf6ec2d..4f29501 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -126,6 +126,15 @@ void pause_action(bool may_fade, bool updatewps)
fade(false, updatewps);
else
audio_pause();
+
+ if (global_settings.pause_rewind) {
+#if (CONFIG_CODEC == SWCODEC)
+ audio_pre_ff_rewind();
+#endif
+ newpos = audio_current_track()->elapsed
+ - global_settings.pause_rewind * 1000;
+ audio_ff_rewind(newpos > 0 ? newpos : 0);
+ }
}
void unpause_action(bool may_fade, bool updatewps)
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 26a2274..71dee79 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -2069,19 +2069,16 @@
id: LANG_HEADPHONE_UNPLUG_RW
- desc: in pause_phones_menu.
+ desc: deprecated
user: core
- *: none
- headphone_detection: "Duration to Rewind"
+ *: ""
- *: none
- headphone_detection: "Duration to Rewind"
+ *: ""
- *: none
- headphone_detection: "Duration to Rewind"
+ *: ""
@@ -12744,3 +12741,17 @@
*: "In custom directories only"
+
+ id: LANG_PAUSE_REWIND
+ desc: Seconds to rewind when rewind on pause is enabled.
+ user: core
+
+ *: "Rewind on Pause"
+
+
+ *: "Rewind on Pause"
+
+
+ *: "Rewind on Pause"
+
+
diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c
index 4153c1c..1b1a13a 100644
--- a/apps/menus/playback_menu.c
+++ b/apps/menus/playback_menu.c
@@ -173,10 +173,9 @@ MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback);
#ifdef HAVE_HEADPHONE_DETECTION
MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL);
-MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL);
MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL);
MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
- &unplug_mode, &unplug_rw, &unplug_autoresume);
+ &unplug_mode, &unplug_autoresume);
#endif
MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL);
@@ -184,6 +183,7 @@ MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL);
#if CONFIG_CODEC == SWCODEC
MENUITEM_SETTING(resume_rewind, &global_settings.resume_rewind, NULL);
#endif
+MENUITEM_SETTING(pause_rewind, &global_settings.pause_rewind, NULL);
MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
Icon_Playback_menu,
@@ -214,6 +214,7 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
#if CONFIG_CODEC == SWCODEC
&resume_rewind,
#endif
+ &pause_rewind,
);
static int playback_callback(int action,const struct menu_item_ex *this_item)
diff --git a/apps/misc.c b/apps/misc.c
index 2e6f0e1..b027215 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -504,16 +504,6 @@ static void unplug_change(bool inserted)
{
headphone_caused_pause = true;
pause_action(false, false);
-
- if (global_settings.unplug_rw)
- {
- if (audio_current_track()->elapsed >
- (unsigned long)(global_settings.unplug_rw*1000))
- audio_ff_rewind(audio_current_track()->elapsed -
- (global_settings.unplug_rw*1000));
- else
- audio_ff_rewind(0);
- }
}
}
}
diff --git a/apps/settings.h b/apps/settings.h
index 3f49cfc..bed88c8 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -483,9 +483,9 @@ struct user_settings
int touchpad_sensitivity;
#endif
+ int pause_rewind; /* time in s to rewind when pausing */
#ifdef HAVE_HEADPHONE_DETECTION
int unplug_mode; /* pause on headphone unplug */
- int unplug_rw; /* time in s to rewind when pausing */
bool unplug_autoresume; /* disable auto-resume if no phones */
#endif
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 5b9a840..f282b8a 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1537,13 +1537,13 @@ const struct settings_list settings[] = {
"pause on headphone unplug", "off,pause,pause and resume",
NULL, 3, ID2P(LANG_OFF), ID2P(LANG_PAUSE),
ID2P(LANG_HEADPHONE_UNPLUG_RESUME)),
- INT_SETTING(0, unplug_rw, LANG_HEADPHONE_UNPLUG_RW, 0,
- "rewind duration on pause", UNIT_SEC, 0, 15, 1, NULL, NULL,
- NULL),
OFFON_SETTING(0, unplug_autoresume,
LANG_HEADPHONE_UNPLUG_DISABLE_AUTORESUME, false,
"disable autoresume if phones not present",NULL),
#endif
+ INT_SETTING(0, pause_rewind, LANG_PAUSE_REWIND, 0,
+ "rewind duration on pause", UNIT_SEC, 0, 15, 1, NULL, NULL,
+ NULL),
#if CONFIG_TUNER
CHOICE_SETTING(0, fm_region, LANG_FM_REGION, 0,
"fm_region", "eu,us,jp,kr,it,wo", set_radio_region, 6,
--
1.7.1