diff --git a/apps/settings.c b/apps/settings.c index 6ca733cf37..fa9ba38106 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -68,7 +68,7 @@ offset abs 0x0d 0x21 0x0e 0x22 0x0f 0x23 -0x10 0x24 +0x10 0x24 0x11 0x25 0x12 0x26 <(int) Resume playlist index, or -1 if no playlist resume> 0x16 0x2a <(int) Byte offset into resume file> @@ -269,7 +269,9 @@ int settings_save( void ) config_block[0xf] = (unsigned char)(global_settings.scroll_speed << 3); - config_block[0x10] = (unsigned char)global_settings.ff_rewind_accel; + config_block[0x10] = (unsigned char) + ((global_settings.ff_rewind_min_step & 15) << 4 | + (global_settings.ff_rewind_accel & 15)); config_block[0x11] = (unsigned char)global_settings.avc; config_block[0x1a] = (unsigned char)global_settings.disk_spindown; @@ -358,8 +360,10 @@ void settings_load(void) if (c != 31) global_settings.scroll_speed = c; - if (config_block[0x10] != 0xFF) - global_settings.ff_rewind_accel = config_block[0x10]; + if (config_block[0x10] != 0xFF) { + global_settings.ff_rewind_min_step = (config_block[0x10] >> 4) & 15; + global_settings.ff_rewind_accel = config_block[0x10] & 15; + } if (config_block[0x11] != 0xFF) global_settings.avc = config_block[0x11]; @@ -418,6 +422,7 @@ void settings_reset(void) { global_settings.total_uptime = 0; global_settings.scroll_speed = 8; global_settings.show_hidden_files = false; + global_settings.ff_rewind_min_step = DEFAULT_FF_REWIND_MIN_STEP; global_settings.ff_rewind_accel = DEFAULT_FF_REWIND_ACCEL_SETTING; global_settings.resume_index = -1; global_settings.resume_offset = -1; diff --git a/apps/settings.h b/apps/settings.h index 3971d41b7b..7474221fc4 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -31,6 +31,21 @@ #define RESUME_ASK 1 #define RESUME_ON 2 +#define FF_REWIND_1000 0 +#define FF_REWIND_2000 1 +#define FF_REWIND_3000 2 +#define FF_REWIND_4000 3 +#define FF_REWIND_5000 4 +#define FF_REWIND_6000 5 +#define FF_REWIND_8000 6 +#define FF_REWIND_10000 7 +#define FF_REWIND_15000 8 +#define FF_REWIND_20000 9 +#define FF_REWIND_25000 10 +#define FF_REWIND_30000 11 +#define FF_REWIND_45000 12 +#define FF_REWIND_60000 13 + struct user_settings { /* audio settings */ @@ -65,6 +80,7 @@ struct user_settings bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ int scroll_speed; /* long texts scrolling speed: 1-20 */ bool playlist_shuffle; + int ff_rewind_min_step; /* FF/Rewind minimum step size */ int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */ int disk_spindown; /* time until disk spindown, in seconds (0=off) */ @@ -118,6 +134,7 @@ extern char rockboxdir[]; #define MIN_CONTRAST_SETTING 5 #define DEFAULT_POWEROFF_SETTING 0 #define DEFAULT_BACKLIGHT_SETTING 5 +#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000 #define DEFAULT_FF_REWIND_ACCEL_SETTING 3 #endif /* __SETTINGS_H__ */ diff --git a/apps/settings_menu.c b/apps/settings_menu.c index cb85af317c..c93ea49c38 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -154,6 +154,17 @@ static Menu spindown(void) return MENU_OK; } +static Menu ff_rewind_min_step(void) +{ + char* names[] = { "1s ", "2s ", "3s ", "4s ", + "5s ", "6s ", "8s ", "10s", + "15s", "20s", "25s", "30s", + "45s", "60s" }; + set_option("[FF/rewind min step]", &global_settings.ff_rewind_min_step, + names, 14 ); + return MENU_OK; +} + static Menu ff_rewind_accel(void) { char* names[] = { "off ", "2x/1s ", "2x/2s ", "2x/3s ", @@ -186,6 +197,7 @@ Menu settings_menu(void) { "Time/Date", timedate_set }, #endif { "Show hidden files", show_hidden_files }, + { "FF/Rewind", ff_rewind_min_step }, { "FF/Rewind Accel", ff_rewind_accel }, { "Resume", resume }, { "Disk spindown", spindown }, 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,73 +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: - 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_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; - - if(wps_time_countup == false) - wps_refresh(id3, -ff_rewind_count, false); - else - wps_refresh(id3, ff_rewind_count, false); - break; - 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; } } @@ -367,49 +330,48 @@ static bool ffwd_rew(int button) #ifdef HAVE_PLAYER_KEYPAD lcd_stop_scroll(); #endif - status_set_playmode(STATUS_FASTFORWARD); + 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 + + + step = ff_rew_steps[global_settings.ff_rewind_min_step]; + + max_step = id3->length * FF_REWIND_MAX_PERCENT / 100; + + 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_RIGHT | BUTTON_REL: - /* fast forward */ mpeg_ff_rewind(ff_rewind_count); ff_rewind_count = 0; ff_rewind = false;