diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 1cd137ae3c..64d28422c1 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -13511,3 +13511,20 @@ *: none + + id: LANG_RESUME_REWIND + desc: in playback settings menu + user: core + + *: none + swcodec: "Rewind Before Resume" + + + *: none + swcodec: "Rewind Before Resume" + + + *: none + swcodec: "Rewind before resume" + + diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c index 5be7a8ca43..f0ebd1eed1 100644 --- a/apps/menus/playback_menu.c +++ b/apps/menus/playback_menu.c @@ -177,6 +177,7 @@ MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON, MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL); MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL); +MENUITEM_SETTING(resume_rewind, &global_settings.resume_rewind, NULL); MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0, Icon_Playback_menu, @@ -203,6 +204,10 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0, ,&unplug_menu #endif ,&skip_length, &prevent_skip, + +#if CONFIG_CODEC == SWCODEC + &resume_rewind, +#endif ); static int playback_callback(int action,const struct menu_item_ex *this_item) diff --git a/apps/playback.c b/apps/playback.c index dc854cbb24..ebe4932ae0 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1344,6 +1344,17 @@ static void audio_finish_load_track(void) track_id3->elapsed = 0; offset = track_id3->offset; + size_t resume_rewind = (global_settings.resume_rewind * + track_id3->bitrate * 1000) / 8; + + if (offset < resume_rewind) + { + offset = 0; + } + else + { + offset -= resume_rewind; + } enum data_type type = TYPE_PACKET_AUDIO; @@ -1375,6 +1386,8 @@ static void audio_finish_load_track(void) break; } + track_id3->offset = offset; + logf("load track: %s", track_id3->path); if (file_offset > AUDIO_REBUFFER_GUESS_SIZE) diff --git a/apps/settings.h b/apps/settings.h index 723dfba176..fc44caae43 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -823,6 +823,10 @@ struct user_settings int hotkey_tree; #endif +#if CONFIG_CODEC == SWCODEC + /* When resuming playback (after a stop), rewind this number of seconds */ + int resume_rewind; +#endif }; /** global variables **/ diff --git a/apps/settings_list.c b/apps/settings_list.c index d52a82f8cc..044f9e8066 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1683,6 +1683,12 @@ const struct settings_list settings[] = { #endif ID2P(LANG_ONPLAY_OPEN_WITH), ID2P(LANG_DELETE), ID2P(LANG_INSERT)), #endif + +#if CONFIG_CODEC == SWCODEC + INT_SETTING(0, resume_rewind, LANG_RESUME_REWIND, 0, + "resume rewind", UNIT_SEC, 0, 60, 5, + NULL, NULL, NULL), +#endif }; const int nb_settings = sizeof(settings)/sizeof(*settings); diff --git a/manual/configure_rockbox/playback_options.tex b/manual/configure_rockbox/playback_options.tex index da6f6efa9b..7d9c8baa09 100644 --- a/manual/configure_rockbox/playback_options.tex +++ b/manual/configure_rockbox/playback_options.tex @@ -288,3 +288,14 @@ you to configure settings related to audio playback. if a track ends, which can be achieved by combining this option with \setting{Repeat} set to \setting{One} +\opt{swcodec}{ + \section{Rewind Before Resume}\index{Rewind Before Resume} + When resuming a track or a bookmark, a short rewind can be done before the + playback is started. This can be useful when listening to speech material, + to help remember what was being said just before playback was stopped. + The size of the rewind can be set to various values between 0 (off) and + 60 seconds. + \note{The rewind is not done when resuming a paused track.} + \note{The actual rewind distance may differ a little from the requested + value, depending on the file in question.} +}%\opt{swcodec}