summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-11-08 14:36:09 +0000
committerNils Wallménius <nils@rockbox.org>2007-11-08 14:36:09 +0000
commit23078a34d82d7ae3728b0f93ef600b50a3b4ce96 (patch)
tree23ed82e06d4f7dfc17f4723ee5292ecc679f5929
parent6bcd8304902465fc856caebb2a8a004d07a451c2 (diff)
downloadrockbox-23078a34d82d7ae3728b0f93ef600b50a3b4ce96.tar.gz
rockbox-23078a34d82d7ae3728b0f93ef600b50a3b4ce96.zip
Fix FS#8114 remove redundant screen updating and minor code police.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15531 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/screens.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/apps/screens.c b/apps/screens.c
index 67f7f7eb37..543aeee6f4 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -457,10 +457,9 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode)
457 display->update(); 457 display->update();
458} 458}
459 459
460static int pitch_increase(int pitch, int delta, 460static int pitch_increase(int pitch, int delta, bool allow_cutoff)
461 bool allow_cutoff, bool redraw_screens) { 461{
462 int new_pitch; 462 int new_pitch;
463 int i;
464 463
465 if (delta < 0) { 464 if (delta < 0) {
466 if (pitch + delta >= PITCH_MIN) { 465 if (pitch + delta >= PITCH_MIN) {
@@ -485,12 +484,7 @@ static int pitch_increase(int pitch, int delta,
485 return pitch; 484 return pitch;
486 } 485 }
487 sound_set_pitch(new_pitch); 486 sound_set_pitch(new_pitch);
488 487
489 if (redraw_screens) {
490 FOR_NB_SCREENS(i)
491 pitch_screen_draw(&screens[i], pitch, pitch_mode);
492 }
493
494 return new_pitch; 488 return new_pitch;
495} 489}
496 490
@@ -512,7 +506,8 @@ static int pitch_increase(int pitch, int delta,
512#define PITCH_N_FCT 10 506#define PITCH_N_FCT 10
513#define PITCH_KN_FCT 1000000UL 507#define PITCH_KN_FCT 1000000UL
514 508
515static int pitch_increase_semitone(int pitch, bool up) { 509static int pitch_increase_semitone(int pitch, bool up)
510{
516 uint32_t tmp; 511 uint32_t tmp;
517 uint32_t round_fct; /* How much to scale down at the end */ 512 uint32_t round_fct; /* How much to scale down at the end */
518 tmp = pitch; 513 tmp = pitch;
@@ -525,14 +520,14 @@ static int pitch_increase_semitone(int pitch, bool up) {
525 } 520 }
526 /* Scaling down with rounding */ 521 /* Scaling down with rounding */
527 tmp = (tmp + round_fct / 2) / round_fct; 522 tmp = (tmp + round_fct / 2) / round_fct;
528 return pitch_increase(pitch, tmp - pitch, false, false); 523 return pitch_increase(pitch, tmp - pitch, false);
529} 524}
530 525
531bool pitch_screen(void) 526bool pitch_screen(void)
532{ 527{
533 int button; 528 int button;
534 int pitch = sound_get_pitch(); 529 int pitch = sound_get_pitch();
535 int new_pitch; 530 int new_pitch, delta = 0;
536 bool nudged = false; 531 bool nudged = false;
537 bool exit = false; 532 bool exit = false;
538 int i; 533 int i;
@@ -549,54 +544,43 @@ bool pitch_screen(void)
549 button = get_action(CONTEXT_PITCHSCREEN,TIMEOUT_BLOCK); 544 button = get_action(CONTEXT_PITCHSCREEN,TIMEOUT_BLOCK);
550 switch (button) { 545 switch (button) {
551 case ACTION_PS_INC_SMALL: 546 case ACTION_PS_INC_SMALL:
552 if (pitch_mode == PITCH_MODE_ABSOLUTE) { 547 delta = PITCH_SMALL_DELTA;
553 pitch = pitch_increase(pitch, PITCH_SMALL_DELTA, true, false);
554 } else {
555 pitch = pitch_increase_semitone(pitch, true);
556 }
557 break; 548 break;
558 549
559 case ACTION_PS_INC_BIG: 550 case ACTION_PS_INC_BIG:
560 if (pitch_mode == PITCH_MODE_ABSOLUTE) { 551 delta = PITCH_BIG_DELTA;
561 pitch = pitch_increase(pitch, PITCH_BIG_DELTA, true, false);
562 }
563 break; 552 break;
564 553
565 case ACTION_PS_DEC_SMALL: 554 case ACTION_PS_DEC_SMALL:
566 if (pitch_mode == PITCH_MODE_ABSOLUTE) { 555 delta = -PITCH_SMALL_DELTA;
567 pitch = pitch_increase(pitch, -PITCH_SMALL_DELTA, true, false);
568 } else {
569 pitch = pitch_increase_semitone(pitch, false);
570 }
571 break; 556 break;
572 557
573 case ACTION_PS_DEC_BIG: 558 case ACTION_PS_DEC_BIG:
574 if (pitch_mode == PITCH_MODE_ABSOLUTE) { 559 delta = -PITCH_BIG_DELTA;
575 pitch = pitch_increase(pitch, -PITCH_BIG_DELTA, true, false);
576 }
577 break; 560 break;
578 561
579 case ACTION_PS_NUDGE_RIGHT: 562 case ACTION_PS_NUDGE_RIGHT:
580 new_pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false, true); 563 new_pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false);
581 nudged = (new_pitch != pitch); 564 nudged = (new_pitch != pitch);
582 pitch = new_pitch; 565 pitch = new_pitch;
583 break; 566 break;
567
584 case ACTION_PS_NUDGE_RIGHTOFF: 568 case ACTION_PS_NUDGE_RIGHTOFF:
585 if (nudged) { 569 if (nudged) {
586 pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false, false); 570 pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false);
587 } 571 }
588 nudged = false; 572 nudged = false;
589 break; 573 break;
590 574
591 case ACTION_PS_NUDGE_LEFT: 575 case ACTION_PS_NUDGE_LEFT:
592 new_pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false, true); 576 new_pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false);
593 nudged = (new_pitch != pitch); 577 nudged = (new_pitch != pitch);
594 pitch = new_pitch; 578 pitch = new_pitch;
595 break; 579 break;
596 580
597 case ACTION_PS_NUDGE_LEFTOFF: 581 case ACTION_PS_NUDGE_LEFTOFF:
598 if (nudged) { 582 if (nudged) {
599 pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false, false); 583 pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false);
600 } 584 }
601 nudged = false; 585 nudged = false;
602 break; 586 break;
@@ -619,6 +603,18 @@ bool pitch_screen(void)
619 return 1; 603 return 1;
620 break; 604 break;
621 } 605 }
606
607 if(delta)
608 {
609 if (pitch_mode == PITCH_MODE_ABSOLUTE) {
610 pitch = pitch_increase(pitch, delta, true);
611 } else {
612 pitch = pitch_increase_semitone(pitch, delta > 0 ? true:false);
613 }
614
615 delta = 0;
616 }
617
622 } 618 }
623#if CONFIG_CODEC == SWCODEC 619#if CONFIG_CODEC == SWCODEC
624 pcmbuf_set_low_latency(false); 620 pcmbuf_set_low_latency(false);