From 32e27d93e883384cffb846998119ecdfd9b8fed7 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sun, 27 Jun 2004 01:05:40 +0000 Subject: The status bar now keeps track of the mpeg status, instead of having to call status_set_playmode() all the time git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4805 a1c6a512-1295-4272-9138-f99709370657 --- apps/bookmark.c | 1 - apps/onplay.c | 1 - apps/playlist_viewer.c | 3 --- apps/status.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- apps/status.h | 2 +- apps/tree.c | 4 ---- apps/wps-display.c | 1 - apps/wps.c | 25 +++++++------------------ 8 files changed, 49 insertions(+), 37 deletions(-) (limited to 'apps') 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) case BUTTON_PLAY: return bookmark_load(global_bookmark_file_name, true); case SYS_USB_CONNECTED: - status_set_playmode(STATUS_STOP); usb_screen(); #ifdef HAVE_LCD_CHARCELLS 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) if (global_settings.playlist_shuffle) playlist_shuffle(current_tick, -1); playlist_start(0,0); - status_set_playmode(STATUS_PLAY); status_draw(false); onplay_result = ONPLAY_START_PLAY; } 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) #else splash(HZ, true, str(LANG_END_PLAYLIST_RECORDER)); #endif - status_set_playmode(STATUS_STOP); goto exit; } @@ -988,7 +987,6 @@ bool playlist_viewer_ex(char* filename) /* Stop current track and play new track */ mpeg_stop(); playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0); - status_set_playmode(STATUS_PLAY); update_playlist(false); } else @@ -1001,7 +999,6 @@ bool playlist_viewer_ex(char* filename) goto exit; playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0); - status_set_playmode(STATUS_PLAY); /* Our playlist is now the current list */ 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 @@ #include "settings.h" #include "status.h" #include "mp3_playback.h" +#include "mpeg.h" #include "wps.h" #ifdef HAVE_RTC #include "timefuncs.h" @@ -35,7 +36,7 @@ #endif #include "powermgmt.h" -static enum playmode current_mode = STATUS_STOP; +static enum playmode ff_mode; static long switch_tick; static int battery_charge_step = 0; @@ -57,15 +58,47 @@ struct status_info { void status_init(void) { - status_set_playmode(STATUS_STOP); + ff_mode = 0; } -void status_set_playmode(enum playmode mode) +void status_set_ffmode(enum playmode mode) { - current_mode = mode; + ff_mode = mode; /* Either STATUS_FASTFORWARD or STATUS_FASTBACKWARD */ status_draw(false); } +int current_playmode(void) +{ + int mpeg_stat = mpeg_status(); + + /* ff_mode can be either STATUS_FASTFORWARD or STATUS_FASTBACKWARD + and that supercedes the other modes */ + if(ff_mode) + return ff_mode; + + if(mpeg_stat & MPEG_STATUS_PLAY) + { + if(mpeg_stat & MPEG_STATUS_PAUSE) + return STATUS_PAUSE; + else + return STATUS_PLAY; + } +#ifdef HAVE_MAS3587F + else + { + if(mpeg_stat & MPEG_STATUS_RECORD) + { + if(mpeg_stat & MPEG_STATUS_PAUSE) + return STATUS_RECORD_PAUSE; + else + return STATUS_RECORD; + } + } +#endif + + return STATUS_STOP; +} + #if defined(HAVE_LCD_CHARCELLS) static bool record = false; static bool audio = false; @@ -120,7 +153,7 @@ void status_draw(bool force_redraw) info.shuffle = global_settings.playlist_shuffle; info.keylock = keys_locked; info.repeat = global_settings.repeat_mode; - info.playmode = current_mode; + info.playmode = current_playmode(); /* only redraw if forced to, or info has changed */ if (force_redraw || @@ -181,7 +214,7 @@ void status_draw(bool force_redraw) statusbar_icon_battery(info.battlevel, plug_state); statusbar_icon_volume(info.volume); - statusbar_icon_play_state(current_mode + Icon_Play); + statusbar_icon_play_state(current_playmode() + Icon_Play); switch (info.repeat) { case REPEAT_ONE: statusbar_icon_play_mode(Icon_RepeatOne); @@ -218,8 +251,8 @@ void status_draw(bool force_redraw) lcd_icon(ICON_VOLUME_4, info.volume > 70); lcd_icon(ICON_VOLUME_5, info.volume > 90); - lcd_icon(ICON_PLAY, current_mode == STATUS_PLAY); - lcd_icon(ICON_PAUSE, current_mode == STATUS_PAUSE); + lcd_icon(ICON_PLAY, current_playmode() == STATUS_PLAY); + lcd_icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE); lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF); 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 }; void status_init(void); -void status_set_playmode(enum playmode mode); +void status_set_ffmode(enum playmode mode); #ifdef HAVE_LCD_BITMAP bool statusbar(bool state); void 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 @@ * KIND, either express or implied. * ****************************************************************************/ - #include #include #include @@ -1020,7 +1019,6 @@ static bool dirbrowse(char *root, int *dirfilter) case BUTTON_OFF: bookmark_autobookmark(); mpeg_stop(); - status_set_playmode(STATUS_STOP); status_draw(false); restore = true; break; @@ -1375,7 +1373,6 @@ static bool dirbrowse(char *root, int *dirfilter) break; case SYS_USB_CONNECTED: - status_set_playmode(STATUS_STOP); usb_screen(); reload_root = true; break; @@ -1732,6 +1729,5 @@ void bookmark_play(char *resume_file, int index, int offset, int seed) } } - status_set_playmode(STATUS_PLAY); start_wps=true; } 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, lcd_update(); #endif global_settings.resume_index = -1; - status_set_playmode(STATUS_STOP); status_draw(true); sleep(HZ); 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) break; case SYS_USB_CONNECTED: - status_set_playmode(STATUS_STOP); usb_screen(); return true; break; @@ -371,9 +370,9 @@ static bool ffwd_rew(int button) direction = (button & BUTTON_RIGHT) ? 1 : -1; if (direction > 0) - status_set_playmode(STATUS_FASTFORWARD); + status_set_ffmode(STATUS_FASTFORWARD); else - status_set_playmode(STATUS_FASTBACKWARD); + status_set_ffmode(STATUS_FASTBACKWARD); ff_rewind = true; @@ -387,8 +386,8 @@ static bool ffwd_rew(int button) } if (direction > 0) { - if ((id3->elapsed + ff_rewind_count) > id3->length) - ff_rewind_count = id3->length - id3->elapsed; + if ((id3->elapsed + ff_rewind_count) > id3->length) + ff_rewind_count = id3->length - id3->elapsed; } else { if ((int)(id3->elapsed + ff_rewind_count) < 0) @@ -411,12 +410,9 @@ static bool ffwd_rew(int button) mpeg_ff_rewind(id3->elapsed+ff_rewind_count); ff_rewind_count = 0; ff_rewind = false; - if (paused) - status_set_playmode(STATUS_PAUSE); - else { + status_set_ffmode(0); + if (!paused) mpeg_resume(); - status_set_playmode(STATUS_PLAY); - } #ifdef HAVE_LCD_CHARCELLS wps_display(id3, nid3); #endif @@ -424,7 +420,7 @@ static bool ffwd_rew(int button) break; case SYS_USB_CONNECTED: - status_set_playmode(STATUS_STOP); + status_set_ffmode(0); usb_screen(); usb = true; exit = true; @@ -516,7 +512,6 @@ static bool menu(void) break; case SYS_USB_CONNECTED: - status_set_playmode(STATUS_STOP); usb_screen(); keys_locked = false; return true; @@ -689,7 +684,6 @@ int wps_show(void) while ( 1 ) { bool mpeg_paused = (mpeg_status() & MPEG_STATUS_PAUSE)?true:false; - status_set_playmode(paused ? STATUS_PAUSE : STATUS_PLAY); /* did someone else (i.e power thread) change mpeg pause mode? */ if (paused != mpeg_paused) { @@ -807,7 +801,6 @@ int wps_show(void) /* pause may have been turned off by pitch screen */ if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) { paused = false; - status_set_playmode(STATUS_PLAY); } break; @@ -838,7 +831,6 @@ int wps_show(void) if ( paused ) { paused = false; - status_set_playmode(STATUS_PLAY); if ( global_settings.fade_on_stop ) fade(1); else @@ -847,7 +839,6 @@ int wps_show(void) else { paused = true; - status_set_playmode(STATUS_PAUSE); if ( global_settings.fade_on_stop ) fade(0); else @@ -980,7 +971,6 @@ int wps_show(void) break; case SYS_USB_CONNECTED: - status_set_playmode(STATUS_STOP); usb_screen(); return SYS_USB_CONNECTED; @@ -1014,7 +1004,6 @@ int wps_show(void) lcd_stop_scroll(); bookmark_autobookmark(); mpeg_stop(); - status_set_playmode(STATUS_STOP); /* Keys can be locked when exiting, so either unlock here or implement key locking in tree.c too */ -- cgit v1.2.3