diff options
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 105 |
1 files changed, 15 insertions, 90 deletions
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 | ||
433 | static 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 */ |
520 | void resume_directory(const char *dir) | 434 | void resume_directory(const char *dir) |
521 | { | 435 | { |
@@ -549,15 +463,26 @@ void reload_directory(void) | |||
549 | 463 | ||
550 | static void start_resume(bool just_powered_on) | 464 | static 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, |