Index: apps/gui/gwps.c =================================================================== --- apps/gui/gwps.c (Revision 20636) +++ apps/gui/gwps.c (Arbeitskopie) @@ -67,9 +67,21 @@ #define RESTORE_WPS_INSTANTLY 0l #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) -/* in milliseconds */ -#define DEFAULT_SKIP_TRESH 3000ul +/* Threshold, in milliseconds, for the elapsed time. If the user presses + PREV and the elapsed time is less than this value, we jump to the start + of the previous track, otherwise to the start of the current track */ +#define SKIP_BACK_TRESHOLD 3000ul + +/* Constants for direction (prev/next). They are used for changing + position within a track or to go to another directory. They + are 1 and -1 (not just two different values) on purpose since + they are used to compute the new position within a track after hop */ +#define HOP_NEXT 1 +#define HOP_PREV (-1) +#define IS_HOP_NEXT(direction) ((direction)==HOP_NEXT) +#define IS_HOP_PREV(direction) ((direction)==HOP_PREV) + static int wpsbars; /* currently only one wps_state is needed */ struct wps_state wps_state; @@ -86,15 +98,15 @@ if (global_settings.prevent_skip) return; - if (direction < 0) + if (IS_HOP_PREV(direction)) audio_prev_dir(); - else if (direction > 0) + else if (IS_HOP_NEXT(direction)) audio_next_dir(); } -static void prev_track(unsigned long skip_thresh) +static void prev_track() { - if (wps_state.id3->elapsed < skip_thresh) + if (wps_state.id3->elapsed < SKIP_BACK_TRESHOLD) { audio_prev(); return; @@ -147,17 +159,18 @@ if (!global_settings.prevent_skip && (!step || - (direction > 0 && step >= remaining) || - (direction < 0 && elapsed < DEFAULT_SKIP_TRESH))) + (IS_HOP_NEXT(direction) && step > remaining) || + (IS_HOP_PREV(direction) && step > elapsed))) { /* Do normal track skipping */ - if (direction > 0) + if (IS_HOP_NEXT(direction)) next_track(); - else if (direction < 0) - prev_track(DEFAULT_SKIP_TRESH); + else if (IS_HOP_PREV(direction)) + prev_track(); return; } - if (direction == 1 && step >= remaining) + if ((IS_HOP_NEXT(direction) && step >= remaining) || + (IS_HOP_PREV(direction) && step >= elapsed)) { #if CONFIG_CODEC == SWCODEC if(global_settings.beep) @@ -165,10 +178,6 @@ #endif return; } - else if ((direction == -1 && elapsed < step)) - { - elapsed = 0; - } else { elapsed += step * direction; @@ -520,7 +529,7 @@ else /* ...otherwise, do it normally */ #endif - play_hop(-1); + play_hop(HOP_PREV); break; /* next @@ -548,7 +557,7 @@ else /* ...otherwise, do it normally */ #endif - play_hop(1); + play_hop(HOP_NEXT); break; /* next / prev directories */ /* and set A-B markers if in a-b mode */