summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/gwps.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 631c9dec15..87912dda30 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -67,6 +67,8 @@
67 67
68#define RESTORE_WPS_INSTANTLY 0l 68#define RESTORE_WPS_INSTANTLY 0l
69#define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) 69#define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
70/* in milliseconds */
71#define DEFAULT_SKIP_TRESH 3000ul
70 72
71static int wpsbars; 73static int wpsbars;
72/* currently only one wps_state is needed */ 74/* currently only one wps_state is needed */
@@ -77,10 +79,21 @@ static struct wps_data wps_datas[NB_SCREENS];
77/* initial setup of wps_data */ 79/* initial setup of wps_data */
78static void wps_state_init(void); 80static void wps_state_init(void);
79 81
80static void prev_track(unsigned skip_thresh) 82static void change_dir(int direction)
83{
84 if (global_settings.prevent_skip)
85 return;
86
87 if (direction < 0)
88 audio_prev_dir();
89 else if (direction > 0)
90 audio_next_dir();
91}
92
93static void prev_track(unsigned long skip_thresh)
81{ 94{
82 if (!global_settings.prevent_skip 95 if (!global_settings.prevent_skip
83 && (wps_state.id3->elapsed < skip_thresh*1000)) 96 && (wps_state.id3->elapsed < skip_thresh))
84 { 97 {
85 audio_prev(); 98 audio_prev();
86 return; 99 return;
@@ -129,36 +142,35 @@ static void next_track(void)
129 142
130static void play_hop(int direction) 143static void play_hop(int direction)
131{ 144{
132 unsigned step = ((unsigned)global_settings.skip_length*1000); 145 unsigned long step = ((unsigned long)global_settings.skip_length)*1000;
133 unsigned long *elapsed = &(wps_state.id3->elapsed); 146 unsigned long elapsed = wps_state.id3->elapsed;
134 bool prevent_skip = global_settings.prevent_skip; 147 unsigned long remaining = wps_state.id3->length - elapsed;
135 148
136 if (direction == 1 && wps_state.id3->length - *elapsed < step+1000) 149 if (!global_settings.prevent_skip
137 { 150 && (!step || (step >= remaining || (direction < 0 && elapsed < DEFAULT_SKIP_TRESH))))
138 if (!prevent_skip) 151 { /* Do normal track skipping */
152 if (direction > 0)
139 next_track(); 153 next_track();
154 else if (direction < 0)
155 prev_track(DEFAULT_SKIP_TRESH);
156 return;
157 }
158
159 if (direction == 1 && step >= remaining)
160 {
140#if CONFIG_CODEC == SWCODEC 161#if CONFIG_CODEC == SWCODEC
141 else 162 if(global_settings.beep)
142 { 163 pcmbuf_beep(1000, 150, 1500*global_settings.beep);
143 if(global_settings.beep)
144 pcmbuf_beep(1000, 150, 1500*global_settings.beep);
145 }
146#endif 164#endif
147 return; 165 return;
148 } 166 }
149 else if ((direction == -1 && *elapsed < step)) 167 else if ((direction == -1 && elapsed < step))
150 { 168 {
151 if (!prevent_skip) 169 elapsed = 0;
152 {
153 prev_track(3);
154 return;
155 }
156 else
157 *elapsed = 0;
158 } 170 }
159 else 171 else
160 { 172 {
161 *elapsed += step * direction; 173 elapsed += step * direction;
162 } 174 }
163 if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) 175 if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused)
164 { 176 {
@@ -168,7 +180,7 @@ static void play_hop(int direction)
168 audio_pause(); 180 audio_pause();
169#endif 181#endif
170 } 182 }
171 audio_ff_rewind(*elapsed); 183 audio_ff_rewind(wps_state.id3->elapsed = elapsed);
172#if (CONFIG_CODEC != SWCODEC) 184#if (CONFIG_CODEC != SWCODEC)
173 if (!wps_state.paused) 185 if (!wps_state.paused)
174 audio_resume(); 186 audio_resume();
@@ -441,8 +453,7 @@ long gui_wps_show(void)
441 case ACTION_WPS_SEEKFWD: 453 case ACTION_WPS_SEEKFWD:
442 if (global_settings.party_mode) 454 if (global_settings.party_mode)
443 break; 455 break;
444 if (global_settings.skip_length == 0 456 if (current_tick -last_right < HZ)
445 && current_tick -last_right < HZ)
446 { 457 {
447 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) 458 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
448 { 459 {
@@ -450,7 +461,7 @@ long gui_wps_show(void)
450 } 461 }
451 else 462 else
452 { 463 {
453 audio_next_dir(); 464 change_dir(1);
454 } 465 }
455 } 466 }
456 else 467 else
@@ -462,8 +473,7 @@ long gui_wps_show(void)
462 case ACTION_WPS_SEEKBACK: 473 case ACTION_WPS_SEEKBACK:
463 if (global_settings.party_mode) 474 if (global_settings.party_mode)
464 break; 475 break;
465 if (global_settings.skip_length == 0 476 if (current_tick -last_left < HZ)
466 && current_tick -last_left < HZ)
467 { 477 {
468 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) 478 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
469 { 479 {
@@ -477,7 +487,7 @@ long gui_wps_show(void)
477 } 487 }
478 else 488 else
479 { 489 {
480 audio_prev_dir(); 490 change_dir(-1);
481 } 491 }
482 } 492 }
483 else 493 else
@@ -491,7 +501,6 @@ long gui_wps_show(void)
491 break; 501 break;
492 last_left = current_tick; 502 last_left = current_tick;
493 update_track = true; 503 update_track = true;
494
495#ifdef AB_REPEAT_ENABLE 504#ifdef AB_REPEAT_ENABLE
496 /* if we're in A/B repeat mode and the current position 505 /* if we're in A/B repeat mode and the current position
497 is past the A marker, jump back to the A marker... */ 506 is past the A marker, jump back to the A marker... */
@@ -507,12 +516,10 @@ long gui_wps_show(void)
507#endif 516#endif
508 } 517 }
509 } 518 }
519 else
510 /* ...otherwise, do it normally */ 520 /* ...otherwise, do it normally */
511#endif 521#endif
512
513 if (global_settings.skip_length > 0)
514 play_hop(-1); 522 play_hop(-1);
515 else prev_track(3);
516 break; 523 break;
517 524
518 /* next 525 /* next
@@ -522,7 +529,6 @@ long gui_wps_show(void)
522 break; 529 break;
523 last_right = current_tick; 530 last_right = current_tick;
524 update_track = true; 531 update_track = true;
525
526#ifdef AB_REPEAT_ENABLE 532#ifdef AB_REPEAT_ENABLE
527 /* if we're in A/B repeat mode and the current position is 533 /* if we're in A/B repeat mode and the current position is
528 before the A marker, jump to the A marker... */ 534 before the A marker, jump to the A marker... */
@@ -538,12 +544,10 @@ long gui_wps_show(void)
538#endif 544#endif
539 } 545 }
540 } 546 }
547 else
541 /* ...otherwise, do it normally */ 548 /* ...otherwise, do it normally */
542#endif 549#endif
543
544 if (global_settings.skip_length > 0)
545 play_hop(1); 550 play_hop(1);
546 else next_track();
547 break; 551 break;
548 /* next / prev directories */ 552 /* next / prev directories */
549 /* and set A-B markers if in a-b mode */ 553 /* and set A-B markers if in a-b mode */
@@ -560,9 +564,7 @@ long gui_wps_show(void)
560 else 564 else
561#endif 565#endif
562 { 566 {
563 if (global_settings.skip_length > 0) 567 change_dir(1);
564 next_track();
565 else audio_next_dir();
566 } 568 }
567 break; 569 break;
568 case ACTION_WPS_ABSETA_PREVDIR: 570 case ACTION_WPS_ABSETA_PREVDIR:
@@ -574,9 +576,7 @@ long gui_wps_show(void)
574 else 576 else
575#endif 577#endif
576 { 578 {
577 if (global_settings.skip_length > 0) 579 change_dir(-1);
578 prev_track(3);
579 else audio_prev_dir();
580 } 580 }
581 break; 581 break;
582 /* menu key functions */ 582 /* menu key functions */