summaryrefslogtreecommitdiff
path: root/apps/gui/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps.c')
-rw-r--r--apps/gui/wps.c354
1 files changed, 172 insertions, 182 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index fe4bcf3213..8b74b0e02b 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -65,9 +65,6 @@
65#include "skin_engine/wps_internals.h" 65#include "skin_engine/wps_internals.h"
66#include "open_plugin.h" 66#include "open_plugin.h"
67 67
68#define RESTORE_WPS_INSTANTLY 0l
69#define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
70
71#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ 68#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
72 /* 3% of 30min file == 54s step size */ 69 /* 3% of 30min file == 54s step size */
73#define MIN_FF_REWIND_STEP 500 70#define MIN_FF_REWIND_STEP 500
@@ -148,14 +145,6 @@ void unpause_action(bool updatewps)
148 update_non_static(); 145 update_non_static();
149} 146}
150 147
151static bool update_onvol_change(enum screen_type screen)
152{
153 skin_update(WPS, screen, SKIN_REFRESH_NON_STATIC);
154
155 return false;
156}
157
158
159#ifdef HAVE_TOUCHSCREEN 148#ifdef HAVE_TOUCHSCREEN
160static int skintouch_to_wps(void) 149static int skintouch_to_wps(void)
161{ 150{
@@ -340,9 +329,9 @@ static bool ffwd_rew(int button, bool seek_from_end)
340 return usb; 329 return usb;
341} 330}
342 331
343#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
344static void gwps_caption_backlight(struct wps_state *state) 332static void gwps_caption_backlight(struct wps_state *state)
345{ 333{
334#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
346 if (state->id3) 335 if (state->id3)
347 { 336 {
348#ifdef HAVE_BACKLIGHT 337#ifdef HAVE_BACKLIGHT
@@ -379,9 +368,10 @@ static void gwps_caption_backlight(struct wps_state *state)
379 } 368 }
380#endif 369#endif
381 } 370 }
371#else
372 (void) state;
373#endif /* def HAVE_BACKLIGHT || def HAVE_REMOTE_LCD */
382} 374}
383#endif
384
385 375
386static void change_dir(int direction) 376static void change_dir(int direction)
387{ 377{
@@ -498,7 +488,6 @@ static void play_hop(int direction)
498 audio_ff_rewind(elapsed); 488 audio_ff_rewind(elapsed);
499} 489}
500 490
501
502#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 491#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
503/* 492/*
504 * If the user is unable to see the wps, because the display is deactivated, 493 * If the user is unable to see the wps, because the display is deactivated,
@@ -541,20 +530,30 @@ static void gwps_leave_wps(bool theme_enabled)
541#endif 530#endif
542} 531}
543 532
533static void restore_theme(void)
534{
535 FOR_NB_SCREENS(i)
536 {
537 struct gui_wps *gwps = skin_get_gwps(WPS, i);
538 struct screen *display = gwps->display;
539 display->scroll_stop();
540 viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL);
541 }
542}
543
544/* 544/*
545 * display the wps on entering or restoring */ 545 * display the wps on entering or restoring */
546static void gwps_enter_wps(bool theme_enabled) 546static void gwps_enter_wps(bool theme_enabled)
547{ 547{
548 struct gui_wps *gwps; 548 struct gui_wps *gwps;
549 struct screen *display; 549 struct screen *display;
550 if (theme_enabled)
551 restore_theme();
550 FOR_NB_SCREENS(i) 552 FOR_NB_SCREENS(i)
551 { 553 {
552 gwps = skin_get_gwps(WPS, i); 554 gwps = skin_get_gwps(WPS, i);
553 display = gwps->display; 555 display = gwps->display;
554 display->scroll_stop(); 556 display->scroll_stop();
555 if (theme_enabled)
556 viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL);
557
558 /* Update the values in the first (default) viewport - in case the user 557 /* Update the values in the first (default) viewport - in case the user
559 has modified the statusbar or colour settings */ 558 has modified the statusbar or colour settings */
560#if LCD_DEPTH > 1 559#if LCD_DEPTH > 1
@@ -607,6 +606,57 @@ void wps_do_playpause(bool updatewps)
607 } 606 }
608} 607}
609 608
609static long do_wps_exit(long action, bool bookmark)
610{
611 audio_pause();
612 update_non_static();
613 if (bookmark)
614 bookmark_autobookmark(true);
615 audio_stop();
616#ifdef AB_REPEAT_ENABLE
617 ab_reset_markers();
618#endif
619 gwps_leave_wps(true);
620#ifdef HAVE_RECORDING
621 if (action == ACTION_WPS_REC)
622 return GO_TO_RECSCREEN;
623#else
624 (void)action;
625#endif
626 if (global_settings.browse_current)
627 return GO_TO_PREVIOUS_BROWSER;
628 return GO_TO_PREVIOUS;
629}
630
631static long do_party_mode(long action)
632{
633 if (global_settings.party_mode)
634 {
635 switch (action)
636 {
637#ifdef ACTION_WPSAB_SINGLE
638 case ACTION_WPSAB_SINGLE:
639 if (!ab_repeat_mode_enabled())
640 break;
641 /* Note: currently all targets use ACTION_WPS_BROWSE
642 * if mapped to any of below actions this will cause problems */
643#endif
644 case ACTION_WPS_PLAY:
645 case ACTION_WPS_SEEKFWD:
646 case ACTION_WPS_SEEKBACK:
647 case ACTION_WPS_SKIPPREV:
648 case ACTION_WPS_SKIPNEXT:
649 case ACTION_WPS_ABSETB_NEXTDIR:
650 case ACTION_WPS_ABSETA_PREVDIR:
651 case ACTION_WPS_STOP:
652 return ACTION_NONE;
653 break;
654 default:
655 break;
656 }
657 }
658 return action;
659}
610 660
611/* The WPS can be left in two ways: 661/* The WPS can be left in two ways:
612 * a) call a function, which draws over the wps. In this case, the wps 662 * a) call a function, which draws over the wps. In this case, the wps
@@ -621,11 +671,10 @@ long gui_wps_show(void)
621{ 671{
622 long button = 0; 672 long button = 0;
623 bool restore = true; 673 bool restore = true;
624 long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */
625 bool exit = false; 674 bool exit = false;
626 bool bookmark = false; 675 bool bookmark = false;
627 bool update = false; 676 bool update = false;
628 bool vol_changed = false; 677 bool theme_enabled = true;
629 long last_left = 0, last_right = 0; 678 long last_left = 0, last_right = 0;
630 struct wps_state *state = get_wps_state(); 679 struct wps_state *state = get_wps_state();
631 680
@@ -634,12 +683,10 @@ long gui_wps_show(void)
634 ab_reset_markers(); 683 ab_reset_markers();
635#endif 684#endif
636 wps_state_init(); 685 wps_state_init();
637
638 while ( 1 ) 686 while ( 1 )
639 { 687 {
640 bool theme_enabled = true; 688 bool hotkey = false;
641 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; 689 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
642
643 /* did someone else (i.e power thread) change audio pause mode? */ 690 /* did someone else (i.e power thread) change audio pause mode? */
644 if (state->paused != audio_paused) { 691 if (state->paused != audio_paused) {
645 state->paused = audio_paused; 692 state->paused = audio_paused;
@@ -653,8 +700,53 @@ long gui_wps_show(void)
653#endif 700#endif
654 } 701 }
655 } 702 }
656 button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK, 703
657 restore ? 1 : HZ/5); 704 if (restore)
705 {
706 restore = false;
707#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
708 add_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook);
709#endif
710 /* we remove the update delay since it's not very usable in the wps,
711 * e.g. during volume changing or ffwd/rewind */
712 sb_skin_set_update_delay(0);
713 skin_request_full_update(WPS);
714 update = true;
715 gwps_enter_wps(theme_enabled);
716 theme_enabled = true;
717 }
718 else
719 {
720 gwps_caption_backlight(state);
721
722 FOR_NB_SCREENS(i)
723 {
724#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
725 /* currently, all remotes are readable without backlight
726 * so still update those */
727 if (lcd_active() || (i != SCREEN_MAIN))
728#endif
729 {
730 bool full_update = skin_do_full_update(WPS, i);
731 if (update || full_update)
732 {
733 skin_update(WPS, i, full_update ?
734 SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC);
735 }
736 }
737 }
738 update = false;
739 }
740
741 if (exit)
742 {
743 return do_wps_exit(button, bookmark);
744 }
745
746 if (button && !IS_SYSEVENT(button) )
747 storage_spin();
748
749 button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK, HZ/5);
658 750
659 /* Exit if audio has stopped playing. This happens e.g. at end of 751 /* Exit if audio has stopped playing. This happens e.g. at end of
660 playlist or if using the sleep timer. */ 752 playlist or if using the sleep timer. */
@@ -664,44 +756,39 @@ long gui_wps_show(void)
664 if (button == ACTION_TOUCHSCREEN) 756 if (button == ACTION_TOUCHSCREEN)
665 button = skintouch_to_wps(); 757 button = skintouch_to_wps();
666#endif 758#endif
759 button = do_party_mode(button); /* block select actions in party mode */
760
667/* The iPods/X5/M5 use a single button for the A-B mode markers, 761/* The iPods/X5/M5 use a single button for the A-B mode markers,
668 defined as ACTION_WPSAB_SINGLE in their config files. */ 762 defined as ACTION_WPSAB_SINGLE in their config files. */
669#ifdef ACTION_WPSAB_SINGLE 763#ifdef ACTION_WPSAB_SINGLE
670 if (!global_settings.party_mode && ab_repeat_mode_enabled()) 764 static int wps_ab_state = 0;
765 if (button == ACTION_WPSAB_SINGLE && ab_repeat_mode_enabled())
671 { 766 {
672 static int wps_ab_state = 0; 767 switch (wps_ab_state)
673 if (button == ACTION_WPSAB_SINGLE)
674 { 768 {
675 switch (wps_ab_state) 769 case 0: /* set the A spot */
676 { 770 button = ACTION_WPS_ABSETA_PREVDIR;
677 case 0: /* set the A spot */ 771 break;
678 button = ACTION_WPS_ABSETA_PREVDIR; 772 case 1: /* set the B spot */
679 break; 773 button = ACTION_WPS_ABSETB_NEXTDIR;
680 case 1: /* set the B spot */ 774 break;
681 button = ACTION_WPS_ABSETB_NEXTDIR; 775 case 2:
682 break; 776 button = ACTION_WPS_ABRESET;
683 case 2: 777 break;
684 button = ACTION_WPS_ABRESET;
685 break;
686 }
687 wps_ab_state = (wps_ab_state+1) % 3;
688 } 778 }
779 wps_ab_state = (wps_ab_state+1) % 3;
689 } 780 }
690#endif 781#endif /* def ACTION_WPSAB_SINGLE */
782
691 switch(button) 783 switch(button)
692 { 784 {
693#ifdef HAVE_HOTKEY 785#ifdef HAVE_HOTKEY
694 case ACTION_WPS_HOTKEY: 786 case ACTION_WPS_HOTKEY:
787 {
788 hotkey = true;
695 if (!global_settings.hotkey_wps) 789 if (!global_settings.hotkey_wps)
696 break; 790 break;
697 /* fall through */ 791 if (global_settings.hotkey_wps == HOTKEY_PLUGIN)
698#endif
699 case ACTION_WPS_CONTEXT:
700 {
701 bool hotkey = button == ACTION_WPS_HOTKEY;
702
703#ifdef HAVE_HOTKEY
704 if (hotkey && global_settings.hotkey_wps == HOTKEY_PLUGIN)
705 { 792 {
706 /* leave WPS without re-enabling theme */ 793 /* leave WPS without re-enabling theme */
707 theme_enabled = false; 794 theme_enabled = false;
@@ -711,39 +798,31 @@ long gui_wps_show(void)
711 if (!audio_status()) 798 if (!audio_status())
712 { 799 {
713 /* re-enable theme since we're returning to SBS */ 800 /* re-enable theme since we're returning to SBS */
714 FOR_NB_SCREENS(i) 801 gwps_leave_wps(true);
715 {
716 struct gui_wps *gwps = skin_get_gwps(WPS, i);
717#ifdef HAVE_BACKDROP_IMAGE
718 skin_backdrop_show(sb_get_backdrop(i));
719#endif
720 viewportmanager_theme_undo(i, skin_has_sbs(gwps));
721 }
722 return GO_TO_ROOT; 802 return GO_TO_ROOT;
723 } 803 }
804 restore = true;
805 break;
724 } 806 }
725 else 807 }
726#endif 808 /* fall through */
809#endif /* def HAVE_HOTKEY */
810 case ACTION_WPS_CONTEXT:
811 {
812 gwps_leave_wps(true);
813 int retval = onplay(state->id3->path,
814 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey);
815 /* if music is stopped in the context menu we want to exit the wps */
816 if (retval == ONPLAY_MAINMENU
817 || !audio_status())
818 return GO_TO_ROOT;
819 else if (retval == ONPLAY_PLAYLIST)
820 return GO_TO_PLAYLIST_VIEWER;
821 else if (retval == ONPLAY_PLUGIN)
727 { 822 {
728 gwps_leave_wps(true); 823 restore_theme();
729 int retval = onplay(state->id3->path, 824 theme_enabled = false;
730 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); 825 open_plugin_run(ID2P(LANG_OPEN_PLUGIN_SET_WPS_CONTEXT_PLUGIN));
731 /* if music is stopped in the context menu we want to exit the wps */
732 if (retval == ONPLAY_MAINMENU
733 || !audio_status())
734 return GO_TO_ROOT;
735 else if (retval == ONPLAY_PLAYLIST)
736 return GO_TO_PLAYLIST_VIEWER;
737 else if (retval == ONPLAY_PLUGIN)
738 {
739 FOR_NB_SCREENS(i)
740 {
741 struct gui_wps *gwps = skin_get_gwps(WPS, i);
742 viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL);
743 }
744 theme_enabled = false;
745 open_plugin_run(ID2P(LANG_OPEN_PLUGIN_SET_WPS_CONTEXT_PLUGIN));
746 }
747 } 826 }
748 827
749 restore = true; 828 restore = true;
@@ -757,24 +836,26 @@ long gui_wps_show(void)
757 836
758 /* play/pause */ 837 /* play/pause */
759 case ACTION_WPS_PLAY: 838 case ACTION_WPS_PLAY:
760 if (global_settings.party_mode)
761 break;
762 wps_do_playpause(true); 839 wps_do_playpause(true);
763 break; 840 break;
764 841
765 case ACTION_WPS_VOLUP: 842 case ACTION_WPS_VOLUP: /* fall through */
766 global_settings.volume += sound_steps(SOUND_VOLUME);
767 vol_changed = true;
768 break;
769 case ACTION_WPS_VOLDOWN: 843 case ACTION_WPS_VOLDOWN:
770 global_settings.volume -= sound_steps(SOUND_VOLUME); 844 if (button == ACTION_WPS_VOLUP)
771 vol_changed = true; 845 global_settings.volume += sound_steps(SOUND_VOLUME);
846 else
847 global_settings.volume -= sound_steps(SOUND_VOLUME);
848
849 setvol();
850 FOR_NB_SCREENS(i)
851 {
852 skin_update(WPS, i, SKIN_REFRESH_NON_STATIC);
853 }
854 update = false;
772 break; 855 break;
773 /* fast forward 856 /* fast forward
774 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ 857 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
775 case ACTION_WPS_SEEKFWD: 858 case ACTION_WPS_SEEKFWD:
776 if (global_settings.party_mode)
777 break;
778 if (current_tick -last_right < HZ) 859 if (current_tick -last_right < HZ)
779 { 860 {
780 if (state->id3->cuesheet) 861 if (state->id3->cuesheet)
@@ -793,9 +874,7 @@ long gui_wps_show(void)
793 /* fast rewind 874 /* fast rewind
794 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/ 875 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
795 case ACTION_WPS_SEEKBACK: 876 case ACTION_WPS_SEEKBACK:
796 if (global_settings.party_mode) 877 if (current_tick - last_left < HZ)
797 break;
798 if (current_tick -last_left < HZ)
799 { 878 {
800 if (state->id3->cuesheet) 879 if (state->id3->cuesheet)
801 { 880 {
@@ -824,8 +903,6 @@ long gui_wps_show(void)
824 903
825 /* prev / restart */ 904 /* prev / restart */
826 case ACTION_WPS_SKIPPREV: 905 case ACTION_WPS_SKIPPREV:
827 if (global_settings.party_mode)
828 break;
829 last_left = current_tick; 906 last_left = current_tick;
830#ifdef AB_REPEAT_ENABLE 907#ifdef AB_REPEAT_ENABLE
831 /* if we're in A/B repeat mode and the current position 908 /* if we're in A/B repeat mode and the current position
@@ -844,8 +921,6 @@ long gui_wps_show(void)
844 /* next 921 /* next
845 OR if skip length set, hop by predetermined amount. */ 922 OR if skip length set, hop by predetermined amount. */
846 case ACTION_WPS_SKIPNEXT: 923 case ACTION_WPS_SKIPNEXT:
847 if (global_settings.party_mode)
848 break;
849 last_right = current_tick; 924 last_right = current_tick;
850#ifdef AB_REPEAT_ENABLE 925#ifdef AB_REPEAT_ENABLE
851 /* if we're in A/B repeat mode and the current position is 926 /* if we're in A/B repeat mode and the current position is
@@ -866,8 +941,6 @@ long gui_wps_show(void)
866 /* next / prev directories */ 941 /* next / prev directories */
867 /* and set A-B markers if in a-b mode */ 942 /* and set A-B markers if in a-b mode */
868 case ACTION_WPS_ABSETB_NEXTDIR: 943 case ACTION_WPS_ABSETB_NEXTDIR:
869 if (global_settings.party_mode)
870 break;
871#if defined(AB_REPEAT_ENABLE) 944#if defined(AB_REPEAT_ENABLE)
872 if (ab_repeat_mode_enabled()) 945 if (ab_repeat_mode_enabled())
873 { 946 {
@@ -881,8 +954,6 @@ long gui_wps_show(void)
881 } 954 }
882 break; 955 break;
883 case ACTION_WPS_ABSETA_PREVDIR: 956 case ACTION_WPS_ABSETA_PREVDIR:
884 if (global_settings.party_mode)
885 break;
886#if defined(AB_REPEAT_ENABLE) 957#if defined(AB_REPEAT_ENABLE)
887 if (ab_repeat_mode_enabled()) 958 if (ab_repeat_mode_enabled())
888 ab_set_A_marker(state->id3->elapsed); 959 ab_set_A_marker(state->id3->elapsed);
@@ -915,7 +986,7 @@ long gui_wps_show(void)
915 restore = true; 986 restore = true;
916 } 987 }
917 988
918 if (enter_shortcuts_menu) 989 if (enter_shortcuts_menu) /* enter_shortcuts_menu */
919 { 990 {
920 global_status.last_screen = GO_TO_SHORTCUTMENU; 991 global_status.last_screen = GO_TO_SHORTCUTMENU;
921 int ret = do_shortcut_menu(NULL); 992 int ret = do_shortcut_menu(NULL);
@@ -952,8 +1023,6 @@ long gui_wps_show(void)
952 1023
953 /* stop and exit wps */ 1024 /* stop and exit wps */
954 case ACTION_WPS_STOP: 1025 case ACTION_WPS_STOP:
955 if (global_settings.party_mode)
956 break;
957 bookmark = true; 1026 bookmark = true;
958 exit = true; 1027 exit = true;
959 break; 1028 break;
@@ -1013,85 +1082,6 @@ long gui_wps_show(void)
1013 update = true; 1082 update = true;
1014 break; 1083 break;
1015 } 1084 }
1016
1017 if (vol_changed)
1018 {
1019 bool res = false;
1020 vol_changed = false;
1021 setvol();
1022 FOR_NB_SCREENS(i)
1023 {
1024 if(update_onvol_change(i))
1025 res = true;
1026 }
1027 if (res) {
1028 restore = true;
1029 restoretimer = RESTORE_WPS_NEXT_SECOND;
1030 }
1031 }
1032
1033
1034 if (restore &&
1035 ((restoretimer == RESTORE_WPS_INSTANTLY) ||
1036 TIME_AFTER(current_tick, restoretimer)))
1037 {
1038 restore = false;
1039 restoretimer = RESTORE_WPS_INSTANTLY;
1040#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1041 add_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook);
1042#endif
1043 /* we remove the update delay since it's not very usable in the wps,
1044 * e.g. during volume changing or ffwd/rewind */
1045 sb_skin_set_update_delay(0);
1046 skin_request_full_update(WPS);
1047 update = true;
1048 gwps_enter_wps(theme_enabled);
1049 }
1050 else
1051 {
1052#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1053 gwps_caption_backlight(state);
1054#endif
1055 FOR_NB_SCREENS(i)
1056 {
1057#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1058 /* currently, all remotes are readable without backlight
1059 * so still update those */
1060 if (lcd_active() || (i != SCREEN_MAIN))
1061#endif
1062 {
1063 bool full_update = skin_do_full_update(WPS, i);
1064 if (update || full_update)
1065 {
1066 skin_update(WPS, i, full_update ?
1067 SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC);
1068 }
1069 }
1070 }
1071 update = false;
1072 }
1073
1074 if (exit) {
1075 audio_pause();
1076 update_non_static();
1077 if (bookmark)
1078 bookmark_autobookmark(true);
1079 audio_stop();
1080#ifdef AB_REPEAT_ENABLE
1081 ab_reset_markers();
1082#endif
1083 gwps_leave_wps(true);
1084#ifdef HAVE_RECORDING
1085 if (button == ACTION_WPS_REC)
1086 return GO_TO_RECSCREEN;
1087#endif
1088 if (global_settings.browse_current)
1089 return GO_TO_PREVIOUS_BROWSER;
1090 return GO_TO_PREVIOUS;
1091 }
1092
1093 if (button && !IS_SYSEVENT(button) )
1094 storage_spin();
1095 } 1085 }
1096 return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ 1086 return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */
1097} 1087}