summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-02-14 15:54:52 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-02-14 15:54:52 +0000
commite2628d99315c315ba52c5b9abe5ba9d4017e8386 (patch)
tree9ebf62f6d43ef922dca791053ce713246c3e23aa
parent84eb9ce4a8a82fee0a85618aa4935aa55cad39fa (diff)
downloadrockbox-e2628d99315c315ba52c5b9abe5ba9d4017e8386.tar.gz
rockbox-e2628d99315c315ba52c5b9abe5ba9d4017e8386.zip
Volume fade patch by Eric Linenberg
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3263 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang5
-rw-r--r--apps/settings.c12
-rw-r--r--apps/settings.h1
-rw-r--r--apps/settings_menu.c7
-rw-r--r--apps/wps.c52
-rw-r--r--docs/CUSTOM_CFG_FORMAT1
6 files changed, 74 insertions, 4 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 4539e21aca..ef92d474cd 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1391,3 +1391,8 @@ id: LANG_SETTINGS_LOADED2
1391desc: Feedback shown when a .cfg file is loaded 1391desc: Feedback shown when a .cfg file is loaded
1392eng: "loaded" 1392eng: "loaded"
1393new: 1393new:
1394
1395id: LANG_FADE_ON_STOP
1396decs: options menu to set fade on stop or pause
1397eng: "Fade On Stop/Pause"
1398new:
diff --git a/apps/settings.c b/apps/settings.c
index cd5208591a..f6e92b001d 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -122,6 +122,7 @@ modified unless the header & checksum test fails.
122 122
123 123
124Rest of config block, only saved to disk: 124Rest of config block, only saved to disk:
1250xAE fade on pause/unpause/stop setting (bit 0)
1250xB0 peak meter clip hold timeout (bit 0-4) 1260xB0 peak meter clip hold timeout (bit 0-4)
1260xB1 peak meter release step size, peak_meter_dbfs (bit 7) 1270xB1 peak meter release step size, peak_meter_dbfs (bit 7)
1270xB2 peak meter min either in -db or in percent 1280xB2 peak meter min either in -db or in percent
@@ -368,7 +369,8 @@ int settings_save( void )
368 config_block[0x28]=(unsigned char)(global_settings.topruntime & 0xff); 369 config_block[0x28]=(unsigned char)(global_settings.topruntime & 0xff);
369 config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8); 370 config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8);
370 } 371 }
371 372
373 config_block[0xae] = (unsigned char)global_settings.fade_on_stop;
372 config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold | 374 config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold |
373 (global_settings.peak_meter_performance ? 0x80 : 0); 375 (global_settings.peak_meter_performance ? 0x80 : 0);
374 config_block[0xb1] = global_settings.peak_meter_release | 376 config_block[0xb1] = global_settings.peak_meter_release |
@@ -651,6 +653,8 @@ void settings_load(void)
651 global_settings.topruntime = 653 global_settings.topruntime =
652 config_block[0x28] | (config_block[0x29] << 8); 654 config_block[0x28] | (config_block[0x29] << 8);
653 655
656 global_settings.fade_on_stop=config_block[0xae];
657
654 global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f; 658 global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f;
655 global_settings.peak_meter_performance = 659 global_settings.peak_meter_performance =
656 (config_block[0xb0] & 0x80) != 0; 660 (config_block[0xb0] & 0x80) != 0;
@@ -672,6 +676,9 @@ void settings_load(void)
672 if (config_block[0xb7] != 0xff) 676 if (config_block[0xb7] != 0xff)
673 global_settings.bidir_limit = config_block[0xb7]; 677 global_settings.bidir_limit = config_block[0xb7];
674 678
679 if (config_block[0xae] != 0xff)
680 global_settings.fade_on_stop = config_block[0xae];
681
675 memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); 682 memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
676 memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); 683 memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
677 684
@@ -980,6 +987,8 @@ bool settings_load_config(char* file)
980 else if (!strcasecmp(name, "trickle charge")) 987 else if (!strcasecmp(name, "trickle charge"))
981 set_cfg_bool(&global_settings.trickle_charge, value); 988 set_cfg_bool(&global_settings.trickle_charge, value);
982#endif 989#endif
990 else if (!strcasecmp(name, "volume fade"))
991 set_cfg_bool(&global_settings.fade_on_stop, value);
983 } 992 }
984 993
985 close(fd); 994 close(fd);
@@ -1057,6 +1066,7 @@ void settings_reset(void) {
1057 global_settings.runtime = 0; 1066 global_settings.runtime = 0;
1058 global_settings.topruntime = 0; 1067 global_settings.topruntime = 0;
1059 global_settings.cpu_sleep = true; 1068 global_settings.cpu_sleep = true;
1069 global_settings.fade_on_stop = true;
1060} 1070}
1061 1071
1062 1072
diff --git a/apps/settings.h b/apps/settings.h
index d1679cee10..68b2ba8874 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -149,6 +149,7 @@ struct user_settings
149 int scroll_step; /* pixels to advance per update */ 149 int scroll_step; /* pixels to advance per update */
150 150
151 bool cpu_sleep; /* Use sleep instruction when idle? */ 151 bool cpu_sleep; /* Use sleep instruction when idle? */
152 bool fade_on_stop; /* fade on pause/unpause/stop */
152}; 153};
153 154
154/* prototypes */ 155/* prototypes */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 37b2b094a7..e931fe63bc 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -565,6 +565,12 @@ static bool ff_rewind_min_step(void)
565 names, 14, NULL ); 565 names, 14, NULL );
566} 566}
567 567
568static bool set_fade_on_stop(void)
569{
570 return set_bool( str(LANG_FADE_ON_STOP), &global_settings.fade_on_stop );
571}
572
573
568static bool ff_rewind_accel(void) 574static bool ff_rewind_accel(void)
569{ 575{
570 char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s", 576 char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s",
@@ -594,6 +600,7 @@ static bool playback_settings_menu(void)
594 { str(LANG_FFRW_STEP), ff_rewind_min_step }, 600 { str(LANG_FFRW_STEP), ff_rewind_min_step },
595 { str(LANG_FFRW_ACCEL), ff_rewind_accel }, 601 { str(LANG_FFRW_ACCEL), ff_rewind_accel },
596 { str(LANG_MP3BUFFER_MARGIN), buffer_margin }, 602 { str(LANG_MP3BUFFER_MARGIN), buffer_margin },
603 { str(LANG_FADE_ON_STOP), set_fade_on_stop },
597 }; 604 };
598 605
599 bool old_shuffle = global_settings.playlist_shuffle; 606 bool old_shuffle = global_settings.playlist_shuffle;
diff --git a/apps/wps.c b/apps/wps.c
index de5ab0a8c1..1071bcc035 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -665,6 +665,43 @@ static bool menu(void)
665 return false; 665 return false;
666} 666}
667 667
668static void fade(bool fade_in)
669{
670 if (fade_in) {
671 /* fade in */
672 int current_volume = 20;
673
674 /* zero out the sound */
675 mpeg_sound_set(SOUND_VOLUME, current_volume);
676
677 mpeg_resume();
678 sleep(1); /* let mpeg thread run */
679
680 while (current_volume < global_settings.volume) {
681 current_volume += 2;
682 sleep(1);
683 mpeg_sound_set(SOUND_VOLUME, current_volume);
684 }
685 mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
686 }
687 else {
688 /* fade out */
689 int current_volume = global_settings.volume;
690
691 while (current_volume > 20) {
692 current_volume -= 2;
693 sleep(1);
694 mpeg_sound_set(SOUND_VOLUME, current_volume);
695 }
696 mpeg_pause();
697 sleep(1); /* let mpeg thread run */
698
699 /* reset volume to what it was before the fade */
700 mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
701 }
702}
703
704
668/* demonstrates showing different formats from playtune */ 705/* demonstrates showing different formats from playtune */
669int wps_show(void) 706int wps_show(void)
670{ 707{
@@ -801,15 +838,21 @@ int wps_show(void)
801 case BUTTON_PLAY: 838 case BUTTON_PLAY:
802 if ( paused ) 839 if ( paused )
803 { 840 {
804 mpeg_resume();
805 paused = false; 841 paused = false;
806 status_set_playmode(STATUS_PLAY); 842 status_set_playmode(STATUS_PLAY);
843 if ( global_settings.fade_on_stop )
844 fade(1);
845 else
846 mpeg_resume();
807 } 847 }
808 else 848 else
809 { 849 {
810 mpeg_pause();
811 paused = true; 850 paused = true;
812 status_set_playmode(STATUS_PAUSE); 851 status_set_playmode(STATUS_PAUSE);
852 if ( global_settings.fade_on_stop )
853 fade(0);
854 else
855 mpeg_pause();
813 if (global_settings.resume) { 856 if (global_settings.resume) {
814 settings_save(); 857 settings_save();
815#ifndef HAVE_RTC 858#ifndef HAVE_RTC
@@ -915,7 +958,7 @@ int wps_show(void)
915 958
916 /* stop and exit wps */ 959 /* stop and exit wps */
917#ifdef HAVE_RECORDER_KEYPAD 960#ifdef HAVE_RECORDER_KEYPAD
918 case BUTTON_OFF | BUTTON_REL: 961 case BUTTON_OFF:
919#else 962#else
920 case BUTTON_STOP | BUTTON_REL: 963 case BUTTON_STOP | BUTTON_REL:
921 if ( lastbutton != BUTTON_STOP ) 964 if ( lastbutton != BUTTON_STOP )
@@ -947,6 +990,9 @@ int wps_show(void)
947 status_set_record(false); 990 status_set_record(false);
948 status_set_audio(false); 991 status_set_audio(false);
949#endif 992#endif
993 if (global_settings.fade_on_stop)
994 fade(0);
995
950 lcd_stop_scroll(); 996 lcd_stop_scroll();
951 mpeg_stop(); 997 mpeg_stop();
952 status_set_playmode(STATUS_STOP); 998 status_set_playmode(STATUS_STOP);
diff --git a/docs/CUSTOM_CFG_FORMAT b/docs/CUSTOM_CFG_FORMAT
index 06b11b8241..3bb599f1e2 100644
--- a/docs/CUSTOM_CFG_FORMAT
+++ b/docs/CUSTOM_CFG_FORMAT
@@ -26,6 +26,7 @@ resume (off, ask, on)
26scan min step (1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 25) [seconds] 26scan min step (1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 25) [seconds]
27scan accel (0 - 15) [double scan speed every X seconds] 27scan accel (0 - 15) [double scan speed every X seconds]
28antiskip (0 - 7) [seconds] 28antiskip (0 - 7) [seconds]
29volume fade (on, off)
29 30
30sort case (on, off) 31sort case (on, off)
31show files (all, supported, music) 32show files (all, supported, music)