Update of /cvsroot/rockbox/apps
In directory sc8-pr-cvs1:/tmp/cvs-serv23545/apps
Modified Files:
settings.c settings.h settings_menu.c wps.c
Log Message:
Volume fade patch by Eric Linenberg
Index: settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -b -r1.114 -r1.115
--- settings.c 14 Feb 2003 14:17:50 -0000 1.114
+++ settings.c 14 Feb 2003 15:54:50 -0000 1.115
@@ -122,6 +122,7 @@
Rest of config block, only saved to disk:
+0xAE fade on pause/unpause/stop setting (bit 0)
0xB0 peak meter clip hold timeout (bit 0-4)
0xB1 peak meter release step size, peak_meter_dbfs (bit 7)
0xB2 peak meter min either in -db or in percent
@@ -369,6 +370,7 @@
config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8);
}
+ config_block[0xae] = (unsigned char)global_settings.fade_on_stop;
config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold |
(global_settings.peak_meter_performance ? 0x80 : 0);
config_block[0xb1] = global_settings.peak_meter_release |
@@ -651,6 +653,8 @@
global_settings.topruntime =
config_block[0x28] | (config_block[0x29] << 8);
+ global_settings.fade_on_stop=config_block[0xae];
+
global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f;
global_settings.peak_meter_performance =
(config_block[0xb0] & 0x80) != 0;
@@ -672,6 +676,9 @@
if (config_block[0xb7] != 0xff)
global_settings.bidir_limit = config_block[0xb7];
+ if (config_block[0xae] != 0xff)
+ global_settings.fade_on_stop = config_block[0xae];
+
memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
@@ -980,6 +987,8 @@
else if (!strcasecmp(name, "trickle charge"))
set_cfg_bool(&global_settings.trickle_charge, value);
#endif
+ else if (!strcasecmp(name, "volume fade"))
+ set_cfg_bool(&global_settings.fade_on_stop, value);
}
close(fd);
@@ -1057,6 +1066,7 @@
global_settings.runtime = 0;
global_settings.topruntime = 0;
global_settings.cpu_sleep = true;
+ global_settings.fade_on_stop = true;
}
Index: settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- settings.h 14 Feb 2003 14:14:55 -0000 1.69
+++ settings.h 14 Feb 2003 15:54:51 -0000 1.70
@@ -149,6 +149,7 @@
int scroll_step; /* pixels to advance per update */
bool cpu_sleep; /* Use sleep instruction when idle? */
+ bool fade_on_stop; /* fade on pause/unpause/stop */
};
/* prototypes */
Index: settings_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings_menu.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -b -r1.97 -r1.98
--- settings_menu.c 14 Feb 2003 09:44:33 -0000 1.97
+++ settings_menu.c 14 Feb 2003 15:54:51 -0000 1.98
@@ -565,6 +565,12 @@
names, 14, NULL );
}
+static bool set_fade_on_stop(void)
+{
+ return set_bool( str(LANG_FADE_ON_STOP), &global_settings.fade_on_stop );
+}
+
+
static bool ff_rewind_accel(void)
{
char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s",
@@ -594,6 +600,7 @@
{ str(LANG_FFRW_STEP), ff_rewind_min_step },
{ str(LANG_FFRW_ACCEL), ff_rewind_accel },
{ str(LANG_MP3BUFFER_MARGIN), buffer_margin },
+ { str(LANG_FADE_ON_STOP), set_fade_on_stop },
};
bool old_shuffle = global_settings.playlist_shuffle;
Index: wps.c
===================================================================
RCS file: /cvsroot/rockbox/apps/wps.c,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -b -r1.178 -r1.179
--- wps.c 12 Feb 2003 10:01:00 -0000 1.178
+++ wps.c 14 Feb 2003 15:54:51 -0000 1.179
@@ -665,6 +665,43 @@
return false;
}
+static void fade(bool fade_in)
+{
+ if (fade_in) {
+ /* fade in */
+ int current_volume = 20;
+
+ /* zero out the sound */
+ mpeg_sound_set(SOUND_VOLUME, current_volume);
+
+ mpeg_resume();
+ sleep(1); /* let mpeg thread run */
+
+ while (current_volume < global_settings.volume) {
+ current_volume += 2;
+ sleep(1);
+ mpeg_sound_set(SOUND_VOLUME, current_volume);
+ }
+ mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
+ }
+ else {
+ /* fade out */
+ int current_volume = global_settings.volume;
+
+ while (current_volume > 20) {
+ current_volume -= 2;
+ sleep(1);
+ mpeg_sound_set(SOUND_VOLUME, current_volume);
+ }
+ mpeg_pause();
+ sleep(1); /* let mpeg thread run */
+
+ /* reset volume to what it was before the fade */
+ mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
+ }
+}
+
+
/* demonstrates showing different formats from playtune */
int wps_show(void)
{
@@ -801,15 +838,21 @@
case BUTTON_PLAY:
if ( paused )
{
- mpeg_resume();
paused = false;
status_set_playmode(STATUS_PLAY);
+ if ( global_settings.fade_on_stop )
+ fade(1);
+ else
+ mpeg_resume();
}
else
{
- mpeg_pause();
paused = true;
status_set_playmode(STATUS_PAUSE);
+ if ( global_settings.fade_on_stop )
+ fade(0);
+ else
+ mpeg_pause();
if (global_settings.resume) {
settings_save();
#ifndef HAVE_RTC
@@ -915,7 +958,7 @@
/* stop and exit wps */
#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF | BUTTON_REL:
+ case BUTTON_OFF:
#else
case BUTTON_STOP | BUTTON_REL:
if ( lastbutton != BUTTON_STOP )
@@ -947,6 +990,9 @@
status_set_record(false);
status_set_audio(false);
#endif
+ if (global_settings.fade_on_stop)
+ fade(0);
+
lcd_stop_scroll();
mpeg_stop();
status_set_playmode(STATUS_STOP);
|