summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/bookmark.c1
-rw-r--r--apps/onplay.c1
-rw-r--r--apps/playlist_viewer.c3
-rw-r--r--apps/status.c49
-rw-r--r--apps/status.h2
-rw-r--r--apps/tree.c4
-rw-r--r--apps/wps-display.c1
-rw-r--r--apps/wps.c25
8 files changed, 49 insertions, 37 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index f052a6600c..5d717e4423 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -523,7 +523,6 @@ bool bookmark_autoload(char* file)
523 case BUTTON_PLAY: 523 case BUTTON_PLAY:
524 return bookmark_load(global_bookmark_file_name, true); 524 return bookmark_load(global_bookmark_file_name, true);
525 case SYS_USB_CONNECTED: 525 case SYS_USB_CONNECTED:
526 status_set_playmode(STATUS_STOP);
527 usb_screen(); 526 usb_screen();
528#ifdef HAVE_LCD_CHARCELLS 527#ifdef HAVE_LCD_CHARCELLS
529 status_set_param(true); 528 status_set_param(true);
diff --git a/apps/onplay.c b/apps/onplay.c
index 7873941af6..c54d9bce6f 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -138,7 +138,6 @@ static bool add_to_playlist(int position, bool queue)
138 if (global_settings.playlist_shuffle) 138 if (global_settings.playlist_shuffle)
139 playlist_shuffle(current_tick, -1); 139 playlist_shuffle(current_tick, -1);
140 playlist_start(0,0); 140 playlist_start(0,0);
141 status_set_playmode(STATUS_PLAY);
142 status_draw(false); 141 status_draw(false);
143 onplay_result = ONPLAY_START_PLAY; 142 onplay_result = ONPLAY_START_PLAY;
144 } 143 }
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 71059aa593..b7e81eeac6 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -856,7 +856,6 @@ bool playlist_viewer_ex(char* filename)
856#else 856#else
857 splash(HZ, true, str(LANG_END_PLAYLIST_RECORDER)); 857 splash(HZ, true, str(LANG_END_PLAYLIST_RECORDER));
858#endif 858#endif
859 status_set_playmode(STATUS_STOP);
860 goto exit; 859 goto exit;
861 } 860 }
862 861
@@ -988,7 +987,6 @@ bool playlist_viewer_ex(char* filename)
988 /* Stop current track and play new track */ 987 /* Stop current track and play new track */
989 mpeg_stop(); 988 mpeg_stop();
990 playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0); 989 playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0);
991 status_set_playmode(STATUS_PLAY);
992 update_playlist(false); 990 update_playlist(false);
993 } 991 }
994 else 992 else
@@ -1001,7 +999,6 @@ bool playlist_viewer_ex(char* filename)
1001 goto exit; 999 goto exit;
1002 1000
1003 playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0); 1001 playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0);
1004 status_set_playmode(STATUS_PLAY);
1005 1002
1006 /* Our playlist is now the current list */ 1003 /* Our playlist is now the current list */
1007 if (!initialize(NULL, true)) 1004 if (!initialize(NULL, true))
diff --git a/apps/status.c b/apps/status.c
index 5ff7a92e75..af6eaa4e2a 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -25,6 +25,7 @@
25#include "settings.h" 25#include "settings.h"
26#include "status.h" 26#include "status.h"
27#include "mp3_playback.h" 27#include "mp3_playback.h"
28#include "mpeg.h"
28#include "wps.h" 29#include "wps.h"
29#ifdef HAVE_RTC 30#ifdef HAVE_RTC
30#include "timefuncs.h" 31#include "timefuncs.h"
@@ -35,7 +36,7 @@
35#endif 36#endif
36#include "powermgmt.h" 37#include "powermgmt.h"
37 38
38static enum playmode current_mode = STATUS_STOP; 39static enum playmode ff_mode;
39 40
40static long switch_tick; 41static long switch_tick;
41static int battery_charge_step = 0; 42static int battery_charge_step = 0;
@@ -57,15 +58,47 @@ struct status_info {
57 58
58void status_init(void) 59void status_init(void)
59{ 60{
60 status_set_playmode(STATUS_STOP); 61 ff_mode = 0;
61} 62}
62 63
63void status_set_playmode(enum playmode mode) 64void status_set_ffmode(enum playmode mode)
64{ 65{
65 current_mode = mode; 66 ff_mode = mode; /* Either STATUS_FASTFORWARD or STATUS_FASTBACKWARD */
66 status_draw(false); 67 status_draw(false);
67} 68}
68 69
70int current_playmode(void)
71{
72 int mpeg_stat = mpeg_status();
73
74 /* ff_mode can be either STATUS_FASTFORWARD or STATUS_FASTBACKWARD
75 and that supercedes the other modes */
76 if(ff_mode)
77 return ff_mode;
78
79 if(mpeg_stat & MPEG_STATUS_PLAY)
80 {
81 if(mpeg_stat & MPEG_STATUS_PAUSE)
82 return STATUS_PAUSE;
83 else
84 return STATUS_PLAY;
85 }
86#ifdef HAVE_MAS3587F
87 else
88 {
89 if(mpeg_stat & MPEG_STATUS_RECORD)
90 {
91 if(mpeg_stat & MPEG_STATUS_PAUSE)
92 return STATUS_RECORD_PAUSE;
93 else
94 return STATUS_RECORD;
95 }
96 }
97#endif
98
99 return STATUS_STOP;
100}
101
69#if defined(HAVE_LCD_CHARCELLS) 102#if defined(HAVE_LCD_CHARCELLS)
70static bool record = false; 103static bool record = false;
71static bool audio = false; 104static bool audio = false;
@@ -120,7 +153,7 @@ void status_draw(bool force_redraw)
120 info.shuffle = global_settings.playlist_shuffle; 153 info.shuffle = global_settings.playlist_shuffle;
121 info.keylock = keys_locked; 154 info.keylock = keys_locked;
122 info.repeat = global_settings.repeat_mode; 155 info.repeat = global_settings.repeat_mode;
123 info.playmode = current_mode; 156 info.playmode = current_playmode();
124 157
125 /* only redraw if forced to, or info has changed */ 158 /* only redraw if forced to, or info has changed */
126 if (force_redraw || 159 if (force_redraw ||
@@ -181,7 +214,7 @@ void status_draw(bool force_redraw)
181 statusbar_icon_battery(info.battlevel, plug_state); 214 statusbar_icon_battery(info.battlevel, plug_state);
182 215
183 statusbar_icon_volume(info.volume); 216 statusbar_icon_volume(info.volume);
184 statusbar_icon_play_state(current_mode + Icon_Play); 217 statusbar_icon_play_state(current_playmode() + Icon_Play);
185 switch (info.repeat) { 218 switch (info.repeat) {
186 case REPEAT_ONE: 219 case REPEAT_ONE:
187 statusbar_icon_play_mode(Icon_RepeatOne); 220 statusbar_icon_play_mode(Icon_RepeatOne);
@@ -218,8 +251,8 @@ void status_draw(bool force_redraw)
218 lcd_icon(ICON_VOLUME_4, info.volume > 70); 251 lcd_icon(ICON_VOLUME_4, info.volume > 70);
219 lcd_icon(ICON_VOLUME_5, info.volume > 90); 252 lcd_icon(ICON_VOLUME_5, info.volume > 90);
220 253
221 lcd_icon(ICON_PLAY, current_mode == STATUS_PLAY); 254 lcd_icon(ICON_PLAY, current_playmode() == STATUS_PLAY);
222 lcd_icon(ICON_PAUSE, current_mode == STATUS_PAUSE); 255 lcd_icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE);
223 256
224 lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF); 257 lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF);
225 lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE); 258 lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE);
diff --git a/apps/status.h b/apps/status.h
index 3c501e019b..c812b9cb75 100644
--- a/apps/status.h
+++ b/apps/status.h
@@ -31,7 +31,7 @@ enum playmode
31}; 31};
32 32
33void status_init(void); 33void status_init(void);
34void status_set_playmode(enum playmode mode); 34void status_set_ffmode(enum playmode mode);
35#ifdef HAVE_LCD_BITMAP 35#ifdef HAVE_LCD_BITMAP
36bool statusbar(bool state); 36bool statusbar(bool state);
37void buttonbar_set(char* caption1, char* caption2, char* caption3); 37void buttonbar_set(char* caption1, char* caption2, char* caption3);
diff --git a/apps/tree.c b/apps/tree.c
index c68927be60..820974979b 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -16,7 +16,6 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19
20#include <stdio.h> 19#include <stdio.h>
21#include <string.h> 20#include <string.h>
22#include <stdlib.h> 21#include <stdlib.h>
@@ -1020,7 +1019,6 @@ static bool dirbrowse(char *root, int *dirfilter)
1020 case BUTTON_OFF: 1019 case BUTTON_OFF:
1021 bookmark_autobookmark(); 1020 bookmark_autobookmark();
1022 mpeg_stop(); 1021 mpeg_stop();
1023 status_set_playmode(STATUS_STOP);
1024 status_draw(false); 1022 status_draw(false);
1025 restore = true; 1023 restore = true;
1026 break; 1024 break;
@@ -1375,7 +1373,6 @@ static bool dirbrowse(char *root, int *dirfilter)
1375 break; 1373 break;
1376 1374
1377 case SYS_USB_CONNECTED: 1375 case SYS_USB_CONNECTED:
1378 status_set_playmode(STATUS_STOP);
1379 usb_screen(); 1376 usb_screen();
1380 reload_root = true; 1377 reload_root = true;
1381 break; 1378 break;
@@ -1732,6 +1729,5 @@ void bookmark_play(char *resume_file, int index, int offset, int seed)
1732 } 1729 }
1733 } 1730 }
1734 1731
1735 status_set_playmode(STATUS_PLAY);
1736 start_wps=true; 1732 start_wps=true;
1737} 1733}
diff --git a/apps/wps-display.c b/apps/wps-display.c
index 44955d0543..17e5fa5aca 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -1014,7 +1014,6 @@ bool wps_display(struct mp3entry* id3,
1014 lcd_update(); 1014 lcd_update();
1015#endif 1015#endif
1016 global_settings.resume_index = -1; 1016 global_settings.resume_index = -1;
1017 status_set_playmode(STATUS_STOP);
1018 status_draw(true); 1017 status_draw(true);
1019 sleep(HZ); 1018 sleep(HZ);
1020 return true; 1019 return true;
diff --git a/apps/wps.c b/apps/wps.c
index 0f393a0faf..8943a4d2fb 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -297,7 +297,6 @@ bool browse_id3(void)
297 break; 297 break;
298 298
299 case SYS_USB_CONNECTED: 299 case SYS_USB_CONNECTED:
300 status_set_playmode(STATUS_STOP);
301 usb_screen(); 300 usb_screen();
302 return true; 301 return true;
303 break; 302 break;
@@ -371,9 +370,9 @@ static bool ffwd_rew(int button)
371 direction = (button & BUTTON_RIGHT) ? 1 : -1; 370 direction = (button & BUTTON_RIGHT) ? 1 : -1;
372 371
373 if (direction > 0) 372 if (direction > 0)
374 status_set_playmode(STATUS_FASTFORWARD); 373 status_set_ffmode(STATUS_FASTFORWARD);
375 else 374 else
376 status_set_playmode(STATUS_FASTBACKWARD); 375 status_set_ffmode(STATUS_FASTBACKWARD);
377 376
378 ff_rewind = true; 377 ff_rewind = true;
379 378
@@ -387,8 +386,8 @@ static bool ffwd_rew(int button)
387 } 386 }
388 387
389 if (direction > 0) { 388 if (direction > 0) {
390 if ((id3->elapsed + ff_rewind_count) > id3->length) 389 if ((id3->elapsed + ff_rewind_count) > id3->length)
391 ff_rewind_count = id3->length - id3->elapsed; 390 ff_rewind_count = id3->length - id3->elapsed;
392 } 391 }
393 else { 392 else {
394 if ((int)(id3->elapsed + ff_rewind_count) < 0) 393 if ((int)(id3->elapsed + ff_rewind_count) < 0)
@@ -411,12 +410,9 @@ static bool ffwd_rew(int button)
411 mpeg_ff_rewind(id3->elapsed+ff_rewind_count); 410 mpeg_ff_rewind(id3->elapsed+ff_rewind_count);
412 ff_rewind_count = 0; 411 ff_rewind_count = 0;
413 ff_rewind = false; 412 ff_rewind = false;
414 if (paused) 413 status_set_ffmode(0);
415 status_set_playmode(STATUS_PAUSE); 414 if (!paused)
416 else {
417 mpeg_resume(); 415 mpeg_resume();
418 status_set_playmode(STATUS_PLAY);
419 }
420#ifdef HAVE_LCD_CHARCELLS 416#ifdef HAVE_LCD_CHARCELLS
421 wps_display(id3, nid3); 417 wps_display(id3, nid3);
422#endif 418#endif
@@ -424,7 +420,7 @@ static bool ffwd_rew(int button)
424 break; 420 break;
425 421
426 case SYS_USB_CONNECTED: 422 case SYS_USB_CONNECTED:
427 status_set_playmode(STATUS_STOP); 423 status_set_ffmode(0);
428 usb_screen(); 424 usb_screen();
429 usb = true; 425 usb = true;
430 exit = true; 426 exit = true;
@@ -516,7 +512,6 @@ static bool menu(void)
516 break; 512 break;
517 513
518 case SYS_USB_CONNECTED: 514 case SYS_USB_CONNECTED:
519 status_set_playmode(STATUS_STOP);
520 usb_screen(); 515 usb_screen();
521 keys_locked = false; 516 keys_locked = false;
522 return true; 517 return true;
@@ -689,7 +684,6 @@ int wps_show(void)
689 while ( 1 ) 684 while ( 1 )
690 { 685 {
691 bool mpeg_paused = (mpeg_status() & MPEG_STATUS_PAUSE)?true:false; 686 bool mpeg_paused = (mpeg_status() & MPEG_STATUS_PAUSE)?true:false;
692 status_set_playmode(paused ? STATUS_PAUSE : STATUS_PLAY);
693 687
694 /* did someone else (i.e power thread) change mpeg pause mode? */ 688 /* did someone else (i.e power thread) change mpeg pause mode? */
695 if (paused != mpeg_paused) { 689 if (paused != mpeg_paused) {
@@ -807,7 +801,6 @@ int wps_show(void)
807 /* pause may have been turned off by pitch screen */ 801 /* pause may have been turned off by pitch screen */
808 if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) { 802 if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) {
809 paused = false; 803 paused = false;
810 status_set_playmode(STATUS_PLAY);
811 } 804 }
812 break; 805 break;
813 806
@@ -838,7 +831,6 @@ int wps_show(void)
838 if ( paused ) 831 if ( paused )
839 { 832 {
840 paused = false; 833 paused = false;
841 status_set_playmode(STATUS_PLAY);
842 if ( global_settings.fade_on_stop ) 834 if ( global_settings.fade_on_stop )
843 fade(1); 835 fade(1);
844 else 836 else
@@ -847,7 +839,6 @@ int wps_show(void)
847 else 839 else
848 { 840 {
849 paused = true; 841 paused = true;
850 status_set_playmode(STATUS_PAUSE);
851 if ( global_settings.fade_on_stop ) 842 if ( global_settings.fade_on_stop )
852 fade(0); 843 fade(0);
853 else 844 else
@@ -980,7 +971,6 @@ int wps_show(void)
980 break; 971 break;
981 972
982 case SYS_USB_CONNECTED: 973 case SYS_USB_CONNECTED:
983 status_set_playmode(STATUS_STOP);
984 usb_screen(); 974 usb_screen();
985 return SYS_USB_CONNECTED; 975 return SYS_USB_CONNECTED;
986 976
@@ -1014,7 +1004,6 @@ int wps_show(void)
1014 lcd_stop_scroll(); 1004 lcd_stop_scroll();
1015 bookmark_autobookmark(); 1005 bookmark_autobookmark();
1016 mpeg_stop(); 1006 mpeg_stop();
1017 status_set_playmode(STATUS_STOP);
1018 1007
1019 /* Keys can be locked when exiting, so either unlock here 1008 /* Keys can be locked when exiting, so either unlock here
1020 or implement key locking in tree.c too */ 1009 or implement key locking in tree.c too */