1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Linus Nielsen Feltzing 2004-06-27 01:05:40 +00:00
parent 0690ac1966
commit 32e27d93e8
8 changed files with 49 additions and 37 deletions

View file

@ -523,7 +523,6 @@ bool bookmark_autoload(char* file)
case BUTTON_PLAY: case BUTTON_PLAY:
return bookmark_load(global_bookmark_file_name, true); return bookmark_load(global_bookmark_file_name, true);
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen(); usb_screen();
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
status_set_param(true); status_set_param(true);

View file

@ -138,7 +138,6 @@ static bool add_to_playlist(int position, bool queue)
if (global_settings.playlist_shuffle) if (global_settings.playlist_shuffle)
playlist_shuffle(current_tick, -1); playlist_shuffle(current_tick, -1);
playlist_start(0,0); playlist_start(0,0);
status_set_playmode(STATUS_PLAY);
status_draw(false); status_draw(false);
onplay_result = ONPLAY_START_PLAY; onplay_result = ONPLAY_START_PLAY;
} }

View file

@ -856,7 +856,6 @@ bool playlist_viewer_ex(char* filename)
#else #else
splash(HZ, true, str(LANG_END_PLAYLIST_RECORDER)); splash(HZ, true, str(LANG_END_PLAYLIST_RECORDER));
#endif #endif
status_set_playmode(STATUS_STOP);
goto exit; goto exit;
} }
@ -988,7 +987,6 @@ bool playlist_viewer_ex(char* filename)
/* Stop current track and play new track */ /* Stop current track and play new track */
mpeg_stop(); mpeg_stop();
playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0); playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0);
status_set_playmode(STATUS_PLAY);
update_playlist(false); update_playlist(false);
} }
else else
@ -1001,7 +999,6 @@ bool playlist_viewer_ex(char* filename)
goto exit; goto exit;
playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0); playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0);
status_set_playmode(STATUS_PLAY);
/* Our playlist is now the current list */ /* Our playlist is now the current list */
if (!initialize(NULL, true)) if (!initialize(NULL, true))

View file

@ -25,6 +25,7 @@
#include "settings.h" #include "settings.h"
#include "status.h" #include "status.h"
#include "mp3_playback.h" #include "mp3_playback.h"
#include "mpeg.h"
#include "wps.h" #include "wps.h"
#ifdef HAVE_RTC #ifdef HAVE_RTC
#include "timefuncs.h" #include "timefuncs.h"
@ -35,7 +36,7 @@
#endif #endif
#include "powermgmt.h" #include "powermgmt.h"
static enum playmode current_mode = STATUS_STOP; static enum playmode ff_mode;
static long switch_tick; static long switch_tick;
static int battery_charge_step = 0; static int battery_charge_step = 0;
@ -57,15 +58,47 @@ struct status_info {
void status_init(void) 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); 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) #if defined(HAVE_LCD_CHARCELLS)
static bool record = false; static bool record = false;
static bool audio = false; static bool audio = false;
@ -120,7 +153,7 @@ void status_draw(bool force_redraw)
info.shuffle = global_settings.playlist_shuffle; info.shuffle = global_settings.playlist_shuffle;
info.keylock = keys_locked; info.keylock = keys_locked;
info.repeat = global_settings.repeat_mode; info.repeat = global_settings.repeat_mode;
info.playmode = current_mode; info.playmode = current_playmode();
/* only redraw if forced to, or info has changed */ /* only redraw if forced to, or info has changed */
if (force_redraw || if (force_redraw ||
@ -181,7 +214,7 @@ void status_draw(bool force_redraw)
statusbar_icon_battery(info.battlevel, plug_state); statusbar_icon_battery(info.battlevel, plug_state);
statusbar_icon_volume(info.volume); statusbar_icon_volume(info.volume);
statusbar_icon_play_state(current_mode + Icon_Play); statusbar_icon_play_state(current_playmode() + Icon_Play);
switch (info.repeat) { switch (info.repeat) {
case REPEAT_ONE: case REPEAT_ONE:
statusbar_icon_play_mode(Icon_RepeatOne); 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_4, info.volume > 70);
lcd_icon(ICON_VOLUME_5, info.volume > 90); lcd_icon(ICON_VOLUME_5, info.volume > 90);
lcd_icon(ICON_PLAY, current_mode == STATUS_PLAY); lcd_icon(ICON_PLAY, current_playmode() == STATUS_PLAY);
lcd_icon(ICON_PAUSE, current_mode == STATUS_PAUSE); lcd_icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE);
lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF); lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF);
lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE); lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE);

View file

@ -31,7 +31,7 @@ enum playmode
}; };
void status_init(void); void status_init(void);
void status_set_playmode(enum playmode mode); void status_set_ffmode(enum playmode mode);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
bool statusbar(bool state); bool statusbar(bool state);
void buttonbar_set(char* caption1, char* caption2, char* caption3); void buttonbar_set(char* caption1, char* caption2, char* caption3);

