summaryrefslogtreecommitdiff
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
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
-rw-r--r--apps/gui/gwps-common.c34
-rw-r--r--apps/gui/gwps-common.h1
-rw-r--r--apps/gui/gwps.c127
-rw-r--r--apps/lang/english.lang56
-rw-r--r--apps/menus/playback_menu.c6
-rw-r--r--apps/onplay.c36
-rw-r--r--apps/playback.h4
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_list.c4
9 files changed, 222 insertions, 48 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 */
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index eb19bcef3b..dd1cfc37ba 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -11604,3 +11604,59 @@
11604 *: "Unknown" 11604 *: "Unknown"
11605 </voice> 11605 </voice>
11606</phrase> 11606</phrase>
11607<phrase>
11608 id: LANG_STUDY_MODE
11609 desc: playback settings menu
11610 user:
11611 <source>
11612 *: "Study Mode"
11613 </source>
11614 <dest>
11615 *: "Study Mode"
11616 </dest>
11617 <voice>
11618 *: "Study Mode"
11619 </voice>
11620</phrase>
11621<phrase>
11622 id: LANG_STUDY_HOP_STEP
11623 desc: playback settings menu
11624 user:
11625 <source>
11626 *: "Study Increment"
11627 </source>
11628 <dest>
11629 *: "Study Increment"
11630 </dest>
11631 <voice>
11632 *: "Study Increment"
11633 </voice>
11634</phrase>
11635<phrase>
11636 id: LANG_ENABLE_STUDY_MODE
11637 desc: WPS context menu
11638 user:
11639 <source>
11640 *: "Enable Study Mode"
11641 </source>
11642 <dest>
11643 *: "Enable Study Mode"
11644 </dest>
11645 <voice>
11646 *: "Enable Study Mode"
11647 </voice>
11648</phrase>
11649<phrase>
11650 id: LANG_DISABLE_STUDY_MODE
11651 desc: WPS context menu
11652 user:
11653 <source>
11654 *: "Disable Study Mode"
11655 </source>
11656 <dest>
11657 *: "Disable Study Mode"
11658 </dest>
11659 <voice>
11660 *: "Disable Study Mode"
11661 </voice>
11662</phrase>
diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c
index 390d5cc9a1..1dcb42b0c5 100644
--- a/apps/menus/playback_menu.c
+++ b/apps/menus/playback_menu.c
@@ -174,6 +174,11 @@ MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
174 &unplug_mode, &unplug_rw, &unplug_autoresume); 174 &unplug_mode, &unplug_rw, &unplug_autoresume);
175#endif 175#endif
176 176
177MENUITEM_SETTING(study_mode, &global_settings.study_mode, NULL);
178MENUITEM_SETTING(study_hop_step, &global_settings.study_hop_step, NULL);
179MAKE_MENU(study_mode_menu, ID2P(LANG_STUDY_MODE), 0, Icon_NOICON,
180 &study_mode, &study_hop_step);
181
177MAKE_MENU(playback_menu_item,ID2P(LANG_PLAYBACK),0, 182MAKE_MENU(playback_menu_item,ID2P(LANG_PLAYBACK),0,
178 Icon_Playback_menu, 183 Icon_Playback_menu,
179 &shuffle_item, &repeat_mode, &play_selected, 184 &shuffle_item, &repeat_mode, &play_selected,
@@ -194,6 +199,7 @@ MAKE_MENU(playback_menu_item,ID2P(LANG_PLAYBACK),0,
194#ifdef HAVE_HEADPHONE_DETECTION 199#ifdef HAVE_HEADPHONE_DETECTION
195 ,&unplug_menu 200 ,&unplug_menu
196#endif 201#endif
202 ,&study_mode_menu
197 ); 203 );
198 204
199static int playback_callback(int action,const struct menu_item_ex *this_item) 205static int playback_callback(int action,const struct menu_item_ex *this_item)
diff --git a/apps/onplay.c b/apps/onplay.c
index 45b18608e8..b65d2fe62f 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1011,6 +1011,41 @@ MENUITEM_FUNCTION(eq_browse_presets_item, 0, ID2P(LANG_EQUALIZER_BROWSE),
1011 eq_browse_presets, NULL, NULL, Icon_Audio); 1011 eq_browse_presets, NULL, NULL, Icon_Audio);
1012#endif 1012#endif
1013 1013
1014/* study mode setting toggling */
1015
1016static char* study_mode_toggle_get_name(int selected_item, void * data,
1017 char *buffer)
1018{
1019 (void)selected_item;
1020 (void)data;
1021 snprintf(buffer, MAX_PATH,
1022 global_settings.study_mode ? str(LANG_DISABLE_STUDY_MODE)
1023 : str(LANG_ENABLE_STUDY_MODE));
1024 return buffer;
1025}
1026
1027static int study_mode_toggle_speak_item(int selected_item, void * data)
1028{
1029 (void)selected_item;
1030 (void)data;
1031 talk_id(global_settings.study_mode ? LANG_DISABLE_STUDY_MODE
1032 : LANG_ENABLE_STUDY_MODE, false);
1033 return 0;
1034}
1035
1036static int toggle_study_mode(void * param)
1037{
1038 (void)param;
1039 global_settings.study_mode ^= 1;
1040 return 0;
1041}
1042
1043MENUITEM_FUNCTION_DYNTEXT(study_mode_toggle, 0,
1044 toggle_study_mode, NULL,
1045 study_mode_toggle_get_name,
1046 study_mode_toggle_speak_item,
1047 NULL, NULL, Icon_NOICON);
1048
1014/* CONTEXT_[TREE|ID3DB] items */ 1049/* CONTEXT_[TREE|ID3DB] items */
1015static int clipboard_callback(int action,const struct menu_item_ex *this_item); 1050static int clipboard_callback(int action,const struct menu_item_ex *this_item);
1016MENUITEM_FUNCTION(rename_file_item, 0, ID2P(LANG_RENAME), 1051MENUITEM_FUNCTION(rename_file_item, 0, ID2P(LANG_RENAME),
@@ -1152,6 +1187,7 @@ MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
1152#if CONFIG_CODEC == SWCODEC 1187#if CONFIG_CODEC == SWCODEC
1153 &eq_menu_graphical_item, &eq_browse_presets_item, 1188 &eq_menu_graphical_item, &eq_browse_presets_item,
1154#endif 1189#endif
1190 &study_mode_toggle,
1155 ); 1191 );
1156/* used when onplay() is not called in the CONTEXT_WPS context */ 1192/* used when onplay() is not called in the CONTEXT_WPS context */
1157MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), 1193MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
diff --git a/apps/playback.h b/apps/playback.h
index 103361c507..5e1eb9865b 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -49,8 +49,8 @@ int audio_current_aa_hid(void);
49extern void audio_next_dir(void); 49extern void audio_next_dir(void);
50extern void audio_prev_dir(void); 50extern void audio_prev_dir(void);
51#else 51#else
52#define audio_next_dir() 52#define audio_next_dir() ({ })
53#define audio_prev_dir() 53#define audio_prev_dir() ({ })
54#endif 54#endif
55 55
56#endif 56#endif
diff --git a/apps/settings.h b/apps/settings.h
index 7c32ba21e3..b21b404d9c 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -437,6 +437,8 @@ struct user_settings
437 bool play_selected; /* Plays selected file even in shuffle mode */ 437 bool play_selected; /* Plays selected file even in shuffle mode */
438 int ff_rewind_min_step; /* FF/Rewind minimum step size */ 438 int ff_rewind_min_step; /* FF/Rewind minimum step size */
439 int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */ 439 int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
440 bool study_mode; /* study mode enabled */
441 int study_hop_step; /* hop step in study mode, in seconds */
440 442
441#ifndef HAVE_FLASH_STORAGE 443#ifndef HAVE_FLASH_STORAGE
442 int disk_spindown; /* time until disk spindown, in seconds (0=off) */ 444 int disk_spindown; /* time until disk spindown, in seconds (0=off) */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 78b73af149..94210ffbca 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1163,6 +1163,10 @@ const struct settings_list settings[] = {
1163#endif 1163#endif
1164#endif 1164#endif
1165 OFFON_SETTING(0,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support", NULL), 1165 OFFON_SETTING(0,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support", NULL),
1166 OFFON_SETTING(0,study_mode,LANG_ENABLE_STUDY_MODE,false,"Study mode",
1167 NULL),
1168 INT_SETTING(0, study_hop_step, LANG_STUDY_HOP_STEP, 5, "Study hop step",
1169 UNIT_SEC, 0, 250, 1, NULL, NULL, NULL),
1166 CHOICE_SETTING(0, start_in_screen, LANG_START_SCREEN, 1, 1170 CHOICE_SETTING(0, start_in_screen, LANG_START_SCREEN, 1,
1167 "start in screen", "previous,root,files,db,wps,menu," 1171 "start in screen", "previous,root,files,db,wps,menu,"
1168#ifdef HAVE_RECORDING 1172#ifdef HAVE_RECORDING