summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorChristi Scarborough <christi@coraline.org>2005-06-29 12:23:09 +0000
committerChristi Scarborough <christi@coraline.org>2005-06-29 12:23:09 +0000
commit9e8918b0866b249a55c06a16a243cdd3dcdad305 (patch)
tree954d2eab9141f0a9a0777f9ce9eceb15af1b569a /apps
parent1f45cce4262bde3f91844701085076892b4743f8 (diff)
downloadrockbox-9e8918b0866b249a55c06a16a243cdd3dcdad305.tar.gz
rockbox-9e8918b0866b249a55c06a16a243cdd3dcdad305.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/filetree.c12
-rw-r--r--apps/lang/english.lang12
-rw-r--r--apps/screens.c6
-rw-r--r--apps/settings.c2
-rw-r--r--apps/settings.h7
-rw-r--r--apps/settings_menu.c9
-rw-r--r--apps/tree.c105
-rw-r--r--apps/wps.c9
8 files changed, 29 insertions, 133 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 60443a163c..c7a2dbf071 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -447,13 +447,11 @@ int ft_enter(struct tree_context* c)
447 } 447 }
448 448
449 if ( play ) { 449 if ( play ) {
450 if ( global_settings.resume ) { 450 /* the resume_index must always be the index in the
451 /* the resume_index must always be the index in the 451 shuffled list in case shuffle is enabled */
452 shuffled list in case shuffle is enabled */ 452 global_settings.resume_index = start_index;
453 global_settings.resume_index = start_index; 453 global_settings.resume_offset = 0;
454 global_settings.resume_offset = 0; 454 settings_save();
455 settings_save();
456 }
457 455
458 start_wps = true; 456 start_wps = true;
459 } 457 }
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 3b068bf50d..91858fde4e 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -391,12 +391,6 @@ eng: "Is Full!"
391voice: "" 391voice: ""
392new: 392new:
393 393
394id: LANG_RESUME_ASK
395desc: question asked at the begining when resume is on
396eng: "Resume?"
397voice: ""
398new:
399
400id: LANG_RESUME_CONFIRM_PLAYER 394id: LANG_RESUME_CONFIRM_PLAYER
401desc: possible answers to resume question 395desc: possible answers to resume question
402eng: "(PLAY/STOP)" 396eng: "(PLAY/STOP)"
@@ -847,12 +841,6 @@ eng: "Dec"
847voice: "December" 841voice: "December"
848new: 842new:
849 843
850id: LANG_RESUME_SETTING_ASK_ONCE
851desc: in settings_menu
852eng: "Ask Once"
853voice: "Ask Once"
854new:
855
856id: LANG_BATTERY_DISPLAY 844id: LANG_BATTERY_DISPLAY
857desc: Battery type title 845desc: Battery type title
858eng: "Battery Display" 846eng: "Battery Display"
diff --git a/apps/screens.c b/apps/screens.c
index 04a32813d1..59ffd06c50 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -693,15 +693,15 @@ bool quick_screen(int context, int button)
693 break; 693 break;
694 694
695 case BUTTON_F3 | BUTTON_RIGHT: 695 case BUTTON_F3 | BUTTON_RIGHT:
696// case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT: 696 case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT:
697 global_settings.statusbar = !global_settings.statusbar; 697 global_settings.statusbar = !global_settings.statusbar;
698 used = true; 698 used = true;
699 break; 699 break;
700 700
701 case BUTTON_F3 | BUTTON_DOWN: 701 case BUTTON_F3 | BUTTON_DOWN:
702// case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT: 702 case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT:
703 case BUTTON_F3 | BUTTON_UP: 703 case BUTTON_F3 | BUTTON_UP:
704// case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT: 704 case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT:
705 global_settings.flip_display = !global_settings.flip_display; 705 global_settings.flip_display = !global_settings.flip_display;
706 button_set_flip(global_settings.flip_display); 706 button_set_flip(global_settings.flip_display);
707 lcd_set_flip(global_settings.flip_display); 707 lcd_set_flip(global_settings.flip_display);
diff --git a/apps/settings.c b/apps/settings.c
index 60e41fcfdd..d40223bd78 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -197,7 +197,7 @@ static const struct bit_entry rtc_bits[] =
197 "stereo,mono,custom,mono left,mono right,karaoke" }, 197 "stereo,mono,custom,mono left,mono right,karaoke" },
198 {8, S_O(stereo_width), 100, "stereo width", NULL}, 198 {8, S_O(stereo_width), 100, "stereo width", NULL},
199 /* playback */ 199 /* playback */
200 {2, S_O(resume), RESUME_ASK, "resume", "off,ask,ask once,on" }, 200 {2, S_O(resume), false, "resume", off_on },
201 {1, S_O(playlist_shuffle), false, "shuffle", off_on }, 201 {1, S_O(playlist_shuffle), false, "shuffle", off_on },
202 {16 | SIGNED, S_O(resume_index), -1, NULL, NULL }, 202 {16 | SIGNED, S_O(resume_index), -1, NULL, NULL },
203 {16 | SIGNED, S_O(resume_first_index), 0, NULL, NULL }, 203 {16 | SIGNED, S_O(resume_first_index), 0, NULL, NULL },
diff --git a/apps/settings.h b/apps/settings.h
index bb4f5fbf32..d630db7f35 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -78,11 +78,6 @@
78 78
79/* data structures */ 79/* data structures */
80 80
81#define RESUME_OFF 0
82#define RESUME_ASK 1
83#define RESUME_ASK_ONCE 2
84#define RESUME_ON 3
85
86#define BOOKMARK_NO 0 81#define BOOKMARK_NO 0
87#define BOOKMARK_YES 1 82#define BOOKMARK_YES 1
88#define BOOKMARK_ASK 2 83#define BOOKMARK_ASK 2
@@ -211,7 +206,7 @@ struct user_settings
211 206
212 /* resume settings */ 207 /* resume settings */
213 208
214 int resume; /* resume option: 0=off, 1=ask, 2=on */ 209 bool resume; /* resume option: 0=off, 1=on */
215 int resume_index; /* index in playlist (-1 for no active resume) */ 210 int resume_index; /* index in playlist (-1 for no active resume) */
216 int resume_first_index; /* index of first track in playlist */ 211 int resume_first_index; /* index of first track in playlist */
217 int resume_offset; /* byte offset in mp3 file */ 212 int resume_offset; /* byte offset in mp3 file */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index b10c7d32ab..5dcf66789f 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -656,14 +656,7 @@ static bool sort_dir(void)
656 656
657static bool resume(void) 657static bool resume(void)
658{ 658{
659 static const struct opt_items names[] = { 659 return set_bool( str(LANG_RESUME), &global_settings.resume);
660 { STR(LANG_SET_BOOL_NO) },
661 { STR(LANG_RESUME_SETTING_ASK) },
662 { STR(LANG_RESUME_SETTING_ASK_ONCE) },
663 { STR(LANG_SET_BOOL_YES) }
664 };
665 return set_option( str(LANG_RESUME), &global_settings.resume, INT,
666 names, 4, NULL );
667} 660}
668 661
669static bool autocreatebookmark(void) 662static bool autocreatebookmark(void)
diff --git a/apps/tree.c b/apps/tree.c
index 6d25203eac..6dcb52d1a4 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -430,92 +430,6 @@ static int showdir(void)
430 return tc.filesindir; 430 return tc.filesindir;
431} 431}
432 432
433static bool ask_resume(bool just_powered_on)
434{
435 int button;
436 bool stop = false;
437 static bool ignore_power = true;
438
439#ifdef HAVE_LCD_CHARCELLS
440 lcd_double_height(false);
441#endif
442
443#ifdef HAVE_ALARM_MOD
444 if ( rtc_check_alarm_started(true) ) {
445 rtc_enable_alarm(false);
446 return true;
447 }
448#endif
449
450 /* always resume? */
451 if ( global_settings.resume == RESUME_ON || ! just_powered_on)
452 return true;
453
454 lcd_clear_display();
455 lcd_puts(0,0,str(LANG_RESUME_ASK));
456#ifdef HAVE_LCD_CHARCELLS
457 status_draw(false);
458 lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER));
459#else
460 lcd_puts(0,1,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
461 lcd_puts(0,2,str(LANG_CANCEL_WITH_ANY_RECORDER));
462#endif
463 lcd_update();
464
465 while (!stop) {
466 button = button_get(true);
467 switch (button) {
468#ifdef TREE_RUN_PRE
469 case TREE_RUN_PRE: /* catch the press, not the release */
470#else
471 case TREE_RUN:
472#endif
473
474#ifdef TREE_RC_RUN_PRE
475 case TREE_RC_RUN_PRE: /* catch the press, not the release */
476#else
477#ifdef TREE_RC_RUN
478 case TREE_RC_RUN:
479#endif
480#endif
481 ignore_power = false;
482 /* Don't ignore the power button for subsequent calls */
483 return true;
484
485#ifdef TREE_POWER_BTN
486 /* Initially ignore the button which powers on the box. It
487 * might still be pressed since booting. */
488 case TREE_POWER_BTN:
489 case TREE_POWER_BTN | BUTTON_REPEAT:
490 if(!ignore_power)
491 stop = true;
492 break;
493
494 /* No longer ignore the power button after it was released */
495 case TREE_POWER_BTN | BUTTON_REL:
496 ignore_power = false;
497 break;
498#endif
499
500 /* Handle sys events, ignore button releases */
501 default:
502 if(default_event_handler(button) == SYS_USB_CONNECTED ||
503 (!IS_SYSEVENT(button) && !(button & BUTTON_REL)))
504 stop = true;
505 break;
506 }
507 }
508
509 if ( global_settings.resume == RESUME_ASK_ONCE && just_powered_on) {
510 global_settings.resume_index = -1;
511 settings_save();
512 }
513
514 ignore_power = false;
515 /* Don't ignore the power button for subsequent calls */
516 return false;
517}
518
519/* load tracks from specified directory to resume play */ 433/* load tracks from specified directory to resume play */
520void resume_directory(const char *dir) 434void resume_directory(const char *dir)
521{ 435{
@@ -549,15 +463,26 @@ void reload_directory(void)
549 463
550static void start_resume(bool just_powered_on) 464static void start_resume(bool just_powered_on)
551{ 465{
552 if ( ( global_settings.resume || ! just_powered_on ) && 466 bool do_resume = false;
553 global_settings.resume_index != -1 ) { 467
468 if ( global_settings.resume_index != -1 ) {
554 DEBUGF("Resume index %X offset %X\n", 469 DEBUGF("Resume index %X offset %X\n",
555 global_settings.resume_index, 470 global_settings.resume_index,
556 global_settings.resume_offset); 471 global_settings.resume_offset);
557 472
558 if (!ask_resume(just_powered_on) ) 473#ifdef HAVE_ALARM_MOD
559 return; 474 if ( rtc_check_alarm_started(true) ) {
475 rtc_enable_alarm(false);
476 do_resume = true;
477 }
478#endif
479
480 /* always resume? */
481 if ( global_settings.resume || ! just_powered_on)
482 do_resume = true;
560 483
484 if (! do_resume) return;
485
561 if (playlist_resume() != -1) 486 if (playlist_resume() != -1)
562 { 487 {
563 playlist_start(global_settings.resume_index, 488 playlist_start(global_settings.resume_index,
diff --git a/apps/wps.c b/apps/wps.c
index be0ad448dd..40c9194793 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -252,7 +252,6 @@ static bool update(void)
252 252
253 /* save resume data */ 253 /* save resume data */
254 if ( id3 && 254 if ( id3 &&
255 global_settings.resume &&
256 global_settings.resume_offset != id3->offset ) { 255 global_settings.resume_offset != id3->offset ) {
257 256
258 if (!playlist_get_resume_info(&global_settings.resume_index)) 257 if (!playlist_get_resume_info(&global_settings.resume_index))
@@ -391,7 +390,7 @@ long wps_show(void)
391 390
392 /* if another thread paused audio, we are probably in car mode, 391 /* if another thread paused audio, we are probably in car mode,
393 about to shut down. lets save the settings. */ 392 about to shut down. lets save the settings. */
394 if (paused && global_settings.resume) { 393 if (paused) {
395 settings_save(); 394 settings_save();
396#ifndef HAVE_RTC 395#ifndef HAVE_RTC
397 ata_flush(); 396 ata_flush();
@@ -544,12 +543,10 @@ long wps_show(void)
544 fade(0); 543 fade(0);
545 else 544 else
546 audio_pause(); 545 audio_pause();
547 if (global_settings.resume) { 546 settings_save();
548 settings_save();
549#ifndef HAVE_RTC 547#ifndef HAVE_RTC
550 ata_flush(); 548 ata_flush();
551#endif 549#endif
552 }
553 } 550 }
554 break; 551 break;
555 552