diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-04-08 17:11:50 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-04-08 17:11:50 +0000 |
commit | 1d52b7295296116327a2552f57cce2ea30cbd507 (patch) | |
tree | 19665425fc4180e1e8d1017a5a3879de3c4ab839 | |
parent | 53b7a4ef8bff0bedd2bd17b5a5677b2deb6510d5 (diff) | |
download | rockbox-1d52b7295296116327a2552f57cce2ea30cbd507.tar.gz rockbox-1d52b7295296116327a2552f57cce2ea30cbd507.zip |
WPS update optimizations:
*) always initialize restore with true, and make the get_action timeout 1 tick if restore is true (which only happens at initially showing the wps), which makes the wps show up way faster (nearly instantly)
*) reduce the number of full updates by removing update_track (full updates are initiated by the event now), rename partial_update to update.
Now, full updates should really happen only on (re-)entering the wps or track change now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20661 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/gwps.c | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 5474b302f0..ef7df3f0b9 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -244,32 +244,24 @@ void gwps_draw_statusbars(void) | |||
244 | long gui_wps_show(void) | 244 | long gui_wps_show(void) |
245 | { | 245 | { |
246 | long button = 0; | 246 | long button = 0; |
247 | bool restore = false; | 247 | bool restore = true; |
248 | long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ | 248 | long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ |
249 | bool exit = false; | 249 | bool exit = false; |
250 | bool bookmark = false; | 250 | bool bookmark = false; |
251 | bool update_track = false, partial_update = false; | 251 | bool update = false; |
252 | int i; | 252 | int i; |
253 | long last_left = 0, last_right = 0; | 253 | long last_left = 0, last_right = 0; |
254 | wps_state_init(); | ||
255 | 254 | ||
256 | #ifdef HAVE_LCD_CHARCELLS | 255 | #ifdef HAVE_LCD_CHARCELLS |
257 | status_set_audio(true); | 256 | status_set_audio(true); |
258 | status_set_param(false); | 257 | status_set_param(false); |
259 | #endif | 258 | #endif |
260 | 259 | ||
261 | gwps_fix_statusbars(); | ||
262 | |||
263 | #ifdef AB_REPEAT_ENABLE | 260 | #ifdef AB_REPEAT_ENABLE |
264 | ab_repeat_init(); | 261 | ab_repeat_init(); |
265 | ab_reset_markers(); | 262 | ab_reset_markers(); |
266 | #endif | 263 | #endif |
267 | if(audio_status() & AUDIO_STATUS_PLAY) | 264 | wps_state_init(); |
268 | { | ||
269 | wps_state.id3 = audio_current_track(); | ||
270 | wps_state.nid3 = audio_next_track(); | ||
271 | restore = true; /* force initial full redraw */ | ||
272 | } | ||
273 | 265 | ||
274 | while ( 1 ) | 266 | while ( 1 ) |
275 | { | 267 | { |
@@ -331,7 +323,8 @@ long gui_wps_show(void) | |||
331 | else | 323 | else |
332 | #endif | 324 | #endif |
333 | { | 325 | { |
334 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); | 326 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK, |
327 | restore ? HZ/100 : HZ/5); | ||
335 | } | 328 | } |
336 | 329 | ||
337 | /* Exit if audio has stopped playing. This happens e.g. at end of | 330 | /* Exit if audio has stopped playing. This happens e.g. at end of |
@@ -372,8 +365,6 @@ long gui_wps_show(void) | |||
372 | FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU | 365 | FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU |
373 | || !audio_status()) | 366 | || !audio_status()) |
374 | return GO_TO_ROOT; | 367 | return GO_TO_ROOT; |
375 | /* track might have changed */ | ||
376 | update_track = true; | ||
377 | restore = true; | 368 | restore = true; |
378 | } | 369 | } |
379 | break; | 370 | break; |
@@ -501,7 +492,6 @@ long gui_wps_show(void) | |||
501 | if (global_settings.party_mode) | 492 | if (global_settings.party_mode) |
502 | break; | 493 | break; |
503 | last_left = current_tick; | 494 | last_left = current_tick; |
504 | update_track = true; | ||
505 | #ifdef AB_REPEAT_ENABLE | 495 | #ifdef AB_REPEAT_ENABLE |
506 | /* if we're in A/B repeat mode and the current position | 496 | /* if we're in A/B repeat mode and the current position |
507 | is past the A marker, jump back to the A marker... */ | 497 | is past the A marker, jump back to the A marker... */ |
@@ -529,7 +519,6 @@ long gui_wps_show(void) | |||
529 | if (global_settings.party_mode) | 519 | if (global_settings.party_mode) |
530 | break; | 520 | break; |
531 | last_right = current_tick; | 521 | last_right = current_tick; |
532 | update_track = true; | ||
533 | #ifdef AB_REPEAT_ENABLE | 522 | #ifdef AB_REPEAT_ENABLE |
534 | /* if we're in A/B repeat mode and the current position is | 523 | /* if we're in A/B repeat mode and the current position is |
535 | before the A marker, jump to the A marker... */ | 524 | before the A marker, jump to the A marker... */ |
@@ -560,7 +549,6 @@ long gui_wps_show(void) | |||
560 | { | 549 | { |
561 | ab_set_B_marker(wps_state.id3->elapsed); | 550 | ab_set_B_marker(wps_state.id3->elapsed); |
562 | ab_jump_to_A_marker(); | 551 | ab_jump_to_A_marker(); |
563 | update_track = true; | ||
564 | } | 552 | } |
565 | else | 553 | else |
566 | #endif | 554 | #endif |
@@ -628,7 +616,7 @@ long gui_wps_show(void) | |||
628 | if (ab_repeat_mode_enabled()) | 616 | if (ab_repeat_mode_enabled()) |
629 | { | 617 | { |
630 | ab_reset_markers(); | 618 | ab_reset_markers(); |
631 | update_track = true; | 619 | update = true; |
632 | } | 620 | } |
633 | break; | 621 | break; |
634 | #endif /* AB_REPEAT_ENABLE */ | 622 | #endif /* AB_REPEAT_ENABLE */ |
@@ -650,10 +638,9 @@ long gui_wps_show(void) | |||
650 | break; | 638 | break; |
651 | 639 | ||
652 | case ACTION_REDRAW: /* yes are locked, just redraw */ | 640 | case ACTION_REDRAW: /* yes are locked, just redraw */ |
653 | restore = true; | 641 | /* fall througgh */ |
654 | break; | 642 | case ACTION_NONE: /* Timeout, do an partial update */ |
655 | case ACTION_NONE: /* Timeout */ | 643 | update = true; |
656 | partial_update = true; | ||
657 | ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ | 644 | ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ |
658 | break; | 645 | break; |
659 | #ifdef HAVE_RECORDING | 646 | #ifdef HAVE_RECORDING |
@@ -669,25 +656,18 @@ long gui_wps_show(void) | |||
669 | default: | 656 | default: |
670 | if(default_event_handler(button) == SYS_USB_CONNECTED) | 657 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
671 | return GO_TO_ROOT; | 658 | return GO_TO_ROOT; |
672 | update_track = true; | 659 | update = true; |
673 | break; | 660 | break; |
674 | } | 661 | } |
675 | 662 | ||
676 | if (wps_state.do_full_update || partial_update || update_track) | 663 | if (wps_state.do_full_update || update) |
677 | { | 664 | { |
678 | if (update_track) | ||
679 | { | ||
680 | wps_state.do_full_update = true; | ||
681 | wps_state.id3 = audio_current_track(); | ||
682 | wps_state.nid3 = audio_next_track(); | ||
683 | } | ||
684 | FOR_NB_SCREENS(i) | 665 | FOR_NB_SCREENS(i) |
685 | { | 666 | { |
686 | gui_wps_update(&gui_wps[i]); | 667 | gui_wps_update(&gui_wps[i]); |
687 | } | 668 | } |
688 | wps_state.do_full_update = false; | 669 | wps_state.do_full_update = false; |
689 | update_track = false; | 670 | update = false; |
690 | partial_update = false; | ||
691 | } | 671 | } |
692 | 672 | ||
693 | if (restore && wps_state.id3 && | 673 | if (restore && wps_state.id3 && |
@@ -770,9 +750,18 @@ static void wps_state_init(void) | |||
770 | { | 750 | { |
771 | wps_state.ff_rewind = false; | 751 | wps_state.ff_rewind = false; |
772 | wps_state.paused = false; | 752 | wps_state.paused = false; |
773 | wps_state.id3 = NULL; | 753 | if(audio_status() & AUDIO_STATUS_PLAY) |
774 | wps_state.nid3 = NULL; | 754 | { |
775 | wps_state.do_full_update = true; | 755 | wps_state.id3 = audio_current_track(); |
756 | wps_state.nid3 = audio_next_track(); | ||
757 | } | ||
758 | else | ||
759 | { | ||
760 | wps_state.id3 = NULL; | ||
761 | wps_state.nid3 = NULL; | ||
762 | } | ||
763 | /* We'll be updating due to restore initialized with true */ | ||
764 | wps_state.do_full_update = false; | ||
776 | /* add the WPS track event callbacks */ | 765 | /* add the WPS track event callbacks */ |
777 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); | 766 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); |
778 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); | 767 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); |