Resume rework. With the new resume function, 'Ask' and 'Ask Once' are redundant options, since you can resume after any startup using the resume key. These have been stripped out, and the resume code has been streamlined. A small bug in button handler initialisation has been fixed.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6911 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Christi Scarborough 2005-06-29 12:23:09 +00:00
parent 1f45cce426
commit 9e8918b086
9 changed files with 31 additions and 134 deletions

View file

@ -447,13 +447,11 @@ int ft_enter(struct tree_context* c)
}
if ( play ) {
if ( global_settings.resume ) {
/* the resume_index must always be the index in the
shuffled list in case shuffle is enabled */
global_settings.resume_index = start_index;
global_settings.resume_offset = 0;
settings_save();
}
/* the resume_index must always be the index in the
shuffled list in case shuffle is enabled */
global_settings.resume_index = start_index;
global_settings.resume_offset = 0;
settings_save();
start_wps = true;
}

View file

@ -391,12 +391,6 @@ eng: "Is Full!"
voice: ""
new:
id: LANG_RESUME_ASK
desc: question asked at the begining when resume is on
eng: "Resume?"
voice: ""
new:
id: LANG_RESUME_CONFIRM_PLAYER
desc: possible answers to resume question
eng: "(PLAY/STOP)"
@ -847,12 +841,6 @@ eng: "Dec"
voice: "December"
new:
id: LANG_RESUME_SETTING_ASK_ONCE
desc: in settings_menu
eng: "Ask Once"
voice: "Ask Once"
new:
id: LANG_BATTERY_DISPLAY
desc: Battery type title
eng: "Battery Display"

View file

@ -693,15 +693,15 @@ bool quick_screen(int context, int button)
break;
case BUTTON_F3 | BUTTON_RIGHT:
// case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT:
case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT:
global_settings.statusbar = !global_settings.statusbar;
used = true;
break;
case BUTTON_F3 | BUTTON_DOWN:
// case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT:
case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT:
case BUTTON_F3 | BUTTON_UP:
// case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT:
case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT:
global_settings.flip_display = !global_settings.flip_display;
button_set_flip(global_settings.flip_display);
lcd_set_flip(global_settings.flip_display);

View file

@ -197,7 +197,7 @@ static const struct bit_entry rtc_bits[] =
"stereo,mono,custom,mono left,mono right,karaoke" },
{8, S_O(stereo_width), 100, "stereo width", NULL},
/* playback */
{2, S_O(resume), RESUME_ASK, "resume", "off,ask,ask once,on" },
{2, S_O(resume), false, "resume", off_on },
{1, S_O(playlist_shuffle), false, "shuffle", off_on },
{16 | SIGNED, S_O(resume_index), -1, NULL, NULL },
{16 | SIGNED, S_O(resume_first_index), 0, NULL, NULL },

View file

@ -78,11 +78,6 @@
/* data structures */
#define RESUME_OFF 0
#define RESUME_ASK 1
#define RESUME_ASK_ONCE 2
#define RESUME_ON 3
#define BOOKMARK_NO 0
#define BOOKMARK_YES 1
#define BOOKMARK_ASK 2
@ -211,7 +206,7 @@ struct user_settings
/* resume settings */
int resume; /* resume option: 0=off, 1=ask, 2=on */
bool resume; /* resume option: 0=off, 1=on */
int resume_index; /* index in playlist (-1 for no active resume) */
int resume_first_index; /* index of first track in playlist */
int resume_offset; /* byte offset in mp3 file */

View file

@ -656,14 +656,7 @@ static bool sort_dir(void)
static bool resume(void)
{
static const struct opt_items names[] = {
{ STR(LANG_SET_BOOL_NO) },
{ STR(LANG_RESUME_SETTING_ASK) },
{ STR(LANG_RESUME_SETTING_ASK_ONCE) },
{ STR(LANG_SET_BOOL_YES) }
};
return set_option( str(LANG_RESUME), &global_settings.resume, INT,
names, 4, NULL );
return set_bool( str(LANG_RESUME), &global_settings.resume);
}
static bool autocreatebookmark(void)

View file

