diff options
author | Björn Stenberg <bjorn@haxx.se> | 2004-05-22 01:09:47 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2004-05-22 01:09:47 +0000 |
commit | 1c6ba0adacf88f23ef81961ffcc7db14d6428159 (patch) | |
tree | 29c7242e404f26d7b07bd0293e12fe95dfae28f1 /apps | |
parent | dfb5c6ed6188e75e2d6a400455c3305de937d700 (diff) | |
download | rockbox-1c6ba0adacf88f23ef81961ffcc7db14d6428159.tar.gz rockbox-1c6ba0adacf88f23ef81961ffcc7db14d6428159.zip |
Improved ff/rw max step calculation (patch #882931 by Craigh Sather)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4691 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/wps.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/apps/wps.c b/apps/wps.c index 6aa8a72b60..bc09ec5506 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <string.h> | 20 | #include <string.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | 22 | ||
23 | #include "system.h" | ||
23 | #include "file.h" | 24 | #include "file.h" |
24 | #include "lcd.h" | 25 | #include "lcd.h" |
25 | #include "font.h" | 26 | #include "font.h" |
@@ -49,6 +50,7 @@ | |||
49 | #include "bookmark.h" | 50 | #include "bookmark.h" |
50 | #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ | 51 | #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ |
51 | /* 3% of 30min file == 54s step size */ | 52 | /* 3% of 30min file == 54s step size */ |
53 | #define MIN_FF_REWIND_STEP 500 | ||
52 | 54 | ||
53 | bool keys_locked = false; | 55 | bool keys_locked = false; |
54 | static bool ff_rewind = false; | 56 | static bool ff_rewind = false; |
@@ -327,15 +329,31 @@ static bool ffwd_rew(int button) | |||
327 | case BUTTON_RIGHT | BUTTON_REPEAT: | 329 | case BUTTON_RIGHT | BUTTON_REPEAT: |
328 | if (ff_rewind) | 330 | if (ff_rewind) |
329 | { | 331 | { |
332 | if (direction == 1) | ||
333 | { | ||
334 | /* fast forwarding, calc max step relative to end */ | ||
335 | max_step = | ||
336 | (id3->length - (id3->elapsed + ff_rewind_count)) * | ||
337 | FF_REWIND_MAX_PERCENT / 100; | ||
338 | } | ||
339 | else | ||
340 | { | ||
341 | /* rewinding, calc max step relative to start */ | ||
342 | max_step = (id3->elapsed + ff_rewind_count) * | ||
343 | FF_REWIND_MAX_PERCENT / 100; | ||
344 | } | ||
345 | |||
346 | max_step = MAX(max_step, MIN_FF_REWIND_STEP); | ||
347 | |||
348 | if (step > max_step) | ||
349 | step = max_step; | ||
350 | |||
330 | ff_rewind_count += step * direction; | 351 | ff_rewind_count += step * direction; |
331 | 352 | ||
332 | if (global_settings.ff_rewind_accel != 0 && | 353 | if (global_settings.ff_rewind_accel != 0 && |
333 | current_tick >= accel_tick) | 354 | current_tick >= accel_tick) |
334 | { | 355 | { |
335 | step *= 2; | 356 | step *= 2; |
336 | if (step > max_step) | ||
337 | step = max_step; | ||
338 | |||
339 | accel_tick = current_tick + | 357 | accel_tick = current_tick + |
340 | global_settings.ff_rewind_accel*HZ; | 358 | global_settings.ff_rewind_accel*HZ; |
341 | } | 359 | } |
@@ -361,12 +379,6 @@ static bool ffwd_rew(int button) | |||
361 | 379 | ||
362 | step = ff_rew_steps[global_settings.ff_rewind_min_step]; | 380 | step = ff_rew_steps[global_settings.ff_rewind_min_step]; |
363 | 381 | ||
364 | max_step = id3->length * FF_REWIND_MAX_PERCENT / 100; | ||
365 | |||
366 | if (step > max_step) | ||
367 | step = max_step; | ||
368 | |||
369 | ff_rewind_count = step * direction; | ||
370 | accel_tick = current_tick + | 382 | accel_tick = current_tick + |
371 | global_settings.ff_rewind_accel*HZ; | 383 | global_settings.ff_rewind_accel*HZ; |
372 | } | 384 | } |