diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 414 |
1 files changed, 203 insertions, 211 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index 776ac6faab..94781988c7 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -96,27 +96,15 @@ volatile long thumbDelayTimer; | |||
96 | 96 | ||
97 | static struct configdata config[] = | 97 | static struct configdata config[] = |
98 | { | 98 | { |
99 | {TYPE_INT, 0, 2, &settings.showfps, "Show FPS", NULL, NULL}, | 99 | {TYPE_INT, 0, 2, &settings.showfps, "Show FPS", NULL, NULL}, |
100 | {TYPE_INT, 0, 2, &settings.limitfps, "Limit FPS", NULL, NULL}, | 100 | {TYPE_INT, 0, 2, &settings.limitfps, "Limit FPS", NULL, NULL}, |
101 | {TYPE_INT, 0, 2, &settings.skipframes, "Skip frames", NULL, NULL}, | 101 | {TYPE_INT, 0, 2, &settings.skipframes, "Skip frames", NULL, NULL}, |
102 | 102 | {TYPE_INT, 0, INT_MAX, &settings.resume_count, "Resume count", | |
103 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 103 | NULL, NULL}, |
104 | {TYPE_INT, 0, INT_MAX, &settings.displayoptions, "Display options", | ||
105 | NULL, NULL}, | ||
106 | #endif | ||
107 | }; | ||
108 | |||
109 | enum mpeg_menu_ids | ||
110 | { | ||
111 | __MPEG_OPTION_START = -1, | ||
112 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 104 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
113 | MPEG_OPTION_DISPLAY_SETTINGS, | 105 | {TYPE_INT, 0, INT_MAX, &settings.displayoptions, "Display options", |
106 | NULL, NULL}, | ||
114 | #endif | 107 | #endif |
115 | MPEG_OPTION_DISPLAY_FPS, | ||
116 | MPEG_OPTION_LIMIT_FPS, | ||
117 | MPEG_OPTION_SKIP_FRAMES, | ||
118 | MPEG_OPTION_CLEAR_RESUMES, | ||
119 | MPEG_OPTION_QUIT, | ||
120 | }; | 108 | }; |
121 | 109 | ||
122 | static const struct opt_items noyes[2] = { | 110 | static const struct opt_items noyes[2] = { |
@@ -124,29 +112,65 @@ static const struct opt_items noyes[2] = { | |||
124 | { "Yes", -1 }, | 112 | { "Yes", -1 }, |
125 | }; | 113 | }; |
126 | 114 | ||
127 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | ||
128 | static bool set_option_dithering(void) | ||
129 | { | ||
130 | int val = (settings.displayoptions & LCD_YUV_DITHER) ? 1 : 0; | ||
131 | rb->set_option("Dithering", &val, INT, noyes, 2, NULL); | ||
132 | settings.displayoptions = (settings.displayoptions & ~LCD_YUV_DITHER) | ||
133 | | ((val != 0) ? LCD_YUV_DITHER : 0); | ||
134 | rb->lcd_yuv_set_options(settings.displayoptions); | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | static void display_options(void) | 115 | static void display_options(void) |
139 | { | 116 | { |
117 | int result; | ||
118 | int menu_id; | ||
119 | int options_quit = 0; | ||
120 | |||
140 | static const struct menu_item items[] = { | 121 | static const struct menu_item items[] = { |
141 | { "Dithering", set_option_dithering }, | 122 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
123 | [MPEG_OPTION_DITHERING] = | ||
124 | { "Dithering", NULL }, | ||
125 | #endif /* #ifdef TOSHIBA_GIGABEAT_F */ | ||
126 | [MPEG_OPTION_DISPLAY_FPS] = | ||
127 | { "Display FPS", NULL }, | ||
128 | [MPEG_OPTION_LIMIT_FPS] = | ||
129 | { "Limit FPS", NULL }, | ||
130 | [MPEG_OPTION_SKIP_FRAMES] = | ||
131 | { "Skip frames", NULL }, | ||
142 | }; | 132 | }; |
143 | 133 | ||
144 | int m = menu_init(rb, items, ARRAYLEN(items), | 134 | menu_id = menu_init(rb, items, ARRAYLEN(items), |
145 | NULL, NULL, NULL, NULL); | 135 | NULL, NULL, NULL, NULL); |
146 | menu_run(m); | 136 | |
147 | menu_exit(m); | 137 | rb->button_clear_queue(); |
148 | } | 138 | |
139 | while(options_quit == 0) | ||
140 | { | ||
141 | result = menu_show(menu_id); | ||
142 | |||
143 | switch (result) | ||
144 | { | ||
145 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | ||
146 | case MPEG_OPTION_DITHERING: | ||
147 | result = (settings.displayoptions & LCD_YUV_DITHER) ? 1 : 0; | ||
148 | rb->set_option("Dithering", &result, INT, noyes, 2, NULL); | ||
149 | settings.displayoptions = (settings.displayoptions & ~LCD_YUV_DITHER) | ||
150 | | ((result != 0) ? LCD_YUV_DITHER : 0); | ||
151 | rb->lcd_yuv_set_options(settings.displayoptions); | ||
152 | break; | ||
149 | #endif /* #ifdef TOSHIBA_GIGABEAT_F */ | 153 | #endif /* #ifdef TOSHIBA_GIGABEAT_F */ |
154 | case MPEG_OPTION_DISPLAY_FPS: | ||
155 | rb->set_option("Display FPS",&settings.showfps,INT, | ||
156 | noyes, 2, NULL); | ||
157 | break; | ||
158 | case MPEG_OPTION_LIMIT_FPS: | ||
159 | rb->set_option("Limit FPS",&settings.limitfps,INT, | ||
160 | noyes, 2, NULL); | ||
161 | break; | ||
162 | case MPEG_OPTION_SKIP_FRAMES: | ||
163 | rb->set_option("Skip frames",&settings.skipframes,INT, | ||
164 | noyes, 2, NULL); | ||
165 | break; | ||
166 | default: | ||
167 | options_quit=1; | ||
168 | break; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | menu_exit(menu_id); | ||
173 | } | ||
150 | 174 | ||
151 | void draw_slider(int slider_ypos, int max_val, int current_val) | 175 | void draw_slider(int slider_ypos, int max_val, int current_val) |
152 | { | 176 | { |
@@ -181,18 +205,18 @@ void draw_slider(int slider_ypos, int max_val, int current_val) | |||
181 | 205 | ||
182 | int get_start_time(int play_time, int in_file) | 206 | int get_start_time(int play_time, int in_file) |
183 | { | 207 | { |
184 | int quit = 0; | 208 | int seek_quit = 0; |
185 | int button = 0; | 209 | int button = 0; |
186 | int resume_time = settings.resume_time; | 210 | int resume_time = settings.resume_time; |
187 | int slider_ypos = LCD_HEIGHT-45; | 211 | int slider_ypos = LCD_HEIGHT-45; |
188 | int seek_rtn; | 212 | int seek_return; |
189 | 213 | ||
190 | slider_state = state0; | 214 | slider_state = state0; |
191 | thumbDelayTimer = *(rb->current_tick); | 215 | thumbDelayTimer = *(rb->current_tick); |
192 | rb->lcd_clear_display(); | 216 | rb->lcd_clear_display(); |
193 | rb->lcd_update(); | 217 | rb->lcd_update(); |
194 | 218 | ||
195 | while(quit == 0) | 219 | while(seek_quit == 0) |
196 | { | 220 | { |
197 | button = rb->button_get(false); | 221 | button = rb->button_get(false); |
198 | switch (button) | 222 | switch (button) |
@@ -200,172 +224,168 @@ int get_start_time(int play_time, int in_file) | |||
200 | #if (CONFIG_KEYPAD == GIGABEAT_PAD) || \ | 224 | #if (CONFIG_KEYPAD == GIGABEAT_PAD) || \ |
201 | (CONFIG_KEYPAD == SANSA_E200_PAD) || \ | 225 | (CONFIG_KEYPAD == SANSA_E200_PAD) || \ |
202 | (CONFIG_KEYPAD == SANSA_C200_PAD) | 226 | (CONFIG_KEYPAD == SANSA_C200_PAD) |
203 | case MPEG_DOWN: | 227 | case MPEG_DOWN: |
204 | case MPEG_DOWN | BUTTON_REPEAT: | 228 | case MPEG_DOWN | BUTTON_REPEAT: |
205 | if ((resume_time -= 20) < 0) | 229 | if ((resume_time -= 20) < 0) |
206 | resume_time = 0; | 230 | resume_time = 0; |
207 | slider_state = state0; | 231 | slider_state = state0; |
208 | thumbDelayTimer = *(rb->current_tick); | 232 | thumbDelayTimer = *(rb->current_tick); |
209 | break; | 233 | break; |
210 | case MPEG_UP: | 234 | case MPEG_UP: |
211 | case MPEG_UP | BUTTON_REPEAT: | 235 | case MPEG_UP | BUTTON_REPEAT: |
212 | if ((resume_time += 20) > play_time) | 236 | if ((resume_time += 20) > play_time) |
213 | resume_time = play_time; | 237 | resume_time = play_time; |
214 | slider_state = state0; | 238 | slider_state = state0; |
215 | thumbDelayTimer = *(rb->current_tick); | 239 | thumbDelayTimer = *(rb->current_tick); |
216 | break; | 240 | break; |
217 | #endif | 241 | #endif |
218 | case MPEG_LEFT: | 242 | case MPEG_LEFT: |
219 | case MPEG_LEFT | BUTTON_REPEAT: | 243 | case MPEG_LEFT | BUTTON_REPEAT: |
220 | case MPEG_SCROLL_UP: | 244 | case MPEG_SCROLL_UP: |
221 | case MPEG_SCROLL_UP | BUTTON_REPEAT: | 245 | case MPEG_SCROLL_UP | BUTTON_REPEAT: |
222 | if (--resume_time < 0) | 246 | if (--resume_time < 0) |
223 | resume_time = 0; | 247 | resume_time = 0; |
224 | slider_state = state0; | 248 | slider_state = state0; |
225 | thumbDelayTimer = *(rb->current_tick); | 249 | thumbDelayTimer = *(rb->current_tick); |
226 | break; | 250 | break; |
227 | case MPEG_RIGHT: | 251 | case MPEG_RIGHT: |
228 | case MPEG_RIGHT | BUTTON_REPEAT: | 252 | case MPEG_RIGHT | BUTTON_REPEAT: |
229 | case MPEG_SCROLL_DOWN: | 253 | case MPEG_SCROLL_DOWN: |
230 | case MPEG_SCROLL_DOWN | BUTTON_REPEAT: | 254 | case MPEG_SCROLL_DOWN | BUTTON_REPEAT: |
231 | if (++resume_time > play_time) | 255 | if (++resume_time > play_time) |
232 | resume_time = play_time; | 256 | resume_time = play_time; |
233 | slider_state = state0; | 257 | slider_state = state0; |
234 | thumbDelayTimer = *(rb->current_tick); | 258 | thumbDelayTimer = *(rb->current_tick); |
235 | break; | 259 | break; |
236 | case MPEG_SELECT: | 260 | case MPEG_SELECT: |
237 | quit = 1; | 261 | settings.resume_time = resume_time; |
238 | break; | 262 | case MPEG_EXIT: |
239 | case MPEG_EXIT: | 263 | seek_quit = 1; |
240 | resume_time = -1; | 264 | break; |
241 | quit = 1; | 265 | default: |
242 | break; | 266 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
243 | default: | 267 | seek_quit = 1; |
244 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 268 | break; |
245 | { | ||
246 | resume_time = -1; | ||
247 | quit = 1; | ||
248 | } | ||
249 | break; | ||
250 | } | 269 | } |
251 | 270 | ||
252 | rb->yield(); | 271 | rb->yield(); |
253 | 272 | ||
254 | switch(slider_state) | 273 | switch(slider_state) |
255 | { | 274 | { |
256 | case state0: | 275 | case state0: |
257 | rb->lcd_clear_display(); | 276 | rb->lcd_clear_display(); |
258 | rb->lcd_update(); | 277 | rb->lcd_update(); |
259 | #ifdef HAVE_LCD_COLOR | 278 | #ifdef HAVE_LCD_COLOR |
260 | if (resume_time > 0) | 279 | if (resume_time > 0) |
261 | rb->splash(0, "Loading..."); | 280 | rb->splash(0, "Loading..."); |
262 | #endif | 281 | #endif |
263 | slider_state = state1; | 282 | slider_state = state1; |
264 | break; | 283 | break; |
265 | case state1: | 284 | case state1: |
266 | if (*(rb->current_tick) - thumbDelayTimer > 75) | 285 | if (*(rb->current_tick) - thumbDelayTimer > 75) |
267 | slider_state = state2; | 286 | slider_state = state2; |
268 | if (resume_time == 0) | 287 | if (resume_time == 0) |
269 | { | 288 | { |
270 | seek_rtn = 0; | 289 | seek_return = 0; |
271 | slider_state = state5; | 290 | slider_state = state5; |
272 | } | 291 | } |
273 | draw_slider(slider_ypos, play_time, resume_time); | 292 | draw_slider(slider_ypos, play_time, resume_time); |
274 | break; | 293 | break; |
275 | case state2: | 294 | case state2: |
276 | if ( (seek_rtn = seek_PTS(in_file, resume_time, 1)) >= 0) | 295 | if ( (seek_return = seek_PTS(in_file, resume_time, 1)) >= 0) |
277 | slider_state = state3; | 296 | slider_state = state3; |
278 | else if (seek_rtn == -101) | 297 | else if (seek_return == -101) |
279 | { | 298 | { |
280 | slider_state = state0; | 299 | slider_state = state0; |
281 | thumbDelayTimer = *(rb->current_tick); | 300 | thumbDelayTimer = *(rb->current_tick); |
282 | } | 301 | } |
283 | else | 302 | else |
303 | slider_state = state4; | ||
304 | break; | ||
305 | case state3: | ||
306 | display_thumb(in_file); | ||
307 | draw_slider(slider_ypos, play_time, resume_time); | ||
284 | slider_state = state4; | 308 | slider_state = state4; |
285 | break; | 309 | break; |
286 | case state3: | 310 | case state4: |
287 | display_thumb(in_file); | 311 | draw_slider(slider_ypos, play_time, resume_time); |
288 | draw_slider(slider_ypos, play_time, resume_time); | 312 | slider_state = state5; |
289 | slider_state = state4; | 313 | break; |
290 | break; | 314 | case state5: |
291 | case state4: | 315 | break; |
292 | draw_slider(slider_ypos, play_time, resume_time); | ||
293 | slider_state = state5; | ||
294 | break; | ||
295 | case state5: | ||
296 | break; | ||
297 | } | 316 | } |
298 | } | 317 | } |
299 | 318 | ||
300 | return resume_time; | 319 | return button; |
301 | } | 320 | } |
302 | 321 | ||
303 | int mpeg_start_menu(int play_time, int in_file) | 322 | enum mpeg_start_id mpeg_start_menu(int play_time, int in_file) |
304 | { | 323 | { |
305 | int m; | 324 | int menu_id; |
306 | int result = 0; | 325 | int result = 0; |
307 | int menu_quit = 0; | 326 | int menu_quit = 0; |
308 | 327 | ||
309 | /* add the resume time to the menu display */ | 328 | /* add the resume time to the menu display */ |
310 | char resume_str[32]; | 329 | char resume_str[32]; |
311 | int time_hol = (int)(settings.resume_time/2); | 330 | int time_hol = (int)(settings.resume_time/2); |
312 | int time_rem = ((settings.resume_time%2)==0) ? 0 : 5; | 331 | int time_rem = ((settings.resume_time%2)==0) ? 0 : 5; |
313 | rb->snprintf(resume_str, sizeof(resume_str), | 332 | rb->snprintf(resume_str, sizeof(resume_str), |
314 | "Resume time (min): %d.%d", time_hol, time_rem); | 333 | "Resume time (min): %d.%d", time_hol, time_rem); |
315 | 334 | ||
316 | struct menu_item items[] = { | 335 | struct menu_item items[] = |
317 | { "Play from beginning", NULL }, | 336 | { |
318 | { resume_str, NULL }, | 337 | [MPEG_START_RESTART] = |
319 | { "Set start time (min)", NULL }, | 338 | { "Play from beginning", NULL }, |
320 | { "Quit mpegplayer", NULL }, | 339 | [MPEG_START_RESUME] = |
340 | { resume_str, NULL }, | ||
341 | [MPEG_START_SEEK] = | ||
342 | { "Set start time (min)", NULL }, | ||
343 | [MPEG_START_QUIT] = | ||
344 | { "Quit mpegplayer", NULL }, | ||
321 | }; | 345 | }; |
322 | 346 | ||
323 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 347 | |
324 | NULL, NULL, NULL, NULL); | 348 | menu_id = menu_init(rb, items, sizeof(items) / sizeof(*items), |
349 | NULL, NULL, NULL, NULL); | ||
325 | 350 | ||
326 | rb->button_clear_queue(); | 351 | rb->button_clear_queue(); |
327 | 352 | ||
328 | while(menu_quit == 0) | 353 | while(menu_quit == 0) |
329 | { | 354 | { |
330 | result = menu_show(m); | 355 | result = menu_show(menu_id); |
331 | 356 | ||
332 | switch (result) | 357 | switch (result) |
333 | { | 358 | { |
334 | case 0: | 359 | case MPEG_START_RESTART: |
335 | menu_quit = 1; | 360 | settings.resume_time = 0; |
336 | result = 0; | 361 | menu_quit = 1; |
337 | break; | 362 | break; |
338 | case 1: | 363 | case MPEG_START_RESUME: |
339 | menu_quit = 1; | 364 | menu_quit = 1; |
340 | result = settings.resume_time; | 365 | break; |
341 | break; | 366 | case MPEG_START_SEEK: |
342 | case 2: | ||
343 | #ifndef HAVE_LCD_COLOR | 367 | #ifndef HAVE_LCD_COLOR |
344 | gray_show(true); | 368 | gray_show(true); |
345 | #endif | 369 | #endif |
346 | if ((result = get_start_time(play_time, in_file)) >= 0) | 370 | if (get_start_time(play_time, in_file) == MPEG_SELECT) |
347 | menu_quit = 1; | 371 | menu_quit = 1; |
348 | #ifndef HAVE_LCD_COLOR | 372 | #ifndef HAVE_LCD_COLOR |
349 | gray_show(false); | 373 | gray_show(false); |
350 | #endif | 374 | #endif |
351 | break; | 375 | break; |
352 | case 3: | 376 | case MPEG_START_QUIT: |
353 | menu_quit = 1; | 377 | menu_quit = 1; |
354 | result = -1; | 378 | break; |
355 | break; | 379 | default: |
356 | default: | 380 | result = MPEG_START_QUIT; |
357 | if (result == MENU_ATTACHED_USB) | ||
358 | { | ||
359 | menu_quit = 1; | 381 | menu_quit = 1; |
360 | result = -1; | 382 | break; |
361 | } | ||
362 | break; | ||
363 | } | 383 | } |
364 | } | 384 | } |
365 | menu_exit(m); | ||
366 | 385 | ||
367 | settings.resume_time = result; | 386 | menu_exit(menu_id); |
368 | return (int)result; | 387 | |
388 | return result; | ||
369 | } | 389 | } |
370 | 390 | ||
371 | void clear_resume_count(void) | 391 | void clear_resume_count(void) |
@@ -380,9 +400,9 @@ void clear_resume_count(void) | |||
380 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); | 400 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); |
381 | } | 401 | } |
382 | 402 | ||
383 | bool mpeg_menu(void) | 403 | enum mpeg_menu_id mpeg_menu(void) |
384 | { | 404 | { |
385 | int m; | 405 | int menu_id; |
386 | int result; | 406 | int result; |
387 | int menu_quit=0; | 407 | int menu_quit=0; |
388 | 408 | ||
@@ -392,68 +412,48 @@ bool mpeg_menu(void) | |||
392 | "Clear all resumes: %u", settings.resume_count); | 412 | "Clear all resumes: %u", settings.resume_count); |
393 | 413 | ||
394 | struct menu_item items[] = { | 414 | struct menu_item items[] = { |
395 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 415 | [MPEG_MENU_DISPLAY_SETTINGS] = |
396 | [MPEG_OPTION_DISPLAY_SETTINGS] = | ||
397 | { "Display Options", NULL }, | 416 | { "Display Options", NULL }, |
398 | #endif | 417 | [MPEG_MENU_CLEAR_RESUMES] = |
399 | [MPEG_OPTION_DISPLAY_FPS] = | ||
400 | { "Display FPS", NULL }, | ||
401 | [MPEG_OPTION_LIMIT_FPS] = | ||
402 | { "Limit FPS", NULL }, | ||
403 | [MPEG_OPTION_SKIP_FRAMES] = | ||
404 | { "Skip frames", NULL }, | ||
405 | [MPEG_OPTION_CLEAR_RESUMES] = | ||
406 | { clear_str, NULL }, | 418 | { clear_str, NULL }, |
407 | [MPEG_OPTION_QUIT] = | 419 | [MPEG_MENU_QUIT] = |
408 | { "Quit mpegplayer", NULL }, | 420 | { "Quit mpegplayer", NULL }, |
409 | }; | 421 | }; |
410 | 422 | ||
411 | m = menu_init(rb, items, ARRAYLEN(items), NULL, NULL, NULL, NULL); | 423 | menu_id = menu_init(rb, items, ARRAYLEN(items), |
424 | NULL, NULL, NULL, NULL); | ||
412 | 425 | ||
413 | rb->button_clear_queue(); | 426 | rb->button_clear_queue(); |
414 | 427 | ||
415 | while (!menu_quit) { | 428 | while (menu_quit == 0) |
416 | result=menu_show(m); | 429 | { |
430 | result=menu_show(menu_id); | ||
417 | 431 | ||
418 | switch(result) | 432 | switch(result) |
419 | { | 433 | { |
420 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 434 | case MPEG_MENU_DISPLAY_SETTINGS: |
421 | case MPEG_OPTION_DISPLAY_SETTINGS: | ||
422 | display_options(); | 435 | display_options(); |
423 | break; | 436 | break; |
424 | #endif | 437 | case MPEG_MENU_CLEAR_RESUMES: |
425 | case MPEG_OPTION_DISPLAY_FPS: | ||
426 | rb->set_option("Display FPS",&settings.showfps,INT, | ||
427 | noyes, 2, NULL); | ||
428 | break; | ||
429 | case MPEG_OPTION_LIMIT_FPS: | ||
430 | rb->set_option("Limit FPS",&settings.limitfps,INT, | ||
431 | noyes, 2, NULL); | ||
432 | break; | ||
433 | case MPEG_OPTION_SKIP_FRAMES: | ||
434 | rb->set_option("Skip frames",&settings.skipframes,INT, | ||
435 | noyes, 2, NULL); | ||
436 | break; | ||
437 | case MPEG_OPTION_CLEAR_RESUMES: | ||
438 | clear_resume_count(); | 438 | clear_resume_count(); |
439 | rb->snprintf(clear_str, sizeof(clear_str), | 439 | rb->snprintf(clear_str, sizeof(clear_str), |
440 | "Clear all resumes: %u", 0); | 440 | "Clear all resumes: %u", 0); |
441 | break; | 441 | break; |
442 | case MPEG_OPTION_QUIT: | 442 | case MPEG_MENU_QUIT: |
443 | default: | 443 | default: |
444 | menu_quit=1; | 444 | menu_quit=1; |
445 | if (result == MENU_ATTACHED_USB) | 445 | if (result == MENU_ATTACHED_USB) |
446 | result = MPEG_OPTION_QUIT; | 446 | result = MPEG_MENU_QUIT; |
447 | break; | 447 | break; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | menu_exit(m); | 451 | menu_exit(menu_id); |
452 | 452 | ||
453 | rb->lcd_clear_display(); | 453 | rb->lcd_clear_display(); |
454 | rb->lcd_update(); | 454 | rb->lcd_update(); |
455 | 455 | ||
456 | return (result==MPEG_OPTION_QUIT); | 456 | return result; |
457 | } | 457 | } |
458 | 458 | ||
459 | void init_settings(const char* filename) | 459 | void init_settings(const char* filename) |
@@ -469,15 +469,9 @@ void init_settings(const char* filename) | |||
469 | 469 | ||
470 | configfile_init(rb); | 470 | configfile_init(rb); |
471 | 471 | ||
472 | /* If the config file don't contain resume count | 472 | if (configfile_load(SETTINGS_FILENAME, config, |
473 | or the load fails, then rebuild the config file. | 473 | sizeof(config)/sizeof(*config), |
474 | This eliminates the worry for older config files | 474 | SETTINGS_MIN_VERSION) < 0) |
475 | having unused data. */ | ||
476 | if (((settings.resume_count = configfile_get_value | ||
477 | (SETTINGS_FILENAME, "Resume count")) < 0) || | ||
478 | (configfile_load(SETTINGS_FILENAME, config, | ||
479 | sizeof(config)/sizeof(*config), | ||
480 | SETTINGS_MIN_VERSION) < 0)) | ||
481 | { | 475 | { |
482 | /* Generate a new config file with default values */ | 476 | /* Generate a new config file with default values */ |
483 | configfile_save(SETTINGS_FILENAME, config, | 477 | configfile_save(SETTINGS_FILENAME, config, |
@@ -498,9 +492,7 @@ void init_settings(const char* filename) | |||
498 | if (settings.resume_count < 0) | 492 | if (settings.resume_count < 0) |
499 | { | 493 | { |
500 | settings.resume_count = 0; | 494 | settings.resume_count = 0; |
501 | 495 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); | |
502 | /* add this place holder so the count is above resume entries */ | ||
503 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); | ||
504 | } | 496 | } |
505 | 497 | ||
506 | rb->strcpy(settings.resume_filename, filename); | 498 | rb->strcpy(settings.resume_filename, filename); |