diff options
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/apps/misc.c b/apps/misc.c index 08e699e781..88ec73e2d3 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -611,7 +611,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) | |||
611 | if(!charger_inserted()) | 611 | if(!charger_inserted()) |
612 | #endif | 612 | #endif |
613 | { | 613 | { |
614 | bool batt_crit = battery_level_critical(); | 614 | bool batt_safe = battery_level_safe(); |
615 | int audio_stat = audio_status(); | 615 | int audio_stat = audio_status(); |
616 | 616 | ||
617 | FOR_NB_SCREENS(i) | 617 | FOR_NB_SCREENS(i) |
@@ -619,15 +619,8 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) | |||
619 | #ifdef X5_BACKLIGHT_SHUTDOWN | 619 | #ifdef X5_BACKLIGHT_SHUTDOWN |
620 | x5_backlight_shutdown(); | 620 | x5_backlight_shutdown(); |
621 | #endif | 621 | #endif |
622 | if (!battery_level_safe()) | 622 | if (batt_safe) |
623 | gui_syncsplash(3*HZ, "%s %s", | 623 | { |
624 | str(LANG_WARNING_BATTERY_EMPTY), | ||
625 | str(LANG_SHUTTINGDOWN)); | ||
626 | else if (battery_level_critical()) | ||
627 | gui_syncsplash(3*HZ, "%s %s", | ||
628 | str(LANG_WARNING_BATTERY_LOW), | ||
629 | str(LANG_SHUTTINGDOWN)); | ||
630 | else { | ||
631 | #ifdef HAVE_TAGCACHE | 624 | #ifdef HAVE_TAGCACHE |
632 | if (!tagcache_prepare_shutdown()) | 625 | if (!tagcache_prepare_shutdown()) |
633 | { | 626 | { |
@@ -636,44 +629,60 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) | |||
636 | return false; | 629 | return false; |
637 | } | 630 | } |
638 | #endif | 631 | #endif |
639 | gui_syncsplash(0, str(LANG_SHUTTINGDOWN)); | 632 | if (battery_level() > 10) |
633 | gui_syncsplash(0, str(LANG_SHUTTINGDOWN)); | ||
634 | else | ||
635 | gui_syncsplash(0, "%s %s", | ||
636 | str(LANG_WARNING_BATTERY_LOW), | ||
637 | str(LANG_SHUTTINGDOWN)); | ||
638 | } | ||
639 | else | ||
640 | { | ||
641 | gui_syncsplash(0, "%s %s", | ||
642 | str(LANG_WARNING_BATTERY_EMPTY), | ||
643 | str(LANG_SHUTTINGDOWN)); | ||
640 | } | 644 | } |
641 | 645 | ||
642 | if (global_settings.fade_on_stop | 646 | if (global_settings.fade_on_stop |
643 | && (audio_stat & AUDIO_STATUS_PLAY)) | 647 | && (audio_stat & AUDIO_STATUS_PLAY)) |
644 | { | 648 | { |
645 | fade(0); | 649 | fade(0); |
646 | } | 650 | } |
647 | 651 | ||
648 | #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC | 652 | if (batt_safe) /* do not save on critical battery */ |
649 | if (!batt_crit && (audio_stat & AUDIO_STATUS_RECORD)) | ||
650 | { | 653 | { |
651 | audio_stop_recording(); | 654 | #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC |
652 | while(audio_status() & AUDIO_STATUS_RECORD) | 655 | if (audio_stat & AUDIO_STATUS_RECORD) |
653 | sleep(1); | 656 | audio_stop_recording(); |
654 | } | ||
655 | |||
656 | audio_close_recording(); | ||
657 | #endif | 657 | #endif |
658 | /* audio_stop_recording == audio_stop for HWCODEC */ | 658 | /* audio_stop_recording == audio_stop for HWCODEC */ |
659 | audio_stop(); | ||
659 | 660 | ||
660 | audio_stop(); | 661 | if (callback != NULL) |
661 | while (audio_status()) | 662 | callback(parameter); |
662 | sleep(1); | ||
663 | |||
664 | if (callback != NULL) | ||
665 | callback(parameter); | ||
666 | 663 | ||
667 | if (!batt_crit) /* do not save on critical battery */ | 664 | /* wait for audio_stop or audio_stop_recording to complete */ |
665 | while (audio_status()) | ||
666 | sleep(1); | ||
667 | |||
668 | #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC | ||
669 | audio_close_recording(); | ||
670 | #endif | ||
668 | system_flush(); | 671 | system_flush(); |
669 | #ifdef HAVE_EEPROM_SETTINGS | 672 | #ifdef HAVE_EEPROM_SETTINGS |
670 | if (firmware_settings.initialized) | 673 | if (firmware_settings.initialized) |
671 | { | 674 | { |
672 | firmware_settings.disk_clean = true; | 675 | firmware_settings.disk_clean = true; |
673 | firmware_settings.bl_version = 0; | 676 | firmware_settings.bl_version = 0; |
674 | eeprom_settings_store(); | 677 | eeprom_settings_store(); |
678 | } | ||
679 | #endif | ||
675 | } | 680 | } |
681 | #ifdef HAVE_DIRCACHE | ||
682 | else | ||
683 | dircache_disable(); | ||
676 | #endif | 684 | #endif |
685 | |||
677 | shutdown_hw(); | 686 | shutdown_hw(); |
678 | } | 687 | } |
679 | #endif | 688 | #endif |