diff options
author | Robert Kukla <roolku@rockbox.org> | 2007-10-16 14:23:50 +0000 |
---|---|---|
committer | Robert Kukla <roolku@rockbox.org> | 2007-10-16 14:23:50 +0000 |
commit | 0b911fefea7615105244098da1baf4655fa1e721 (patch) | |
tree | fdf7364483d71ffe8dacfbd0dc44933b3d865178 /apps | |
parent | 94c23df2abdd1b8ac171f6bf1d651bd3a1faed58 (diff) | |
download | rockbox-0b911fefea7615105244098da1baf4655fa1e721.tar.gz rockbox-0b911fefea7615105244098da1baf4655fa1e721.zip |
FS#7971 - mpegplayer - start menu loads quicker - menu clean up - code clean up
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15143 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/mpegplayer/alloc.c | 3 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 414 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.h | 30 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 48 |
4 files changed, 261 insertions, 234 deletions
diff --git a/apps/plugins/mpegplayer/alloc.c b/apps/plugins/mpegplayer/alloc.c index ae482de112..c79894447b 100644 --- a/apps/plugins/mpegplayer/alloc.c +++ b/apps/plugins/mpegplayer/alloc.c | |||
@@ -54,8 +54,6 @@ static void * mpeg_malloc_internal (unsigned char *mallocbuf, | |||
54 | x = &mallocbuf[*mem_ptr]; | 54 | x = &mallocbuf[*mem_ptr]; |
55 | *mem_ptr += (size + 3) & ~3; /* Keep memory 32-bit aligned */ | 55 | *mem_ptr += (size + 3) & ~3; /* Keep memory 32-bit aligned */ |
56 | 56 | ||
57 | rb->memset(x,0,size); | ||
58 | |||
59 | return x; | 57 | return x; |
60 | (void)reason; | 58 | (void)reason; |
61 | } | 59 | } |
@@ -75,7 +73,6 @@ size_t mpeg_alloc_init(unsigned char *buf, size_t mallocsize, | |||
75 | mallocbuf = (char *)(((intptr_t)buf + 15) & ~15); | 73 | mallocbuf = (char *)(((intptr_t)buf + 15) & ~15); |
76 | /* Adjust for real size */ | 74 | /* Adjust for real size */ |
77 | bufsize -= mallocbuf - buf; | 75 | bufsize -= mallocbuf - buf; |
78 | rb->memset(buf,0,bufsize); | ||
79 | 76 | ||
80 | /* Separate allocator for video */ | 77 | /* Separate allocator for video */ |
81 | libmpeg2size = (libmpeg2size + 15) & ~15; | 78 | libmpeg2size = (libmpeg2size + 15) & ~15; |
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); |
diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h index 690667f632..340deb46fe 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.h +++ b/apps/plugins/mpegplayer/mpeg_settings.h | |||
@@ -1,6 +1,31 @@ | |||
1 | 1 | ||
2 | #include "plugin.h" | 2 | #include "plugin.h" |
3 | 3 | ||
4 | enum mpeg_option_id | ||
5 | { | ||
6 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | ||
7 | MPEG_OPTION_DITHERING, | ||
8 | #endif | ||
9 | MPEG_OPTION_DISPLAY_FPS, | ||
10 | MPEG_OPTION_LIMIT_FPS, | ||
11 | MPEG_OPTION_SKIP_FRAMES, | ||
12 | }; | ||
13 | |||
14 | enum mpeg_start_id | ||
15 | { | ||
16 | MPEG_START_RESTART, | ||
17 | MPEG_START_RESUME, | ||
18 | MPEG_START_SEEK, | ||
19 | MPEG_START_QUIT, | ||
20 | }; | ||
21 | |||
22 | enum mpeg_menu_id | ||
23 | { | ||
24 | MPEG_MENU_DISPLAY_SETTINGS, | ||
25 | MPEG_MENU_CLEAR_RESUMES, | ||
26 | MPEG_MENU_QUIT, | ||
27 | }; | ||
28 | |||
4 | struct mpeg_settings { | 29 | struct mpeg_settings { |
5 | int showfps; /* flag to display fps */ | 30 | int showfps; /* flag to display fps */ |
6 | int limitfps; /* flag to limit fps */ | 31 | int limitfps; /* flag to limit fps */ |
@@ -8,7 +33,6 @@ struct mpeg_settings { | |||
8 | int resume_count; /* total # of resumes in config file */ | 33 | int resume_count; /* total # of resumes in config file */ |
9 | int resume_time; /* resume time for current mpeg (in half minutes) */ | 34 | int resume_time; /* resume time for current mpeg (in half minutes) */ |
10 | char resume_filename[128]; /* filename of current mpeg */ | 35 | char resume_filename[128]; /* filename of current mpeg */ |
11 | |||
12 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) | 36 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) |
13 | int displayoptions; | 37 | int displayoptions; |
14 | #endif | 38 | #endif |
@@ -17,8 +41,8 @@ struct mpeg_settings { | |||
17 | extern struct mpeg_settings settings; | 41 | extern struct mpeg_settings settings; |
18 | 42 | ||
19 | int get_start_time(int play_time, int in_file); | 43 | int get_start_time(int play_time, int in_file); |
20 | int mpeg_start_menu(int play_time, int in_file); | 44 | enum mpeg_start_id mpeg_start_menu(int play_time, int in_file); |
21 | bool mpeg_menu(void); | 45 | enum mpeg_menu_id mpeg_menu(void); |
22 | void init_settings(const char* filename); | 46 | void init_settings(const char* filename); |
23 | void save_settings(void); | 47 | void save_settings(void); |
24 | void clear_resume_count(void); | 48 | void clear_resume_count(void); |
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 12282a3322..5d79475d2a 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c | |||
@@ -1042,7 +1042,7 @@ static inline int32_t clip_sample(int32_t sample) | |||
1042 | 1042 | ||
1043 | static int button_loop(void) | 1043 | static int button_loop(void) |
1044 | { | 1044 | { |
1045 | bool result; | 1045 | int result; |
1046 | int vol, minvol, maxvol; | 1046 | int vol, minvol, maxvol; |
1047 | int button; | 1047 | int button; |
1048 | 1048 | ||
@@ -1118,15 +1118,19 @@ static int button_loop(void) | |||
1118 | /* The menu can change the font, so restore */ | 1118 | /* The menu can change the font, so restore */ |
1119 | rb->lcd_setfont(FONT_SYSFIXED); | 1119 | rb->lcd_setfont(FONT_SYSFIXED); |
1120 | 1120 | ||
1121 | if (result) { | 1121 | switch (result) |
1122 | settings.resume_time = (int)(get_stream_time()/CLOCK_RATE/ | 1122 | { |
1123 | 30-start_pts_time); | 1123 | case MPEG_MENU_QUIT: |
1124 | str_send_msg(&video_str, STREAM_QUIT, 0); | 1124 | settings.resume_time = (int)(get_stream_time()/CLOCK_RATE/ |
1125 | audio_str.status = STREAM_STOPPED; | 1125 | 30-start_pts_time); |
1126 | } else { | 1126 | str_send_msg(&video_str, STREAM_QUIT, 0); |
1127 | audio_str.status = STREAM_PLAYING; | 1127 | audio_str.status = STREAM_STOPPED; |
1128 | str_send_msg(&video_str, STREAM_PLAY, 0); | 1128 | break; |
1129 | pcm_playback_play_pause(true); | 1129 | default: |
1130 | audio_str.status = STREAM_PLAYING; | ||
1131 | str_send_msg(&video_str, STREAM_PLAY, 0); | ||
1132 | pcm_playback_play_pause(true); | ||
1133 | break; | ||
1130 | } | 1134 | } |
1131 | break; | 1135 | break; |
1132 | 1136 | ||
@@ -2203,7 +2207,8 @@ ssize_t seek_PTS( int in_file, int start_time, int accept_button ) | |||
2203 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 2207 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
2204 | { | 2208 | { |
2205 | int status = PLUGIN_ERROR; /* assume failure */ | 2209 | int status = PLUGIN_ERROR; /* assume failure */ |
2206 | int start_time=-1; | 2210 | int result; |
2211 | int start_time = -1; | ||
2207 | void* audiobuf; | 2212 | void* audiobuf; |
2208 | ssize_t audiosize; | 2213 | ssize_t audiosize; |
2209 | int in_file; | 2214 | int in_file; |
@@ -2295,8 +2300,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2295 | rb->lcd_set_foreground(LCD_WHITE); | 2300 | rb->lcd_set_foreground(LCD_WHITE); |
2296 | rb->lcd_set_background(LCD_BLACK); | 2301 | rb->lcd_set_background(LCD_BLACK); |
2297 | #endif | 2302 | #endif |
2298 | rb->lcd_clear_display(); | ||
2299 | rb->lcd_update(); | ||
2300 | 2303 | ||
2301 | init_settings((char*)parameter); | 2304 | init_settings((char*)parameter); |
2302 | 2305 | ||
@@ -2312,10 +2315,21 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2312 | find_end_pts( in_file ); | 2315 | find_end_pts( in_file ); |
2313 | 2316 | ||
2314 | /* start menu */ | 2317 | /* start menu */ |
2315 | start_time = mpeg_start_menu(end_pts_time-start_pts_time, in_file); | 2318 | rb->lcd_clear_display(); |
2316 | if ( start_time == -1 ) | 2319 | rb->lcd_update(); |
2317 | return 0; | 2320 | result = mpeg_start_menu(end_pts_time-start_pts_time, in_file); |
2318 | else if ( start_time < 0 ) | 2321 | |
2322 | switch (result) | ||
2323 | { | ||
2324 | case MPEG_START_QUIT: | ||
2325 | return 0; | ||
2326 | default: | ||
2327 | start_time = settings.resume_time; | ||
2328 | break; | ||
2329 | } | ||
2330 | |||
2331 | /* basic time checks */ | ||
2332 | if ( start_time < 0 ) | ||
2319 | start_time = 0; | 2333 | start_time = 0; |
2320 | else if ( start_time > (end_pts_time-start_pts_time) ) | 2334 | else if ( start_time > (end_pts_time-start_pts_time) ) |
2321 | start_time = (end_pts_time-start_pts_time); | 2335 | start_time = (end_pts_time-start_pts_time); |