summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-10-04 08:48:20 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-10-04 08:48:20 +0000
commita6d0abb602985189b304648532053d7e61d54171 (patch)
treeeb2a935fe1c3e8c0a8cd085544cf997c3ad0ea7d
parenta31bae655e92d85708a23b79ba27ace5fc2a185a (diff)
downloadrockbox-a6d0abb602985189b304648532053d7e61d54171.tar.gz
rockbox-a6d0abb602985189b304648532053d7e61d54171.zip
Repeat off/all/one toggle. By Hardeep Sidhu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2498 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang15
-rw-r--r--apps/playlist.c47
-rw-r--r--apps/screens.c35
-rw-r--r--apps/settings.c7
-rw-r--r--apps/settings.h5
-rw-r--r--apps/settings_menu.c23
-rw-r--r--apps/status.c2
-rw-r--r--apps/wps-display.c1
-rw-r--r--apps/wps.c9
-rw-r--r--firmware/mpeg.c23
10 files changed, 139 insertions, 28 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index b67277ba1c..5c7b0a3b86 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -869,3 +869,18 @@ id: LANG_BACKLIGHT_ON_WHEN_CHARGING
869desc: in display_settings_menu 869desc: in display_settings_menu
870eng: "Backlight on when charging" 870eng: "Backlight on when charging"
871new: 871new:
872
873id: LANG_REPEAT
874desc: in settings_menu
875eng: "Repeat"
876new:
877
878id: LANG_REPEAT_ALL
879desc: repeat playlist once all songs have completed
880eng: "All"
881new:
882
883id: LANG_REPEAT_ONE
884desc: repeat one song
885eng: "One"
886new:
diff --git a/apps/playlist.c b/apps/playlist.c
index b81aed8763..038e710829 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -66,15 +66,37 @@ int playlist_add(char *filename)
66 return 0; 66 return 0;
67} 67}
68 68
69int playlist_next(int steps) 69static int get_next_index(int steps)
70{ 70{
71 playlist.index = (playlist.index+steps) % playlist.amount; 71 int next_index = -1;
72 while ( playlist.index < 0 ) { 72
73 if ( global_settings.loop_playlist ) 73 switch (global_settings.repeat_mode)
74 playlist.index += playlist.amount; 74 {
75 else 75 case REPEAT_OFF:
76 playlist.index = 0; 76 next_index = playlist.index+steps;
77 if ((next_index < 0) || (next_index >= playlist.amount))
78 next_index = -1;
79 break;
80
81 case REPEAT_ONE:
82 next_index = playlist.index;
83 break;
84
85 case REPEAT_ALL:
86 default:
87 next_index = (playlist.index+steps) % playlist.amount;
88 while (next_index < 0)
89 next_index += playlist.amount;
90 break;
77 } 91 }
92
93 return next_index;
94}
95
96int playlist_next(int steps)
97{
98 playlist.index = get_next_index(steps);
99
78 return playlist.index; 100 return playlist.index;
79} 101}
80 102
@@ -93,14 +115,11 @@ char* playlist_peek(int steps)
93 /* prevent madness when all files are empty/bad */ 115 /* prevent madness when all files are empty/bad */
94 return NULL; 116 return NULL;
95 117
96 index = (playlist.index+steps) % playlist.amount; 118 index = get_next_index(steps);
97 while ( index < 0 ) { 119 if (index >= 0)
98 if ( global_settings.loop_playlist )
99 index += playlist.amount;
100 else
101 index = 0;
102 }
103 seek = playlist.indices[index]; 120 seek = playlist.indices[index];
121 else
122 return NULL;
104 123
105 if(playlist.in_ram) 124 if(playlist.in_ram)
106 { 125 {
diff --git a/apps/screens.c b/apps/screens.c
index 450fdfaaa4..81ed976a61 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -164,6 +164,7 @@ bool f2_screen(void)
164 bool used = false; 164 bool used = false;
165 int w, h; 165 int w, h;
166 char buf[32]; 166 char buf[32];
167 int oldrepeat = global_settings.repeat_mode;
167 168
168 /* Get the font height */ 169 /* Get the font height */
169 lcd_getstringsize("A",&w,&h); 170 lcd_getstringsize("A",&w,&h);
@@ -176,6 +177,7 @@ bool f2_screen(void)
176 177
177 lcd_clear_display(); 178 lcd_clear_display();
178 179
180 /* Shuffle mode */
179 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE)); 181 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE));
180 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE)); 182 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
181 lcd_putsxy(0, LCD_HEIGHT/2, 183 lcd_putsxy(0, LCD_HEIGHT/2,
@@ -184,6 +186,7 @@ bool f2_screen(void)
184 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], 186 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
185 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); 187 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
186 188
189 /* Directory Filter */
187 switch ( global_settings.dirfilter ) { 190 switch ( global_settings.dirfilter ) {
188 case SHOW_ALL: 191 case SHOW_ALL:
189 ptr = str(LANG_FILTER_ALL); 192 ptr = str(LANG_FILTER_ALL);
@@ -206,6 +209,28 @@ bool f2_screen(void)
206 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], 209 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
207 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); 210 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
208 211
212 /* Repeat Mode */
213 switch ( global_settings.repeat_mode ) {
214 case REPEAT_OFF:
215 ptr = str(LANG_OFF);
216 break;
217
218 case REPEAT_ALL:
219 ptr = str(LANG_REPEAT_ALL);
220 break;
221
222 case REPEAT_ONE:
223 ptr = str(LANG_REPEAT_ONE);
224 break;
225 }
226
227 lcd_getstringsize(str(LANG_REPEAT),&w,&h);
228 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, str(LANG_REPEAT));
229 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
230 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
231 lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
232 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
233
209 lcd_update(); 234 lcd_update();
210 235
211 switch (button_get(true)) { 236 switch (button_get(true)) {
@@ -229,6 +254,14 @@ bool f2_screen(void)
229 used = true; 254 used = true;
230 break; 255 break;
231 256
257 case BUTTON_RIGHT:
258 case BUTTON_F2 | BUTTON_RIGHT:
259 global_settings.repeat_mode++;
260 if ( global_settings.repeat_mode >= NUM_REPEAT_MODES )
261 global_settings.repeat_mode = 0;
262 used = true;
263 break;
264
232 case BUTTON_F2 | BUTTON_REL: 265 case BUTTON_F2 | BUTTON_REL:
233 if ( used ) 266 if ( used )
234 exit = true; 267 exit = true;
@@ -247,6 +280,8 @@ bool f2_screen(void)
247 280
248 settings_save(); 281 settings_save();
249 lcd_setfont(FONT_UI); 282 lcd_setfont(FONT_UI);
283 if ( oldrepeat != global_settings.repeat_mode )
284 mpeg_flush_and_reload_tracks();
250 285
251 return false; 286 return false;
252} 287}
diff --git a/apps/settings.c b/apps/settings.c
index cc09d60884..0ba72df110 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -91,6 +91,7 @@ offset abs
910x1c 0x30 <peak meter hold timeout (bit 0-4)> 910x1c 0x30 <peak meter hold timeout (bit 0-4)>
920x1d 0x31 <peak meter clip hold timeout (bit 0-4)> 920x1d 0x31 <peak meter clip hold timeout (bit 0-4)>
930x1e 0x32 <peak meter release step size> 930x1e 0x32 <peak meter release step size>
940x1f 0x33 <repeat mode>
94 95
95 <all unused space filled with 0xff> 96 <all unused space filled with 0xff>
96 97
@@ -313,6 +314,7 @@ int settings_save( void )
313 config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold; 314 config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold;
314 config_block[0x1d] = (unsigned char)global_settings.peak_meter_clip_hold; 315 config_block[0x1d] = (unsigned char)global_settings.peak_meter_clip_hold;
315 config_block[0x1e] = (unsigned char)global_settings.peak_meter_release; 316 config_block[0x1e] = (unsigned char)global_settings.peak_meter_release;
317 config_block[0x1f] = (unsigned char)global_settings.repeat_mode;
316 318
317 memcpy(&config_block[0xF8], &global_settings.resume_seed, 4); 319 memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
318 320
@@ -466,6 +468,9 @@ void settings_load(void)
466 if (config_block[0x1e] != 0xFF) 468 if (config_block[0x1e] != 0xFF)
467 global_settings.peak_meter_release = config_block[0x1e]; 469 global_settings.peak_meter_release = config_block[0x1e];
468 470
471 if (config_block[0x1f] != 0xFF)
472 global_settings.repeat_mode = config_block[0x1f];
473
469 memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); 474 memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
470 475
471 if (config_block[0x24] != 0xFF) 476 if (config_block[0x24] != 0xFF)
@@ -623,7 +628,7 @@ void settings_reset(void) {
623 global_settings.sort_case = false; 628 global_settings.sort_case = false;
624 global_settings.statusbar = true; 629 global_settings.statusbar = true;
625 global_settings.scrollbar = true; 630 global_settings.scrollbar = true;
626 global_settings.loop_playlist = true; 631 global_settings.repeat_mode = REPEAT_ALL;
627 global_settings.playlist_shuffle = false; 632 global_settings.playlist_shuffle = false;
628 global_settings.discharge = 0; 633 global_settings.discharge = 0;
629 global_settings.total_uptime = 0; 634 global_settings.total_uptime = 0;
diff --git a/apps/settings.h b/apps/settings.h
index 35c345aaad..b30d8aa744 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -77,7 +77,7 @@ struct user_settings
77 77
78 /* misc options */ 78 /* misc options */
79 79
80 int loop_playlist; /* do we return to top of playlist at end? */ 80 int repeat_mode; /* 0=off 1=repeat all 2=repeat one */
81 int dirfilter; /* 0=display all, 1=only supported, 2=only music */ 81 int dirfilter; /* 0=display all, 1=only supported, 2=only music */
82 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ 82 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
83 int scroll_speed; /* long texts scrolling speed: 1-30 */ 83 int scroll_speed; /* long texts scrolling speed: 1-30 */
@@ -151,6 +151,9 @@ extern char rockboxdir[];
151#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000 151#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000
152#define DEFAULT_FF_REWIND_ACCEL_SETTING 3 152#define DEFAULT_FF_REWIND_ACCEL_SETTING 3
153 153
154/* repeat mode options */
155enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
156
154/* dir filter options */ 157/* dir filter options */
155enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, NUM_FILTER_MODES }; 158enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, NUM_FILTER_MODES };
156 159
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 49e2fe431e..5d130e9cda 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -109,12 +109,28 @@ static bool peak_meter_menu(void)
109} 109}
110#endif 110#endif
111 111
112#ifndef HAVE_RECORDER_KEYPAD
113static bool shuffle(void) 112static bool shuffle(void)
114{ 113{
115 return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle ); 114 return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
116} 115}
117#endif 116
117static bool repeat_mode(void)
118{
119 bool result;
120 char* names[] = { str(LANG_OFF),
121 str(LANG_REPEAT_ALL),
122 str(LANG_REPEAT_ONE) };
123
124 int old_repeat = global_settings.repeat_mode;
125
126 result = set_option( str(LANG_REPEAT), &global_settings.repeat_mode,
127 names, 3, NULL );
128
129 if (old_repeat != global_settings.repeat_mode)
130 mpeg_flush_and_reload_tracks();
131
132 return result;
133}
118 134
119static bool play_selected(void) 135static bool play_selected(void)
120{ 136{
@@ -299,9 +315,8 @@ static bool playback_settings_menu(void)
299 bool result; 315 bool result;
300 316
301 struct menu_items items[] = { 317 struct menu_items items[] = {
302#ifndef HAVE_RECORDER_KEYPAD
303 { str(LANG_SHUFFLE), shuffle }, 318 { str(LANG_SHUFFLE), shuffle },
304#endif 319 { str(LANG_REPEAT), repeat_mode },
305 { str(LANG_PLAY_SELECTED), play_selected }, 320 { str(LANG_PLAY_SELECTED), play_selected },
306 { str(LANG_RESUME), resume }, 321 { str(LANG_RESUME), resume },
307 { str(LANG_FFRW_STEP), ff_rewind_min_step }, 322 { str(LANG_FFRW_STEP), ff_rewind_min_step },
diff --git a/apps/status.c b/apps/status.c
index 410728484e..1de837f28b 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -191,7 +191,7 @@ void status_draw(void)
191#endif 191#endif
192 statusbar_icon_volume(volume); 192 statusbar_icon_volume(volume);
193 statusbar_icon_play_state(current_mode + Icon_Play); 193 statusbar_icon_play_state(current_mode + Icon_Play);
194 if (global_settings.loop_playlist) 194 if (global_settings.repeat_mode != REPEAT_OFF)
195 statusbar_icon_play_mode(Icon_Repeat); 195 statusbar_icon_play_mode(Icon_Repeat);
196 else 196 else
197 statusbar_icon_play_mode(Icon_Normal); 197 statusbar_icon_play_mode(Icon_Normal);
diff --git a/apps/wps-display.c b/apps/wps-display.c
index 822b1875e0..3f94a09b9e 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -543,7 +543,6 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all)
543 if (!id3) 543 if (!id3)
544 { 544 {
545 lcd_stop_scroll(); 545 lcd_stop_scroll();
546 lcd_clear_display();
547 return false; 546 return false;
548 } 547 }
549 548
diff --git a/apps/wps.c b/apps/wps.c
index db4459c465..4f1fd504f3 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -411,7 +411,9 @@ static bool ffwd_rew(int button)
411 411
412static void update(void) 412static void update(void)
413{ 413{
414 if (mpeg_has_changed_track()) 414 bool track_changed = mpeg_has_changed_track();
415
416 if (track_changed)
415 { 417 {
416 lcd_stop_scroll(); 418 lcd_stop_scroll();
417 id3 = mpeg_current_track(); 419 id3 = mpeg_current_track();
@@ -435,6 +437,11 @@ static void update(void)
435 global_settings.resume_offset = id3->offset; 437 global_settings.resume_offset = id3->offset;
436 settings_save(); 438 settings_save();
437 } 439 }
440 else if ( !id3 && track_changed ) {
441 global_settings.resume_index = -1;
442 global_settings.resume_offset = -1;
443 settings_save();
444 }
438} 445}
439 446
440 447
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index ae9888869f..05f0a163c8 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -733,8 +733,11 @@ static void update_playlist(void)
733{ 733{
734 int index; 734 int index;
735 735
736 if (num_tracks_in_memory() > 0)
737 {
736 index = playlist_next(id3tags[tag_read_idx]->id3.index); 738 index = playlist_next(id3tags[tag_read_idx]->id3.index);
737 id3tags[tag_read_idx]->id3.index = index; 739 id3tags[tag_read_idx]->id3.index = index;
740 }
738} 741}
739 742
740static void track_change(void) 743static void track_change(void)
@@ -878,15 +881,15 @@ static void mpeg_thread(void)
878 881
879 case MPEG_NEXT: 882 case MPEG_NEXT:
880 DEBUGF("MPEG_NEXT\n"); 883 DEBUGF("MPEG_NEXT\n");
884 /* is next track in ram? */
885 if ( num_tracks_in_memory() > 1 ) {
886 int unplayed_space_left, unswapped_space_left;
887
881 /* stop the current stream */ 888 /* stop the current stream */
882 play_pending = false; 889 play_pending = false;
883 playing = false; 890 playing = false;
884 stop_dma(); 891 stop_dma();
885 892
886 /* is next track in ram? */
887 if ( num_tracks_in_memory() > 1 ) {
888 int unplayed_space_left, unswapped_space_left;
889
890 track_change(); 893 track_change();
891 mp3buf_read = id3tags[tag_read_idx]->mempos; 894 mp3buf_read = id3tags[tag_read_idx]->mempos;
892 init_dma(); 895 init_dma();
@@ -912,6 +915,14 @@ static void mpeg_thread(void)
912 } 915 }
913 } 916 }
914 else { 917 else {
918 if (!playlist_peek(1))
919 break;
920
921 /* stop the current stream */
922 play_pending = false;
923 playing = false;
924 stop_dma();
925
915 reset_mp3_buffer(); 926 reset_mp3_buffer();
916 remove_all_tags(); 927 remove_all_tags();
917 928
@@ -940,6 +951,8 @@ static void mpeg_thread(void)
940 case MPEG_PREV: { 951 case MPEG_PREV: {
941 int numtracks = num_tracks_in_memory(); 952 int numtracks = num_tracks_in_memory();
942 DEBUGF("MPEG_PREV\n"); 953 DEBUGF("MPEG_PREV\n");
954 if (!playlist_peek(-1))
955 break;
943 /* stop the current stream */ 956 /* stop the current stream */
944 play_pending = false; 957 play_pending = false;
945 playing = false; 958 playing = false;
@@ -1162,7 +1175,7 @@ static void mpeg_thread(void)
1162 case MPEG_SWAP_DATA: 1175 case MPEG_SWAP_DATA:
1163 free_space_left = get_unswapped_space(); 1176 free_space_left = get_unswapped_space();
1164 1177
1165 if(free_space_left == 0) 1178 if(free_space_left == 0 && !play_pending)
1166 break; 1179 break;
1167 1180
1168 amount_to_swap = MIN(MPEG_SWAP_CHUNKSIZE, free_space_left); 1181 amount_to_swap = MIN(MPEG_SWAP_CHUNKSIZE, free_space_left);