forked from len0rd/rockbox
wps.c cleanup
No functional changes code clean-up consolidate pause_action, unpause_action_ do_wps_playpause Change-Id: Id5de9616c0ecd6d2b48d611667ef0589a50dcae6
This commit is contained in:
parent
d6e57e6e8e
commit
05336c9efb
2 changed files with 68 additions and 64 deletions
112
apps/gui/wps.c
112
apps/gui/wps.c
|
@ -116,31 +116,40 @@ static void update_non_static(void)
|
||||||
skin_update(WPS, i, SKIN_REFRESH_NON_STATIC);
|
skin_update(WPS, i, SKIN_REFRESH_NON_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pause_action(bool updatewps)
|
void wps_do_action(enum wps_do_action_type action, bool updatewps)
|
||||||
{
|
{
|
||||||
/* Do audio first, then update, unless skin were to use its local
|
if (action == WPS_PLAYPAUSE) /* toggle the status */
|
||||||
status in which case, reverse it */
|
{
|
||||||
|
struct wps_state *state = get_wps_state();
|
||||||
|
if (state->paused)
|
||||||
|
action = WPS_PLAY;
|
||||||
|
|
||||||
|
state->paused = !state->paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action == WPS_PLAY) /* unpause_action */
|
||||||
|
{
|
||||||
|
audio_resume();
|
||||||
|
}
|
||||||
|
else /* WPS_PAUSE pause_action */
|
||||||
|
{
|
||||||
audio_pause();
|
audio_pause();
|
||||||
|
|
||||||
if (updatewps)
|
|
||||||
update_non_static();
|
|
||||||
|
|
||||||
if (global_settings.pause_rewind) {
|
if (global_settings.pause_rewind) {
|
||||||
long newpos;
|
unsigned long elapsed = audio_current_track()->elapsed;
|
||||||
|
long newpos = elapsed - (global_settings.pause_rewind * 1000);
|
||||||
|
|
||||||
audio_pre_ff_rewind();
|
audio_pre_ff_rewind();
|
||||||
newpos = audio_current_track()->elapsed
|
|
||||||
- global_settings.pause_rewind * 1000;
|
|
||||||
audio_ff_rewind(newpos > 0 ? newpos : 0);
|
audio_ff_rewind(newpos > 0 ? newpos : 0);
|
||||||
}
|
}
|
||||||
}
|
if (action == WPS_PLAYPAUSE)
|
||||||
|
{
|
||||||
void unpause_action(bool updatewps)
|
settings_save();
|
||||||
{
|
#if !defined(HAVE_SW_POWEROFF)
|
||||||
/* Do audio first, then update, unless skin were to use its local
|
call_storage_idle_notifys(true); /* make sure resume info is saved */
|
||||||
status in which case, reverse it */
|
#endif
|
||||||
audio_resume();
|
}
|
||||||
|
}
|
||||||
if (updatewps)
|
if (updatewps)
|
||||||
update_non_static();
|
update_non_static();
|
||||||
}
|
}
|
||||||
|
@ -601,25 +610,6 @@ static void gwps_enter_wps(bool theme_enabled)
|
||||||
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
|
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wps_do_playpause(bool updatewps)
|
|
||||||
{
|
|
||||||
struct wps_state *state = get_wps_state();
|
|
||||||
if ( state->paused )
|
|
||||||
{
|
|
||||||
state->paused = false;
|
|
||||||
unpause_action(updatewps);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
state->paused = true;
|
|
||||||
pause_action(updatewps);
|
|
||||||
settings_save();
|
|
||||||
#if !defined(HAVE_SW_POWEROFF)
|
|
||||||
call_storage_idle_notifys(true); /* make sure resume info is saved */
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static long do_wps_exit(long action, bool bookmark)
|
static long do_wps_exit(long action, bool bookmark)
|
||||||
{
|
{
|
||||||
audio_pause();
|
audio_pause();
|
||||||
|
@ -672,6 +662,32 @@ static long do_party_mode(long action)
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int action_wpsab_single(long button)
|
||||||
|
{
|
||||||
|
/* The iPods/X5/M5 use a single button for the A-B mode markers,
|
||||||
|
defined as ACTION_WPSAB_SINGLE in their config files. */
|
||||||
|
#ifdef ACTION_WPSAB_SINGLE
|
||||||
|
static int wps_ab_state = 0;
|
||||||
|
if (button == ACTION_WPSAB_SINGLE && ab_repeat_mode_enabled())
|
||||||
|
{
|
||||||
|
switch (wps_ab_state)
|
||||||
|
{
|
||||||
|
case 0: /* set the A spot */
|
||||||
|
button = ACTION_WPS_ABSETA_PREVDIR;
|
||||||
|
break;
|
||||||
|
case 1: /* set the B spot */
|
||||||
|
button = ACTION_WPS_ABSETB_NEXTDIR;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
button = ACTION_WPS_ABRESET;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wps_ab_state = (wps_ab_state+1) % 3;
|
||||||
|
}
|
||||||
|
#endif /* def ACTION_WPSAB_SINGLE */
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
/* The WPS can be left in two ways:
|
/* The WPS can be left in two ways:
|
||||||
* a) call a function, which draws over the wps. In this case, the wps
|
* a) call a function, which draws over the wps. In this case, the wps
|
||||||
* will be still active (i.e. the below function didn't return)
|
* will be still active (i.e. the below function didn't return)
|
||||||
|
@ -770,27 +786,7 @@ long gui_wps_show(void)
|
||||||
#endif
|
#endif
|
||||||
button = do_party_mode(button); /* block select actions in party mode */
|
button = do_party_mode(button); /* block select actions in party mode */
|
||||||
|
|
||||||
/* The iPods/X5/M5 use a single button for the A-B mode markers,
|
button = action_wpsab_single(button); /* iPods/X5/M5 */
|
||||||
defined as ACTION_WPSAB_SINGLE in their config files. */
|
|
||||||
#ifdef ACTION_WPSAB_SINGLE
|
|
||||||
static int wps_ab_state = 0;
|
|
||||||
if (button == ACTION_WPSAB_SINGLE && ab_repeat_mode_enabled())
|
|
||||||
{
|
|
||||||
switch (wps_ab_state)
|
|
||||||
{
|
|
||||||
case 0: /* set the A spot */
|
|
||||||
button = ACTION_WPS_ABSETA_PREVDIR;
|
|
||||||
break;
|
|
||||||
case 1: /* set the B spot */
|
|
||||||
button = ACTION_WPS_ABSETB_NEXTDIR;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
button = ACTION_WPS_ABRESET;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wps_ab_state = (wps_ab_state+1) % 3;
|
|
||||||
}
|
|
||||||
#endif /* def ACTION_WPSAB_SINGLE */
|
|
||||||
|
|
||||||
switch(button)
|
switch(button)
|
||||||
{
|
{
|
||||||
|
@ -848,7 +844,7 @@ long gui_wps_show(void)
|
||||||
|
|
||||||
/* play/pause */
|
/* play/pause */
|
||||||
case ACTION_WPS_PLAY:
|
case ACTION_WPS_PLAY:
|
||||||
wps_do_playpause(true);
|
wps_do_action(WPS_PLAYPAUSE, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_WPS_VOLUP: /* fall through */
|
case ACTION_WPS_VOLUP: /* fall through */
|
||||||
|
|
|
@ -36,10 +36,18 @@ struct wps_state
|
||||||
|
|
||||||
long gui_wps_show(void);
|
long gui_wps_show(void);
|
||||||
|
|
||||||
|
enum wps_do_action_type
|
||||||
|
{
|
||||||
|
WPS_PLAY = AUDIO_STATUS_PLAY,
|
||||||
|
WPS_PAUSE = AUDIO_STATUS_PAUSE,
|
||||||
|
WPS_PLAYPAUSE, /* toggle */
|
||||||
|
};
|
||||||
|
|
||||||
|
void wps_do_action(enum wps_do_action_type, bool updatewps);
|
||||||
/* fade (if enabled) and pause the audio, optionally rewind a little */
|
/* fade (if enabled) and pause the audio, optionally rewind a little */
|
||||||
void pause_action(bool updatewps);
|
#define pause_action(update) wps_do_action(WPS_PAUSE, update)
|
||||||
void unpause_action(bool updatewps);
|
#define unpause_action(update) wps_do_action(WPS_PLAY, update)
|
||||||
void wps_do_playpause(bool updatewps);
|
#define wps_do_playpause(update) wps_do_action(WPS_PLAYPAUSE, update)
|
||||||
|
|
||||||
struct wps_state *get_wps_state(void);
|
struct wps_state *get_wps_state(void);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue