summaryrefslogtreecommitdiff
path: root/apps/wps.c
diff options
context:
space:
mode:
authorEric Linenberg <elinenbe@umich.edu>2002-09-04 03:38:37 +0000
committerEric Linenberg <elinenbe@umich.edu>2002-09-04 03:38:37 +0000
commit7eb27113c58d95c6644f439406ce74208cfc26b6 (patch)
tree51310ff4f561e9bede42246ccbad015a82b0b5c3 /apps/wps.c
parent1be02f6c63ea532a04518b91b956beeb5f12cc56 (diff)
downloadrockbox-7eb27113c58d95c6644f439406ce74208cfc26b6.tar.gz
rockbox-7eb27113c58d95c6644f439406ce74208cfc26b6.zip
Nate Nystrom's FF/RW min speed patch
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2161 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/wps.c')
-rw-r--r--apps/wps.c120
1 files changed, 41 insertions, 79 deletions
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 @@
44#include "ajf.h" 44#include "ajf.h"
45#endif 45#endif
46 46
47#define FF_REWIND_MIN_STEP 1000 /* minimum ff/rewind step is 1 second */
48#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ 47#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
49 /* 3% of 30min file == 54s step size */ 48 /* 3% of 30min file == 54s step size */
50 49
@@ -288,26 +287,37 @@ int player_id3_show(void)
288 287
289static bool ffwd_rew(int button) 288static bool ffwd_rew(int button)
290{ 289{
291 unsigned int ff_rewind_step = 0; /* current rewind step size */ 290 static int ff_rew_steps[] = {
292 unsigned int ff_rewind_max_step = 0; /* max rewind step size */ 291 1000, 2000, 3000, 4000,
293 int ff_rewind_count = 0; 292 5000, 6000, 8000, 10000,
294 long ff_rewind_accel_tick = 0; /* next time to bump ff/rewind step size */ 293 15000, 20000, 25000, 30000,
294 45000, 60000
295 };
296
297 unsigned int step = 0; /* current ff/rewind step */
298 unsigned int max_step = 0; /* maximum ff/rewind step */
299 int ff_rewind_count = 0; /* current ff/rewind count (in ticks) */
300 int direction = 1; /* forward=1 or backward=-1 */
301 long accel_tick = 0; /* next time at which to bump the step size */
295 bool exit = false; 302 bool exit = false;
296 bool usb = false; 303 bool usb = false;
297 304
298 while (!exit) { 305 while (!exit) {
299 switch ( button ) { 306 switch ( button ) {
300 case BUTTON_LEFT | BUTTON_REPEAT: 307 case BUTTON_LEFT | BUTTON_REPEAT:
308 case BUTTON_RIGHT | BUTTON_REPEAT:
301 if (ff_rewind) 309 if (ff_rewind)
302 { 310 {
303 ff_rewind_count -= ff_rewind_step; 311 ff_rewind_count += step * direction;
312
304 if (global_settings.ff_rewind_accel != 0 && 313 if (global_settings.ff_rewind_accel != 0 &&
305 current_tick >= ff_rewind_accel_tick) 314 current_tick >= accel_tick)
306 { 315 {
307 ff_rewind_step *= 2; 316 step *= 2;
308 if (ff_rewind_step > ff_rewind_max_step) 317 if (step > max_step)
309 ff_rewind_step = ff_rewind_max_step; 318 step = max_step;
310 ff_rewind_accel_tick = current_tick + 319
320 accel_tick = current_tick +
311 global_settings.ff_rewind_accel*HZ; 321 global_settings.ff_rewind_accel*HZ;
312 } 322 }
313 } 323 }
@@ -320,96 +330,48 @@ static bool ffwd_rew(int button)
320#ifdef HAVE_PLAYER_KEYPAD 330#ifdef HAVE_PLAYER_KEYPAD
321 lcd_stop_scroll(); 331 lcd_stop_scroll();
322#endif 332#endif
333 direction = (button & BUTTON_RIGHT) ? 1 : -1;
334
335 if (direction > 0)
336 status_set_playmode(STATUS_FASTFORWARD);
337 else
323 status_set_playmode(STATUS_FASTBACKWARD); 338 status_set_playmode(STATUS_FASTBACKWARD);
339
324 ff_rewind = true; 340 ff_rewind = true;
325 ff_rewind_max_step =
326 id3->length * FF_REWIND_MAX_PERCENT / 100;
327 ff_rewind_step = FF_REWIND_MIN_STEP;
328 if (ff_rewind_step > ff_rewind_max_step)
329 ff_rewind_step = ff_rewind_max_step;
330 ff_rewind_count = -ff_rewind_step;
331 ff_rewind_accel_tick = current_tick +
332 global_settings.ff_rewind_accel*HZ;
333 }
334 else
335 break;
336 }
337 341
338 if ((int)(id3->elapsed + ff_rewind_count) < 0) 342 step = ff_rew_steps[global_settings.ff_rewind_min_step];
339 ff_rewind_count = -id3->elapsed;
340 343
341 if(wps_time_countup == false) 344 max_step = id3->length * FF_REWIND_MAX_PERCENT / 100;
342 wps_refresh(id3, -ff_rewind_count, false);
343 else
344 wps_refresh(id3, ff_rewind_count, false);
345 break;
346 345
347 case BUTTON_RIGHT | BUTTON_REPEAT: 346 if (step > max_step)
348 if (ff_rewind) 347 step = max_step;
349 { 348
350 ff_rewind_count += ff_rewind_step; 349 ff_rewind_count = step * direction;
351 if (global_settings.ff_rewind_accel != 0 && 350 accel_tick = current_tick +
352 current_tick >= ff_rewind_accel_tick)
353 {
354 ff_rewind_step *= 2;
355 if (ff_rewind_step > ff_rewind_max_step)
356 ff_rewind_step = ff_rewind_max_step;
357 ff_rewind_accel_tick = current_tick +
358 global_settings.ff_rewind_accel*HZ;
359 }
360 }
361 else
362 {
363 if ( mpeg_is_playing() && id3 && id3->length )
364 {
365 if (!paused)
366 mpeg_pause();
367#ifdef HAVE_PLAYER_KEYPAD
368 lcd_stop_scroll();
369#endif
370 status_set_playmode(STATUS_FASTFORWARD);
371 ff_rewind = true;
372 ff_rewind_max_step =
373 id3->length * FF_REWIND_MAX_PERCENT / 100;
374 ff_rewind_step = FF_REWIND_MIN_STEP;
375 if (ff_rewind_step > ff_rewind_max_step)
376 ff_rewind_step = ff_rewind_max_step;
377 ff_rewind_count = ff_rewind_step;
378 ff_rewind_accel_tick = current_tick +
379 global_settings.ff_rewind_accel*HZ; 351 global_settings.ff_rewind_accel*HZ;
380 } 352 }
381 else 353 else
382 break; 354 break;
383 } 355 }
384 356
357 if (direction > 0) {
385 if ((id3->elapsed + ff_rewind_count) > id3->length) 358 if ((id3->elapsed + ff_rewind_count) > id3->length)
386 ff_rewind_count = id3->length - id3->elapsed; 359 ff_rewind_count = id3->length - id3->elapsed;
360 }
361 else {
362 if ((int)(id3->elapsed + ff_rewind_count) < 0)
363 ff_rewind_count = -id3->elapsed;
364 }
387 365
388 if(wps_time_countup == false) 366 if(wps_time_countup == false)
389 wps_refresh(id3, -ff_rewind_count, false); 367 wps_refresh(id3, -ff_rewind_count, false);
390 else 368 else
391 wps_refresh(id3, ff_rewind_count, false); 369 wps_refresh(id3, ff_rewind_count, false);
392 break;
393 370
394 case BUTTON_LEFT | BUTTON_REL:
395 /* rewind */
396 mpeg_ff_rewind(ff_rewind_count);
397 ff_rewind_count = 0;
398 ff_rewind = false;
399 if (paused)
400 status_set_playmode(STATUS_PAUSE);
401 else {
402 mpeg_resume();
403 status_set_playmode(STATUS_PLAY);
404 }
405#ifdef HAVE_LCD_CHARCELLS
406 wps_display(id3);
407#endif
408 exit = true;
409 break; 371 break;
410 372
373 case BUTTON_LEFT | BUTTON_REL:
411 case BUTTON_RIGHT | BUTTON_REL: 374 case BUTTON_RIGHT | BUTTON_REL:
412 /* fast forward */
413 mpeg_ff_rewind(ff_rewind_count); 375 mpeg_ff_rewind(ff_rewind_count);
414 ff_rewind_count = 0; 376 ff_rewind_count = 0;
415 ff_rewind = false; 377 ff_rewind = false;