diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 410 |
1 files changed, 384 insertions, 26 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index 28062f4567..197fa09236 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -7,20 +7,99 @@ | |||
7 | extern struct plugin_api* rb; | 7 | extern struct plugin_api* rb; |
8 | 8 | ||
9 | struct mpeg_settings settings; | 9 | struct mpeg_settings settings; |
10 | static struct mpeg_settings old_settings; | 10 | |
11 | ssize_t seek_PTS(int in_file, int startTime, int accept_button); | ||
12 | void display_thumb(int in_file); | ||
13 | |||
14 | #ifndef HAVE_LCD_COLOR | ||
15 | void gray_show(bool enable); | ||
16 | #endif | ||
11 | 17 | ||
12 | #define SETTINGS_VERSION 2 | 18 | #define SETTINGS_VERSION 2 |
13 | #define SETTINGS_MIN_VERSION 1 | 19 | #define SETTINGS_MIN_VERSION 1 |
14 | #define SETTINGS_FILENAME "mpegplayer.cfg" | 20 | #define SETTINGS_FILENAME "mpegplayer.cfg" |
15 | 21 | ||
22 | enum slider_state_t {state0, state1, state2, | ||
23 | state3, state4, state5} slider_state; | ||
24 | |||
25 | volatile long thumbDelayTimer; | ||
26 | |||
27 | /* button definitions */ | ||
28 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ | ||
29 | (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
30 | #define MPEG_SELECT BUTTON_ON | ||
31 | #define MPEG_RIGHT BUTTON_RIGHT | ||
32 | #define MPEG_LEFT BUTTON_LEFT | ||
33 | #define MPEG_SCROLL_DOWN BUTTON_UP | ||
34 | #define MPEG_SCROLL_UP BUTTON_DOWN | ||
35 | #define MPEG_EXIT BUTTON_OFF | ||
36 | |||
37 | #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) | ||
38 | #define MPEG_SELECT BUTTON_PLAY | ||
39 | #define MPEG_RIGHT BUTTON_RIGHT | ||
40 | #define MPEG_LEFT BUTTON_LEFT | ||
41 | #define MPEG_SCROLL_DOWN BUTTON_UP | ||
42 | #define MPEG_SCROLL_UP BUTTON_DOWN | ||
43 | #define MPEG_EXIT BUTTON_POWER | ||
44 | |||
45 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ | ||
46 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ | ||
47 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) | ||
48 | #define MPEG_SELECT BUTTON_SELECT | ||
49 | #define MPEG_RIGHT BUTTON_RIGHT | ||
50 | #define MPEG_LEFT BUTTON_LEFT | ||
51 | #define MPEG_SCROLL_DOWN BUTTON_SCROLL_FWD | ||
52 | #define MPEG_SCROLL_UP BUTTON_SCROLL_BACK | ||
53 | #define MPEG_EXIT BUTTON_MENU | ||
54 | |||
55 | #elif CONFIG_KEYPAD == GIGABEAT_PAD | ||
56 | #define MPEG_SELECT BUTTON_SELECT | ||
57 | #define MPEG_LEFT BUTTON_LEFT | ||
58 | #define MPEG_RIGHT BUTTON_RIGHT | ||
59 | #define MPEG_UP BUTTON_UP | ||
60 | #define MPEG_DOWN BUTTON_DOWN | ||
61 | #define MPEG_SCROLL_DOWN BUTTON_VOL_DOWN | ||
62 | #define MPEG_SCROLL_UP BUTTON_VOL_UP | ||
63 | #define MPEG_EXIT BUTTON_POWER | ||
64 | |||
65 | #elif CONFIG_KEYPAD == IRIVER_H10_PAD | ||
66 | #define MPEG_SELECT BUTTON_PLAY | ||
67 | #define MPEG_SCROLL_UP BUTTON_SCROLL_UP | ||
68 | #define MPEG_SCROLL_DOWN BUTTON_SCROLL_DOWN | ||
69 | #define MPEG_LEFT BUTTON_LEFT | ||
70 | #define MPEG_RIGHT BUTTON_RIGHT | ||
71 | #define MPEG_EXIT BUTTON_POWER | ||
72 | |||
73 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) | ||
74 | #define MPEG_SELECT BUTTON_SELECT | ||
75 | #define MPEG_SCROLL_UP BUTTON_SCROLL_UP | ||
76 | #define MPEG_SCROLL_DOWN BUTTON_SCROLL_DOWN | ||
77 | #define MPEG_LEFT BUTTON_LEFT | ||
78 | #define MPEG_RIGHT BUTTON_RIGHT | ||
79 | #define MPEG_UP BUTTON_UP | ||
80 | #define MPEG_DOWN BUTTON_DOWN | ||
81 | #define MPEG_EXIT BUTTON_POWER | ||
82 | |||
83 | #elif (CONFIG_KEYPAD == SANSA_C200_PAD) | ||
84 | #define MPEG_SELECT BUTTON_SELECT | ||
85 | #define MPEG_SCROLL_UP BUTTON_VOL_UP | ||
86 | #define MPEG_SCROLL_DOWN BUTTON_VOL_DOWN | ||
87 | #define MPEG_LEFT BUTTON_LEFT | ||
88 | #define MPEG_RIGHT BUTTON_RIGHT | ||
89 | #define MPEG_UP BUTTON_UP | ||
90 | #define MPEG_DOWN BUTTON_DOWN | ||
91 | #define MPEG_EXIT BUTTON_POWER | ||
92 | |||
93 | #else | ||
94 | #error MPEGPLAYER: Unsupported keypad | ||
95 | #endif | ||
96 | |||
16 | static struct configdata config[] = | 97 | static struct configdata config[] = |
17 | { | 98 | { |
18 | {TYPE_ENUM, 0, 2, &settings.showfps, "Show FPS", | 99 | {TYPE_INT, 0, 2, &settings.showfps, "Show FPS", NULL, NULL}, |
19 | (char *[]){ "No", "Yes" }, NULL}, | 100 | {TYPE_INT, 0, 2, &settings.limitfps, "Limit FPS", NULL, NULL}, |
20 | {TYPE_ENUM, 0, 2, &settings.limitfps, "Limit FPS", | 101 | {TYPE_INT, 0, 2, &settings.skipframes, "Skip frames", NULL, NULL}, |
21 | (char *[]){ "No", "Yes" }, NULL}, | 102 | |
22 | {TYPE_ENUM, 0, 2, &settings.skipframes, "Skip frames", | ||
23 | (char *[]){ "No", "Yes" }, NULL}, | ||
24 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 103 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
25 | {TYPE_INT, 0, INT_MAX, &settings.displayoptions, "Display options", | 104 | {TYPE_INT, 0, INT_MAX, &settings.displayoptions, "Display options", |
26 | NULL, NULL}, | 105 | NULL, NULL}, |
@@ -36,6 +115,7 @@ enum mpeg_menu_ids | |||
36 | MPEG_OPTION_DISPLAY_FPS, | 115 | MPEG_OPTION_DISPLAY_FPS, |
37 | MPEG_OPTION_LIMIT_FPS, | 116 | MPEG_OPTION_LIMIT_FPS, |
38 | MPEG_OPTION_SKIP_FRAMES, | 117 | MPEG_OPTION_SKIP_FRAMES, |
118 | MPEG_OPTION_CLEAR_RESUMES, | ||
39 | MPEG_OPTION_QUIT, | 119 | MPEG_OPTION_QUIT, |
40 | }; | 120 | }; |
41 | 121 | ||
@@ -68,13 +148,250 @@ static void display_options(void) | |||
68 | } | 148 | } |
69 | #endif /* #ifdef TOSHIBA_GIGABEAT_F */ | 149 | #endif /* #ifdef TOSHIBA_GIGABEAT_F */ |
70 | 150 | ||
151 | void draw_slider(int slider_ypos, int max_val, int current_val) | ||
152 | { | ||
153 | int slider_margin = LCD_WIDTH*12/100; /* 12% */ | ||
154 | int slider_width = LCD_WIDTH-(slider_margin*2); | ||
155 | char resume_str[32]; | ||
156 | |||
157 | /* max_val and current_val are in half minutes | ||
158 | determine value .0 or .5 to display */ | ||
159 | int max_hol = max_val/2; | ||
160 | int max_rem = (max_val-(max_hol*2))*5; | ||
161 | int current_hol = current_val/2; | ||
162 | int current_rem = (current_val-(current_hol*2))*5; | ||
163 | |||
164 | rb->snprintf(resume_str, sizeof(resume_str), "0.0"); | ||
165 | rb->lcd_putsxy(slider_margin, slider_ypos, resume_str); | ||
166 | |||
167 | rb->snprintf(resume_str, sizeof(resume_str), "%u.%u", max_hol, max_rem); | ||
168 | rb->lcd_putsxy(LCD_WIDTH-slider_margin-25, slider_ypos, resume_str); | ||
169 | |||
170 | rb->lcd_drawrect(slider_margin, slider_ypos+17, slider_width, 8); | ||
171 | rb->lcd_fillrect(slider_margin, slider_ypos+17, | ||
172 | current_val*slider_width/max_val, 8); | ||
173 | |||
174 | rb->snprintf(resume_str, sizeof(resume_str), "%u.%u", current_hol, | ||
175 | current_rem); | ||
176 | rb->lcd_putsxy(slider_margin+(current_val*slider_width/max_val)-16, | ||
177 | slider_ypos+29, resume_str); | ||
178 | |||
179 | rb->lcd_update_rect(0, slider_ypos, LCD_WIDTH, LCD_HEIGHT-slider_ypos); | ||
180 | } | ||
181 | |||
182 | int get_start_time(int play_time, int in_file) | ||
183 | { | ||
184 | int quit = 0; | ||
185 | int button = 0; | ||
186 | int resume_time = settings.resume_time; | ||
187 | int slider_ypos = LCD_HEIGHT-45; | ||
188 | int seek_rtn; | ||
189 | |||
190 | slider_state = state0; | ||
191 | thumbDelayTimer = *(rb->current_tick); | ||
192 | rb->lcd_clear_display(); | ||
193 | rb->lcd_update(); | ||
194 | |||
195 | while(quit == 0) | ||
196 | { | ||
197 | button = rb->button_get(false); | ||
198 | switch (button) | ||
199 | { | ||
200 | #if (CONFIG_KEYPAD == GIGABEAT_PAD) || \ | ||
201 | (CONFIG_KEYPAD == SANSA_E200_PAD) || \ | ||
202 | (CONFIG_KEYPAD == SANSA_C200_PAD) | ||
203 | case MPEG_DOWN: | ||
204 | case MPEG_DOWN | BUTTON_REPEAT: | ||
205 | if ((resume_time -= 20) < 0) | ||
206 | resume_time = 0; | ||
207 | slider_state = state0; | ||
208 | thumbDelayTimer = *(rb->current_tick); | ||
209 | break; | ||
210 | case MPEG_UP: | ||
211 | case MPEG_UP | BUTTON_REPEAT: | ||
212 | if ((resume_time += 20) > play_time) | ||
213 | resume_time = play_time; | ||
214 | slider_state = state0; | ||
215 | thumbDelayTimer = *(rb->current_tick); | ||
216 | break; | ||
217 | #endif | ||
218 | case MPEG_LEFT: | ||
219 | case MPEG_LEFT | BUTTON_REPEAT: | ||
220 | case MPEG_SCROLL_UP: | ||
221 | case MPEG_SCROLL_UP | BUTTON_REPEAT: | ||
222 | if (--resume_time < 0) | ||
223 | resume_time = 0; | ||
224 | slider_state = state0; | ||
225 | thumbDelayTimer = *(rb->current_tick); | ||
226 | break; | ||
227 | case MPEG_RIGHT: | ||
228 | case MPEG_RIGHT | BUTTON_REPEAT: | ||
229 | case MPEG_SCROLL_DOWN: | ||
230 | case MPEG_SCROLL_DOWN | BUTTON_REPEAT: | ||
231 | if (++resume_time > play_time) | ||
232 | resume_time = play_time; | ||
233 | slider_state = state0; | ||
234 | thumbDelayTimer = *(rb->current_tick); | ||
235 | break; | ||
236 | case MPEG_SELECT: | ||
237 | quit = 1; | ||
238 | break; | ||
239 | case MPEG_EXIT: | ||
240 | resume_time = -1; | ||
241 | quit = 1; | ||
242 | break; | ||
243 | default: | ||
244 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | ||
245 | { | ||
246 | resume_time = -1; | ||
247 | quit = 1; | ||
248 | } | ||
249 | break; | ||
250 | } | ||
251 | |||
252 | rb->yield(); | ||
253 | |||
254 | switch(slider_state) | ||
255 | { | ||
256 | case state0: | ||
257 | rb->lcd_clear_display(); | ||
258 | rb->lcd_update(); | ||
259 | #ifdef HAVE_LCD_COLOR | ||
260 | if (resume_time > 0) | ||
261 | rb->splash(0, "loading ..."); | ||
262 | #endif | ||
263 | slider_state = state1; | ||
264 | break; | ||
265 | case state1: | ||
266 | if (*(rb->current_tick) - thumbDelayTimer > 75) | ||
267 | slider_state = state2; | ||
268 | if (resume_time == 0) | ||
269 | { | ||
270 | seek_rtn = 0; | ||
271 | slider_state = state5; | ||
272 | } | ||
273 | draw_slider(slider_ypos, play_time, resume_time); | ||
274 | break; | ||
275 | case state2: | ||
276 | if ( (seek_rtn = seek_PTS(in_file, resume_time, 1)) >= 0) | ||
277 | slider_state = state3; | ||
278 | else if (seek_rtn == -101) | ||
279 | { | ||
280 | slider_state = state0; | ||
281 | thumbDelayTimer = *(rb->current_tick); | ||
282 | } | ||
283 | else | ||
284 | slider_state = state4; | ||
285 | break; | ||
286 | case state3: | ||
287 | display_thumb(in_file); | ||
288 | draw_slider(slider_ypos, play_time, resume_time); | ||
289 | slider_state = state4; | ||
290 | break; | ||
291 | case state4: | ||
292 | draw_slider(slider_ypos, play_time, resume_time); | ||
293 | slider_state = state5; | ||
294 | break; | ||
295 | case state5: | ||
296 | break; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | return resume_time; | ||
301 | } | ||
302 | |||
303 | int mpeg_start_menu(int play_time, int in_file) | ||
304 | { | ||
305 | int m; | ||
306 | int result = 0; | ||
307 | int menu_quit = 0; | ||
308 | |||
309 | /* add the resume time to the menu display */ | ||
310 | char resume_str[32]; | ||
311 | int time_hol = (int)(settings.resume_time/2); | ||
312 | int time_rem = ((settings.resume_time%2)==0) ? 0 : 5; | ||
313 | rb->snprintf(resume_str, sizeof(resume_str), | ||
314 | "Resume time (min): %d.%d", time_hol, time_rem); | ||
315 | |||
316 | struct menu_item items[] = { | ||
317 | { "Play from beginning", NULL }, | ||
318 | { resume_str, NULL }, | ||
319 | { "Set start time (min)", NULL }, | ||
320 | { "Quit mpegplayer", NULL }, | ||
321 | }; | ||
322 | |||
323 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | ||
324 | NULL, NULL, NULL, NULL); | ||
325 | |||
326 | rb->button_clear_queue(); | ||
327 | |||
328 | while(menu_quit == 0) | ||
329 | { | ||
330 | result = menu_show(m); | ||
331 | |||
332 | switch (result) | ||
333 | { | ||
334 | case 0: | ||
335 | menu_quit = 1; | ||
336 | result = 0; | ||
337 | break; | ||
338 | case 1: | ||
339 | menu_quit = 1; | ||
340 | result = settings.resume_time; | ||
341 | break; | ||
342 | case 2: | ||
343 | #ifndef HAVE_LCD_COLOR | ||
344 | gray_show(true); | ||
345 | #endif | ||
346 | if ((result = get_start_time(play_time, in_file)) >= 0) | ||
347 | menu_quit = 1; | ||
348 | #ifndef HAVE_LCD_COLOR | ||
349 | gray_show(false); | ||
350 | #endif | ||
351 | break; | ||
352 | case 3: | ||
353 | menu_quit = 1; | ||
354 | result = -1; | ||
355 | break; | ||
356 | default: | ||
357 | if (result == MENU_ATTACHED_USB) | ||
358 | { | ||
359 | menu_quit = 1; | ||
360 | result = -1; | ||
361 | } | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | menu_exit(m); | ||
366 | |||
367 | settings.resume_time = result; | ||
368 | return (int)result; | ||
369 | } | ||
370 | |||
371 | void clear_resume_count(void) | ||
372 | { | ||
373 | configfile_save(SETTINGS_FILENAME, config, | ||
374 | sizeof(config)/sizeof(*config), | ||
375 | SETTINGS_VERSION); | ||
376 | |||
377 | settings.resume_count = 0; | ||
378 | |||
379 | /* add this place holder so the count is above resume entries */ | ||
380 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); | ||
381 | } | ||
382 | |||
71 | bool mpeg_menu(void) | 383 | bool mpeg_menu(void) |
72 | { | 384 | { |
73 | int m; | 385 | int m; |
74 | int result; | 386 | int result; |
75 | int menu_quit=0; | 387 | int menu_quit=0; |
76 | 388 | ||
77 | static const struct menu_item items[] = { | 389 | /* add the clear resume option to the menu display */ |
390 | char clear_str[32]; | ||
391 | rb->snprintf(clear_str, sizeof(clear_str), | ||
392 | "Clear all resumes: %u", settings.resume_count); | ||
393 | |||
394 | struct menu_item items[] = { | ||
78 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 395 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
79 | [MPEG_OPTION_DISPLAY_SETTINGS] = | 396 | [MPEG_OPTION_DISPLAY_SETTINGS] = |
80 | { "Display Options", NULL }, | 397 | { "Display Options", NULL }, |
@@ -85,6 +402,8 @@ bool mpeg_menu(void) | |||
85 | { "Limit FPS", NULL }, | 402 | { "Limit FPS", NULL }, |
86 | [MPEG_OPTION_SKIP_FRAMES] = | 403 | [MPEG_OPTION_SKIP_FRAMES] = |
87 | { "Skip frames", NULL }, | 404 | { "Skip frames", NULL }, |
405 | [MPEG_OPTION_CLEAR_RESUMES] = | ||
406 | { clear_str, NULL }, | ||
88 | [MPEG_OPTION_QUIT] = | 407 | [MPEG_OPTION_QUIT] = |
89 | { "Quit mpegplayer", NULL }, | 408 | { "Quit mpegplayer", NULL }, |
90 | }; | 409 | }; |
@@ -115,6 +434,11 @@ bool mpeg_menu(void) | |||
115 | rb->set_option("Skip frames",&settings.skipframes,INT, | 434 | rb->set_option("Skip frames",&settings.skipframes,INT, |
116 | noyes, 2, NULL); | 435 | noyes, 2, NULL); |
117 | break; | 436 | break; |
437 | case MPEG_OPTION_CLEAR_RESUMES: | ||
438 | clear_resume_count(); | ||
439 | rb->snprintf(clear_str, sizeof(clear_str), | ||
440 | "Clear all resumes: %u", 0); | ||
441 | break; | ||
118 | case MPEG_OPTION_QUIT: | 442 | case MPEG_OPTION_QUIT: |
119 | default: | 443 | default: |
120 | menu_quit=1; | 444 | menu_quit=1; |
@@ -132,48 +456,82 @@ bool mpeg_menu(void) | |||
132 | return (result==MPEG_OPTION_QUIT); | 456 | return (result==MPEG_OPTION_QUIT); |
133 | } | 457 | } |
134 | 458 | ||
135 | 459 | void init_settings(const char* filename) | |
136 | void init_settings(void) | ||
137 | { | 460 | { |
138 | /* Set the default settings */ | 461 | /* Set the default settings */ |
139 | settings.showfps = 0; /* Do not show FPS */ | 462 | settings.showfps = 0; /* Do not show FPS */ |
140 | settings.limitfps = 1; /* Limit FPS */ | 463 | settings.limitfps = 1; /* Limit FPS */ |
141 | settings.skipframes = 1; /* Skip frames */ | 464 | settings.skipframes = 1; /* Skip frames */ |
465 | settings.resume_count = -1; | ||
142 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 466 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
143 | settings.displayoptions = 0; /* No visual effects */ | 467 | settings.displayoptions = 0; /* No visual effects */ |
144 | #endif | 468 | #endif |
145 | 469 | ||
146 | configfile_init(rb); | 470 | configfile_init(rb); |
147 | 471 | ||
148 | if (configfile_load(SETTINGS_FILENAME, config, | 472 | /* If the config file don't contain resume count |
149 | sizeof(config)/sizeof(*config), | 473 | or the load fails, then rebuild the config file. |
150 | SETTINGS_MIN_VERSION | 474 | This eliminates the worry for older config files |
151 | ) < 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)) | ||
152 | { | 481 | { |
153 | /* If the loading failed, save a new config file (as the disk is | 482 | /* Generate a new config file with default values */ |
154 | already spinning) */ | ||
155 | configfile_save(SETTINGS_FILENAME, config, | 483 | configfile_save(SETTINGS_FILENAME, config, |
156 | sizeof(config)/sizeof(*config), | 484 | sizeof(config)/sizeof(*config), |
157 | SETTINGS_VERSION); | 485 | SETTINGS_VERSION); |
158 | } | 486 | } |
159 | 487 | ||
160 | /* Keep a copy of the saved version of the settings - so we can check if | ||
161 | the settings have changed when we quit */ | ||
162 | old_settings = settings; | ||
163 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 488 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
489 | if ((settings.displayoptions = | ||
490 | configfile_get_value(SETTINGS_FILENAME, "Display options")) < 0) | ||
491 | { | ||
492 | configfile_update_entry(SETTINGS_FILENAME, "Display options", | ||
493 | (settings.displayoptions=0)); | ||
494 | } | ||
164 | rb->lcd_yuv_set_options(settings.displayoptions); | 495 | rb->lcd_yuv_set_options(settings.displayoptions); |
165 | #endif | 496 | #endif |
497 | |||
498 | if (settings.resume_count < 0) | ||
499 | { | ||
500 | settings.resume_count = 0; | ||
501 | |||
502 | /* add this place holder so the count is above resume entries */ | ||
503 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); | ||
504 | } | ||
505 | |||
506 | rb->strcpy(settings.resume_filename, filename); | ||
507 | |||
508 | /* get the resume time for the current mpeg if it exist */ | ||
509 | if ((settings.resume_time = configfile_get_value | ||
510 | (SETTINGS_FILENAME, filename)) < 0) | ||
511 | { | ||
512 | settings.resume_time = 0; | ||
513 | } | ||
166 | } | 514 | } |
167 | 515 | ||
168 | void save_settings(void) | 516 | void save_settings(void) |
169 | { | 517 | { |
170 | /* Save the user settings if they have changed */ | 518 | configfile_update_entry(SETTINGS_FILENAME, "Show FPS", |
171 | if (rb->memcmp(&settings,&old_settings,sizeof(settings))!=0) { | 519 | settings.showfps); |
172 | configfile_save(SETTINGS_FILENAME, config, | 520 | configfile_update_entry(SETTINGS_FILENAME, "Limit FPS", |
173 | sizeof(config)/sizeof(*config), | 521 | settings.limitfps); |
174 | SETTINGS_VERSION); | 522 | configfile_update_entry(SETTINGS_FILENAME, "Skip frames", |
523 | settings.skipframes); | ||
175 | 524 | ||
176 | /* Store the settings in old_settings - to check for future changes */ | 525 | /* If this was a new resume entry then update the total resume count */ |
177 | old_settings = settings; | 526 | if (configfile_update_entry(SETTINGS_FILENAME, settings.resume_filename, |
527 | settings.resume_time) == 0) | ||
528 | { | ||
529 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", | ||
530 | ++settings.resume_count); | ||
178 | } | 531 | } |
532 | |||
533 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | ||
534 | configfile_update_entry(SETTINGS_FILENAME, "Display options", | ||
535 | settings.displayoptions); | ||
536 | #endif | ||
179 | } | 537 | } |