summaryrefslogtreecommitdiff
path: root/apps/gui/gwps.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-04-06 00:39:43 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-04-06 00:39:43 +0000
commit843c7efaf8c953fc3bec40a7da0be3a5da9950df (patch)
treecb27e411394f716d26193433c66132072730ea70 /apps/gui/gwps.c
parent9188f0ffd7ce97101a5b2d697cc43072cd63b502 (diff)
downloadrockbox-843c7efaf8c953fc3bec40a7da0be3a5da9950df.tar.gz
rockbox-843c7efaf8c953fc3bec40a7da0be3a5da9950df.zip
FS9795 - some playback cleanup.
* Use events to notify things when the track has changed instead of the nasty has_track_changed() * Event for when the mp3entry for the next track is avilable (which allows alot more tags to be static which means less redrawing in the WPS) * virtually guarentee that the mp3entry sturct returned by audio_current/next_track() is going to be valid for the duration of the current track. The only time it wont be now is during the time between the codec finishing the previous track and the next track actually starting (~2s), but this is not an issue as long as it is called again when the TRACK_CHANGED event happens (or just use the pointer that gives) It is still possible to confuse the WPS with the next tracks id3 info being displayed but this should fix itself up faster than it used to (and be harder to do) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20633 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/gwps.c')
-rw-r--r--apps/gui/gwps.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 32a27212a4..5474b302f0 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -78,6 +78,8 @@ static struct wps_data wps_datas[NB_SCREENS];
78 78
79/* initial setup of wps_data */ 79/* initial setup of wps_data */
80static void wps_state_init(void); 80static void wps_state_init(void);
81static void track_changed_callback(void *param);
82static void nextid3available_callback(void* param);
81 83
82static void change_dir(int direction) 84static void change_dir(int direction)
83{ 85{
@@ -246,7 +248,7 @@ long gui_wps_show(void)
246 long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ 248 long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */
247 bool exit = false; 249 bool exit = false;
248 bool bookmark = false; 250 bool bookmark = false;
249 bool update_track = false; 251 bool update_track = false, partial_update = false;
250 int i; 252 int i;
251 long last_left = 0, last_right = 0; 253 long last_left = 0, last_right = 0;
252 wps_state_init(); 254 wps_state_init();
@@ -651,7 +653,7 @@ long gui_wps_show(void)
651 restore = true; 653 restore = true;
652 break; 654 break;
653 case ACTION_NONE: /* Timeout */ 655 case ACTION_NONE: /* Timeout */
654 update_track = true; 656 partial_update = true;
655 ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ 657 ffwd_rew(button); /* hopefully fix the ffw/rwd bug */
656 break; 658 break;
657#ifdef HAVE_RECORDING 659#ifdef HAVE_RECORDING
@@ -671,13 +673,21 @@ long gui_wps_show(void)
671 break; 673 break;
672 } 674 }
673 675
674 if (update_track) 676 if (wps_state.do_full_update || partial_update || update_track)
675 { 677 {
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 }
676 FOR_NB_SCREENS(i) 684 FOR_NB_SCREENS(i)
677 { 685 {
678 gui_wps_update(&gui_wps[i]); 686 gui_wps_update(&gui_wps[i]);
679 } 687 }
688 wps_state.do_full_update = false;
680 update_track = false; 689 update_track = false;
690 partial_update = false;
681 } 691 }
682 692
683 if (restore && wps_state.id3 && 693 if (restore && wps_state.id3 &&
@@ -723,7 +733,36 @@ long gui_wps_show(void)
723 return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ 733 return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */
724} 734}
725 735
726/* needs checking if needed end*/ 736/* this is called from the playback thread so NO DRAWING! */
737static void track_changed_callback(void *param)
738{
739 wps_state.id3 = (struct mp3entry*)param;
740 wps_state.nid3 = audio_next_track();
741
742 if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type
743 && strcmp(wps_state.id3->path, curr_cue->audio_filename))
744 {
745 /* the current cuesheet isn't the right one any more */
746 /* We need to parse the new cuesheet */
747 char cuepath[MAX_PATH];
748
749 if (look_for_cuesheet_file(wps_state.id3->path, cuepath) &&
750 parse_cuesheet(cuepath, curr_cue))
751 {
752 wps_state.id3->cuesheet_type = 1;
753 strcpy(curr_cue->audio_filename, wps_state.id3->path);
754 }
755
756 cue_spoof_id3(curr_cue, wps_state.id3);
757 }
758 wps_state.do_full_update = true;
759}
760static void nextid3available_callback(void* param)
761{
762 (void)param;
763 wps_state.nid3 = audio_next_track();
764 wps_state.do_full_update = true;
765}
727 766
728/* wps_state */ 767/* wps_state */
729 768
@@ -733,6 +772,10 @@ static void wps_state_init(void)
733 wps_state.paused = false; 772 wps_state.paused = false;
734 wps_state.id3 = NULL; 773 wps_state.id3 = NULL;
735 wps_state.nid3 = NULL; 774 wps_state.nid3 = NULL;
775 wps_state.do_full_update = true;
776 /* add the WPS track event callbacks */
777 add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback);
778 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback);
736} 779}
737 780
738/* wps_state end*/ 781/* wps_state end*/