From 7eb27113c58d95c6644f439406ce74208cfc26b6 Mon Sep 17 00:00:00 2001 From: Eric Linenberg Date: Wed, 4 Sep 2002 03:38:37 +0000 Subject: Nate Nystrom's FF/RW min speed patch git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2161 a1c6a512-1295-4272-9138-f99709370657 --- apps/wps.c | 120 +++++++++++++++++++++---------------------------------------- 1 file changed, 41 insertions(+), 79 deletions(-) (limited to 'apps/wps.c') diff --git a/apps/wps.c b/apps/wps.c index 1bd2c6405d..0c10a881c3 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -44,7 +44,6 @@ #include "ajf.h" #endif -#define FF_REWIND_MIN_STEP 1000 /* minimum ff/rewind step is 1 second */ #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ /* 3% of 30min file == 54s step size */ @@ -288,26 +287,37 @@ int player_id3_show(void) static bool ffwd_rew(int button) { - unsigned int ff_rewind_step = 0; /* current rewind step size */ - unsigned int ff_rewind_max_step = 0; /* max rewind step size */ - int ff_rewind_count = 0; - long ff_rewind_accel_tick = 0; /* next time to bump ff/rewind step size */ + static int ff_rew_steps[] = { + 1000, 2000, 3000, 4000, + 5000, 6000, 8000, 10000, + 15000, 20000, 25000, 30000, + 45000, 60000 + }; + + unsigned int step = 0; /* current ff/rewind step */ + 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; while (!exit) { switch ( button ) { case BUTTON_LEFT | BUTTON_REPEAT: + case BUTTON_RIGHT | BUTTON_REPEAT: if (ff_rewind) { - ff_rewind_count -= ff_rewind_step; + ff_rewind_count += step * direction; + if (global_settings.ff_rewind_accel != 0 && - current_tick >= ff_rewind_accel_tick) + current_tick >= accel_tick) { - ff_rewind_step *= 2; - if (ff_rewind_step > ff_rewind_max_step) - ff_rewind_step = ff_rewind_max_step; - ff_rewind_accel_tick = current_tick + + step *= 2; + if (step > max_step) + step = max_step; + + accel_tick = current_tick + global_settings.ff_rewind_accel*HZ; } } @@ -320,96 +330,48 @@ static bool ffwd_rew(int button) #ifdef HAVE_PLAYER_KEYPAD lcd_stop_scroll(); #endif + direction = (button & BUTTON_RIGHT) ? 1 : -1; + + if (direction > 0) + status_set_playmode(STATUS_FASTFORWARD); + else status_set_playmode(STATUS_FASTBACKWARD); + ff_rewind = true; - ff_rewind_max_step = - id3->length * FF_REWIND_MAX_PERCENT / 100; - ff_rewind_step = FF_REWIND_MIN_STEP; - if (ff_rewind_step > ff_rewind_max_step) - ff_rewind_step = ff_rewind_max_step; - ff_rewind_count = -ff_rewind_step; - ff_rewind_accel_tick = current_tick + - global_settings.ff_rewind_accel*HZ; - } - else - break; - } - if ((int)(id3->elapsed + ff_rewind_count) < 0) - ff_rewind_count = -id3->elapsed; + step = ff_rew_steps[global_settings.ff_rewind_min_step]; - if(wps_time_countup == false) - wps_refresh(id3, -ff_rewind_count, false); - else - wps_refresh(id3, ff_rewind_count, false); - break; + max_step = id3->length * FF_REWIND_MAX_PERCENT / 100; - case BUTTON_RIGHT | BUTTON_REPEAT: - if (ff_rewind) - { - ff_rewind_count += ff_rewind_step; - if (global_settings.ff_rewind_accel != 0 && - current_tick >= ff_rewind_accel_tick) - { - ff_rewind_step *= 2; - if (ff_rewind_step > ff_rewind_max_step) - ff_rewind_step = ff_rewind_max_step; - ff_rewind_accel_tick = current_tick + - global_settings.ff_rewind_accel*HZ; - } - } - else - { - if ( mpeg_is_playing() && id3 && id3->length ) - { - if (!paused) - mpeg_pause(); -#ifdef HAVE_PLAYER_KEYPAD - lcd_stop_scroll(); -#endif - status_set_playmode(STATUS_FASTFORWARD); - ff_rewind = true; - ff_rewind_max_step = - id3->length * FF_REWIND_MAX_PERCENT / 100; - ff_rewind_step = FF_REWIND_MIN_STEP; - if (ff_rewind_step > ff_rewind_max_step) - ff_rewind_step = ff_rewind_max_step; - ff_rewind_count = ff_rewind_step; - ff_rewind_accel_tick = current_tick + + if (step > max_step) + step = max_step; + + ff_rewind_count = step * direction; + accel_tick = current_tick + global_settings.ff_rewind_accel*HZ; } else break; } + if (direction > 0) { if ((id3->elapsed + ff_rewind_count) > id3->length) ff_rewind_count = id3->length - id3->elapsed; + } + else { + if ((int)(id3->elapsed + ff_rewind_count) < 0) + ff_rewind_count = -id3->elapsed; + } if(wps_time_countup == false) wps_refresh(id3, -ff_rewind_count, false); else wps_refresh(id3, ff_rewind_count, false); - break; - case BUTTON_LEFT | BUTTON_REL: - /* rewind */ - mpeg_ff_rewind(ff_rewind_count); - ff_rewind_count = 0; - ff_rewind = false; - if (paused) - status_set_playmode(STATUS_PAUSE); - else { - mpeg_resume(); - status_set_playmode(STATUS_PLAY); - } -#ifdef HAVE_LCD_CHARCELLS - wps_display(id3); -#endif - exit = true; break; + case BUTTON_LEFT | BUTTON_REL: case BUTTON_RIGHT | BUTTON_REL: - /* fast forward */ mpeg_ff_rewind(ff_rewind_count); ff_rewind_count = 0; ff_rewind = false; -- cgit v1.2.3