summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorStéphane Doyon <s.doyon@videotron.ca>2008-05-04 13:47:58 +0000
committerStéphane Doyon <s.doyon@videotron.ca>2008-05-04 13:47:58 +0000
commitab0f7e17ef225f2db908276f903d1354b7777618 (patch)
treed9928efee4632f6c9a853fc83b9200f218c837e8 /apps/gui
parent1ef5a836f8349b593945727a9905dbd9e1a3def0 (diff)
downloadrockbox-ab0f7e17ef225f2db908276f903d1354b7777618.tar.gz
rockbox-ab0f7e17ef225f2db908276f903d1354b7777618.zip
Accept FS#6188: study mode.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17355 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c34
-rw-r--r--apps/gui/gwps-common.h1
-rw-r--r--apps/gui/gwps.c127
3 files changed, 116 insertions, 46 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index ed4ca17b2a..bcb82df100 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -78,6 +78,7 @@ static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force)
78#define gui_wps_statusbar_draw(wps, force) \ 78#define gui_wps_statusbar_draw(wps, force) \
79 gui_statusbar_draw((wps)->statusbar, (force)) 79 gui_statusbar_draw((wps)->statusbar, (force))
80#endif 80#endif
81#include "pcmbuf.h"
81 82
82/* fades the volume */ 83/* fades the volume */
83void fade(bool fade_in) 84void fade(bool fade_in)
@@ -143,6 +144,39 @@ bool update_onvol_change(struct gui_wps * gwps)
143 return false; 144 return false;
144} 145}
145 146
147void play_hop(int direction)
148{
149 if(!wps_state.id3 || !wps_state.id3->length
150 || global_settings.study_hop_step == 0)
151 return;
152#define STEP ((unsigned)global_settings.study_hop_step *1000)
153 if(direction == 1
154 && wps_state.id3->length - wps_state.id3->elapsed < STEP+1000) {
155#if CONFIG_CODEC == SWCODEC
156 if(global_settings.beep)
157 pcmbuf_beep(1000, 150, 1500*global_settings.beep);
158#endif
159 return;
160 }
161 if((direction == -1 && wps_state.id3->elapsed < STEP))
162 wps_state.id3->elapsed = 0;
163 else
164 wps_state.id3->elapsed += STEP *direction;
165 if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) {
166#if (CONFIG_CODEC == SWCODEC)
167 audio_pre_ff_rewind();
168#else
169 audio_pause();
170#endif
171 }
172 audio_ff_rewind(wps_state.id3->elapsed);
173#if (CONFIG_CODEC != SWCODEC)
174 if (!wps_state.paused)
175 audio_resume();
176#endif
177#undef STEP
178}
179
146bool ffwd_rew(int button) 180bool ffwd_rew(int button)
147{ 181{
148 unsigned int step = 0; /* current ff/rewind step */ 182 unsigned int step = 0; /* current ff/rewind step */
diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h
index 76555c1c06..23080254f2 100644
--- a/apps/gui/gwps-common.h
+++ b/apps/gui/gwps-common.h
@@ -27,6 +27,7 @@ void fade(bool fade_in);
27bool gui_wps_display(void); 27bool gui_wps_display(void);
28bool update_onvol_change(struct gui_wps * gwps); 28bool update_onvol_change(struct gui_wps * gwps);
29bool update(struct gui_wps *gwps); 29bool update(struct gui_wps *gwps);
30void play_hop(int direction);
30bool ffwd_rew(int button); 31bool ffwd_rew(int button);
31void display_keylock_text(bool locked); 32void display_keylock_text(bool locked);
32 33
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 2e72813d73..28aea4945f 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -90,6 +90,51 @@ static void gui_wps_set_margin(struct gui_wps *gwps)
90} 90}
91#endif 91#endif
92 92
93static void prev_track(unsigned skip_thresh)
94{
95 if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) {
96 audio_prev();
97 }
98 else {
99 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
100 {
101 curr_cuesheet_skip(-1, wps_state.id3->elapsed);
102 return;
103 }
104
105 if (!wps_state.paused)
106#if (CONFIG_CODEC == SWCODEC)
107 audio_pre_ff_rewind();
108#else
109 audio_pause();
110#endif
111
112 audio_ff_rewind(0);
113
114#if (CONFIG_CODEC != SWCODEC)
115 if (!wps_state.paused)
116 audio_resume();
117#endif
118 }
119}
120
121void next_track(void)
122{
123 /* take care of if we're playing a cuesheet */
124 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
125 {
126 if (curr_cuesheet_skip(1, wps_state.id3->elapsed))
127 {
128 /* if the result was false, then we really want
129 to skip to the next track */
130 return;
131 }
132 }
133
134 audio_next();
135}
136
137
93long gui_wps_show(void) 138long gui_wps_show(void)
94{ 139{
95 long button = 0; 140 long button = 0;
@@ -335,11 +380,13 @@ long gui_wps_show(void)
335 } 380 }
336 break; 381 break;
337 /* fast forward 382 /* fast forward
338 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ 383 OR next dir if this is straight after ACTION_WPS_SKIPNEXT
384 OR in study mode, next track if straight after SKIPPREV. */
339 case ACTION_WPS_SEEKFWD: 385 case ACTION_WPS_SEEKFWD:
340 if (global_settings.party_mode) 386 if (global_settings.party_mode)
341 break; 387 break;
342 if (current_tick -last_right < HZ) 388 if (!global_settings.study_mode
389 && current_tick -last_right < HZ)
343 { 390 {
344 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) 391 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
345 { 392 {
@@ -350,15 +397,23 @@ long gui_wps_show(void)
350 audio_next_dir(); 397 audio_next_dir();
351 } 398 }
352 } 399 }
400 else if(global_settings.study_mode
401 && current_tick -last_left < HZ) {
402 next_track();
403 update_track = true;
404 }
353 else ffwd_rew(ACTION_WPS_SEEKFWD); 405 else ffwd_rew(ACTION_WPS_SEEKFWD);
354 last_right = 0; 406 last_right = last_left = 0;
355 break; 407 break;
356 /* fast rewind 408 /* fast rewind
357 OR prev dir if this is straight after ACTION_WPS_SKIPPREV */ 409 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,
410 OR in study mode, beg of track or prev track if this is
411 straight after SKIPPREV */
358 case ACTION_WPS_SEEKBACK: 412 case ACTION_WPS_SEEKBACK:
359 if (global_settings.party_mode) 413 if (global_settings.party_mode)
360 break; 414 break;
361 if (current_tick -last_left < HZ) 415 if (!global_settings.study_mode
416 && current_tick -last_left < HZ)
362 { 417 {
363 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) 418 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
364 { 419 {
@@ -375,8 +430,14 @@ long gui_wps_show(void)
375 audio_prev_dir(); 430 audio_prev_dir();
376 } 431 }
377 } 432 }
433 else if(global_settings.study_mode
434 && current_tick -last_right < HZ)
435 {
436 prev_track(3+global_settings.study_hop_step);
437 update_track = true;
438 }
378 else ffwd_rew(ACTION_WPS_SEEKBACK); 439 else ffwd_rew(ACTION_WPS_SEEKBACK);
379 last_left = 0; 440 last_left = last_right = 0;
380 break; 441 break;
381 442
382 /* prev / restart */ 443 /* prev / restart */
@@ -404,34 +465,13 @@ long gui_wps_show(void)
404 /* ...otherwise, do it normally */ 465 /* ...otherwise, do it normally */
405#endif 466#endif
406 467
407 if (!wps_state.id3 || (wps_state.id3->elapsed < 3*1000)) { 468 if(global_settings.study_mode)
408 audio_prev(); 469 play_hop(-1);
409 } 470 else prev_track(3);
410 else {
411
412 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
413 {
414 curr_cuesheet_skip(-1, wps_state.id3->elapsed);
415 break;
416 }
417
418 if (!wps_state.paused)
419#if (CONFIG_CODEC == SWCODEC)
420 audio_pre_ff_rewind();
421#else
422 audio_pause();
423#endif
424
425 audio_ff_rewind(0);
426
427#if (CONFIG_CODEC != SWCODEC)
428 if (!wps_state.paused)
429 audio_resume();
430#endif
431 }
432 break; 471 break;
433 472
434 /* next */ 473 /* next
474 OR in study mode, hop by predetermined amount. */
435 case ACTION_WPS_SKIPNEXT: 475 case ACTION_WPS_SKIPNEXT:
436 if (global_settings.party_mode) 476 if (global_settings.party_mode)
437 break; 477 break;
@@ -456,18 +496,9 @@ long gui_wps_show(void)
456 /* ...otherwise, do it normally */ 496 /* ...otherwise, do it normally */
457#endif 497#endif
458 498
459 /* take care of if we're playing a cuesheet */ 499 if(global_settings.study_mode)
460 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) 500 play_hop(1);
461 { 501 else next_track();
462 if (curr_cuesheet_skip(1, wps_state.id3->elapsed))
463 {
464 /* if the result was false, then we really want
465 to skip to the next track */
466 break;
467 }
468 }
469
470 audio_next();
471 break; 502 break;
472 /* next / prev directories */ 503 /* next / prev directories */
473 /* and set A-B markers if in a-b mode */ 504 /* and set A-B markers if in a-b mode */
@@ -484,7 +515,9 @@ long gui_wps_show(void)
484 else 515 else
485#endif 516#endif
486 { 517 {
487 audio_next_dir(); 518 if(global_settings.study_mode)
519 next_track();
520 else audio_next_dir();
488 } 521 }
489 break; 522 break;
490 case ACTION_WPS_ABSETA_PREVDIR: 523 case ACTION_WPS_ABSETA_PREVDIR:
@@ -496,7 +529,9 @@ long gui_wps_show(void)
496 else 529 else
497#endif 530#endif
498 { 531 {
499 audio_prev_dir(); 532 if(global_settings.study_mode)
533 prev_track(3);
534 else audio_prev_dir();
500 } 535 }
501 break; 536 break;
502 /* menu key functions */ 537 /* menu key functions */