@ -430,92 +430,6 @@ static int showdir(void)
return tc.filesindir;
}
static bool ask_resume(bool just_powered_on)
{
int button;
bool stop = false;
static bool ignore_power = true;
#ifdef HAVE_LCD_CHARCELLS
lcd_double_height(false);
#endif
#ifdef HAVE_ALARM_MOD
if ( rtc_check_alarm_started(true) ) {
rtc_enable_alarm(false);
return true;
}
#endif
/* always resume? */
if ( global_settings.resume == RESUME_ON || ! just_powered_on)
return true;
lcd_clear_display();
lcd_puts(0,0,str(LANG_RESUME_ASK));
#ifdef HAVE_LCD_CHARCELLS
status_draw(false);
lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER));
#else
lcd_puts(0,1,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
lcd_puts(0,2,str(LANG_CANCEL_WITH_ANY_RECORDER));
#endif
lcd_update();
while (!stop) {
button = button_get(true);
switch (button) {
#ifdef TREE_RUN_PRE
case TREE_RUN_PRE: /* catch the press, not the release */
#else
case TREE_RUN:
#endif
#ifdef TREE_RC_RUN_PRE
case TREE_RC_RUN_PRE: /* catch the press, not the release */
#else
#ifdef TREE_RC_RUN
case TREE_RC_RUN:
#endif
#endif
ignore_power = false;
/* Don't ignore the power button for subsequent calls */
return true;
#ifdef TREE_POWER_BTN
/* Initially ignore the button which powers on the box. It
* might still be pressed since booting. */
case TREE_POWER_BTN:
case TREE_POWER_BTN | BUTTON_REPEAT:
if(!ignore_power)
stop = true;
break;
/* No longer ignore the power button after it was released */
case TREE_POWER_BTN | BUTTON_REL:
ignore_power = false;
break;
#endif
/* Handle sys events, ignore button releases */
default:
if(default_event_handler(button) == SYS_USB_CONNECTED ||
(!IS_SYSEVENT(button) && !(button & BUTTON_REL)))
stop = true;
break;
}
}
if ( global_settings.resume == RESUME_ASK_ONCE && just_powered_on) {
global_settings.resume_index = -1;
settings_save();
}
ignore_power = false;
/* Don't ignore the power button for subsequent calls */
return false;
}
/* load tracks from specified directory to resume play */
void resume_directory(const char *dir)
{
@ -549,15 +463,26 @@ void reload_directory(void)
static void start_resume(bool just_powered_on)
{
if ( ( global_settings.resume || ! just_powered_on ) &&
global_settings.resume_index != -1 ) {
bool do_resume = false;
if ( global_settings.resume_index != -1 ) {
DEBUGF("Resume index %X offset %X\n",
global_settings.resume_index,
global_settings.resume_offset);
if (!ask_resume(just_powered_on) )
return;
#ifdef HAVE_ALARM_MOD
if ( rtc_check_alarm_started(true) ) {
rtc_enable_alarm(false);
do_resume = true;
}
#endif
/* always resume? */
if ( global_settings.resume || ! just_powered_on)
do_resume = true;
if (! do_resume) return;
if (playlist_resume() != -1)
{
playlist_start(global_settings.resume_index,

View file

@ -252,7 +252,6 @@ static bool update(void)
/* save resume data */
if ( id3 &&
global_settings.resume &&
global_settings.resume_offset != id3->offset ) {
if (!playlist_get_resume_info(&global_settings.resume_index))
@ -391,7 +390,7 @@ long wps_show(void)
/* if another thread paused audio, we are probably in car mode,
about to shut down. lets save the settings. */
if (paused && global_settings.resume) {
if (paused) {
settings_save();
#ifndef HAVE_RTC
ata_flush();
@ -544,12 +543,10 @@ long wps_show(void)
fade(0);
else
audio_pause();
if (global_settings.resume) {
settings_save();
settings_save();
#ifndef HAVE_RTC
ata_flush();
ata_flush();
#endif
}
}
break;

View file

@ -220,7 +220,8 @@ void button_init(void)
#endif /* CONFIG_KEYPAD */
queue_init(&button_queue);
lastbtn = 0;
button_read();
lastbtn = button_read();
tick_add_task(button_tick);
reset_poweroff_timer();