From b40c5556425c3a9a3cc6601b051696dea7936035 Mon Sep 17 00:00:00 2001 From: markun Date: Sat, 28 Jun 2008 17:55:53 +0000 Subject: [PATCH] implement smooth seeking acceleration for audio playback and mpegplayer git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17843 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 14 ++------ apps/lang/english.lang | 68 ++++++++++++++++++++++++++++++++++++ apps/plugins/mpegplayer/mpegplayer.c | 10 ++---- apps/settings_list.c | 6 ++-- 4 files changed, 78 insertions(+), 20 deletions(-) diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index b53d68d6b..3fd77a221 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -196,10 +196,10 @@ bool ffwd_rew(int button) unsigned int max_step = 0; /* maximum ff/rewind step */ int ff_rewind_count = 0; /* current ff/rewind count (in ticks) */ int direction = -1; /* forward=1 or backward=-1 */ - long accel_tick = 0; /* next time at which to bump the step size */ bool exit = false; bool usb = false; int i = 0; + const long ff_rw_accel = (global_settings.ff_rewind_accel + 3); if (button == ACTION_NONE) { @@ -237,13 +237,8 @@ bool ffwd_rew(int button) ff_rewind_count += step * direction; - if (global_settings.ff_rewind_accel != 0 && - current_tick >= accel_tick) - { - step *= 2; - accel_tick = current_tick + - global_settings.ff_rewind_accel*HZ; - } + /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */ + step += step >> ff_rw_accel; } else { @@ -268,9 +263,6 @@ bool ffwd_rew(int button) wps_state.ff_rewind = true; step = 1000 * global_settings.ff_rewind_min_step; - - accel_tick = current_tick + - global_settings.ff_rewind_accel*HZ; } else break; diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 757fa58bb..02ecdd5ad 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -11750,3 +11750,71 @@ gigabeatf: "High" + + id: LANG_VERY_SLOW + desc: in settings_menu + user: + + *: none + gigabeatf: "Very slow" + + + *: none + gigabeatf: "Very slow" + + + *: none + gigabeatf: "Very slow" + + + + id: LANG_SLOW + desc: in settings_menu + user: + + *: none + gigabeatf: "Slow" + + + *: none + gigabeatf: "Slow" + + + *: none + gigabeatf: "Slow" + + + + id: LANG_VERY_FAST + desc: in settings_menu + user: + + *: none + gigabeatf: "Very fast" + + + *: none + gigabeatf: "Very fast" + + + *: none + gigabeatf: "Very fast" + + + + id: LANG_FAST + desc: in settings_menu + user: + + *: none + gigabeatf: "Fast" + + + *: none + gigabeatf: "Fast" + + + *: none + gigabeatf: "Fast" + + diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 6d6aa2078..5b478d0bf 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -1109,8 +1109,7 @@ static int wvs_get_status(void) static uint32_t wvs_ff_rw(int btn, unsigned refresh) { unsigned int step = TS_SECOND*rb->global_settings->ff_rewind_min_step; - const long ff_rw_accel = rb->global_settings->ff_rewind_accel; - long accel_tick = *rb->current_tick + ff_rw_accel*HZ; + const long ff_rw_accel = (rb->global_settings->ff_rewind_accel + 3); uint32_t start; uint32_t time = stream_get_seek_time(&start); const uint32_t duration = stream_get_duration(); @@ -1145,7 +1144,6 @@ static uint32_t wvs_ff_rw(int btn, unsigned refresh) while (1) { - long tick = *rb->current_tick; stream_keep_disk_active(); switch (btn) @@ -1199,10 +1197,8 @@ static uint32_t wvs_ff_rw(int btn, unsigned refresh) ff_rw_count += step; - if (ff_rw_accel != 0 && TIME_AFTER(tick, accel_tick)) { - step *= 2; - accel_tick = tick + ff_rw_accel*HZ; - } + /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */ + step += step >> ff_rw_accel; if (wvs.status == WVS_STATUS_FF) { if (duration - time <= ff_rw_count) diff --git a/apps/settings_list.c b/apps/settings_list.c index 6007570bf..1e9bd185b 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -666,8 +666,10 @@ const struct settings_list settings[] = { TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, ff_rewind_min_step, LANG_FFRW_STEP, 1, "scan min step", NULL, UNIT_SEC, NULL, NULL, NULL, 14, 1,2,3,4,5,6,8,10,15,20,25,30,45,60), - INT_SETTING(0, ff_rewind_accel, LANG_FFRW_ACCEL, 3, "scan accel", UNIT_SEC, - 16, 0, -1, scanaccel_formatter, getlang_unit_0_is_off, NULL), + CHOICE_SETTING(0, ff_rewind_accel, LANG_FFRW_ACCEL, 2, + "seek accel", "very fast,fast,normal,slow,very slow", NULL, 5, + ID2P(LANG_VERY_FAST), ID2P(LANG_FAST), ID2P(LANG_NORMAL), + ID2P(LANG_SLOW) , ID2P(LANG_VERY_SLOW)), #if (CONFIG_CODEC == SWCODEC) && !defined(HAVE_FLASH_STORAGE) STRINGCHOICE_SETTING(0, buffer_margin, LANG_MP3BUFFER_MARGIN, 0,"antiskip", "5s,15s,30s,1min,2min,3min,5min,10min", NULL, 8, -- 2.11.4.GIT