View file

@ -16,7 +16,6 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -1020,7 +1019,6 @@ static bool dirbrowse(char *root, int *dirfilter)
case BUTTON_OFF: case BUTTON_OFF:
bookmark_autobookmark(); bookmark_autobookmark();
mpeg_stop(); mpeg_stop();
status_set_playmode(STATUS_STOP);
status_draw(false); status_draw(false);
restore = true; restore = true;
break; break;
@ -1375,7 +1373,6 @@ static bool dirbrowse(char *root, int *dirfilter)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen(); usb_screen();
reload_root = true; reload_root = true;
break; 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; start_wps=true;
} }

View file

@ -1014,7 +1014,6 @@ bool wps_display(struct mp3entry* id3,
lcd_update(); lcd_update();
#endif #endif
global_settings.resume_index = -1; global_settings.resume_index = -1;
status_set_playmode(STATUS_STOP);
status_draw(true); status_draw(true);
sleep(HZ); sleep(HZ);
return true; return true;

View file

@ -297,7 +297,6 @@ bool browse_id3(void)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen(); usb_screen();
return true; return true;
break; break;
@ -371,9 +370,9 @@ static bool ffwd_rew(int button)
direction = (button & BUTTON_RIGHT) ? 1 : -1; direction = (button & BUTTON_RIGHT) ? 1 : -1;
if (direction > 0) if (direction > 0)
status_set_playmode(STATUS_FASTFORWARD); status_set_ffmode(STATUS_FASTFORWARD);
else else
status_set_playmode(STATUS_FASTBACKWARD); status_set_ffmode(STATUS_FASTBACKWARD);
ff_rewind = true; ff_rewind = true;
@ -387,8 +386,8 @@ static bool ffwd_rew(int button)
} }
if (direction > 0) { if (direction > 0) {
if ((id3->elapsed + ff_rewind_count) > id3->length) if ((id3->elapsed + ff_rewind_count) > id3->length)
ff_rewind_count = id3->length - id3->elapsed; ff_rewind_count = id3->length - id3->elapsed;
} }
else { else {
if ((int)(id3->elapsed + ff_rewind_count) < 0) 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); mpeg_ff_rewind(id3->elapsed+ff_rewind_count);
ff_rewind_count = 0; ff_rewind_count = 0;
ff_rewind = false; ff_rewind = false;
if (paused) status_set_ffmode(0);
status_set_playmode(STATUS_PAUSE); if (!paused)
else {
mpeg_resume(); mpeg_resume();
status_set_playmode(STATUS_PLAY);
}
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
wps_display(id3, nid3); wps_display(id3, nid3);
#endif #endif
@ -424,7 +420,7 @@ static bool ffwd_rew(int button)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP); status_set_ffmode(0);
usb_screen(); usb_screen();
usb = true; usb = true;
exit = true; exit = true;
@ -516,7 +512,6 @@ static bool menu(void)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen(); usb_screen();
keys_locked = false; keys_locked = false;
return true; return true;
@ -689,7 +684,6 @@ int wps_show(void)
while ( 1 ) while ( 1 )
{ {
bool mpeg_paused = (mpeg_status() & MPEG_STATUS_PAUSE)?true:false; 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? */ /* did someone else (i.e power thread) change mpeg pause mode? */
if (paused != mpeg_paused) { if (paused != mpeg_paused) {
@ -807,7 +801,6 @@ int wps_show(void)
/* pause may have been turned off by pitch screen */ /* pause may have been turned off by pitch screen */
if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) { if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) {
paused = false; paused = false;
status_set_playmode(STATUS_PLAY);
} }
break; break;
@ -838,7 +831,6 @@ int wps_show(void)
if ( paused ) if ( paused )
{ {
paused = false; paused = false;
status_set_playmode(STATUS_PLAY);
if ( global_settings.fade_on_stop ) if ( global_settings.fade_on_stop )
fade(1); fade(1);
else else
@ -847,7 +839,6 @@ int wps_show(void)
else else
{ {
paused = true; paused = true;
status_set_playmode(STATUS_PAUSE);
if ( global_settings.fade_on_stop ) if ( global_settings.fade_on_stop )
fade(0); fade(0);
else else
@ -980,7 +971,6 @@ int wps_show(void)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen(); usb_screen();
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
@ -1014,7 +1004,6 @@ int wps_show(void)
lcd_stop_scroll(); lcd_stop_scroll();
bookmark_autobookmark(); bookmark_autobookmark();
mpeg_stop(); mpeg_stop();
status_set_playmode(STATUS_STOP);
/* Keys can be locked when exiting, so either unlock here /* Keys can be locked when exiting, so either unlock here
or implement key locking in tree.c too */ or implement key locking in tree.c too */