summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c39
-rw-r--r--apps/gui/gwps.c51
-rw-r--r--apps/gui/gwps.h1
-rw-r--r--apps/gui/wps_parser.c44
4 files changed, 76 insertions, 59 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index f32b002f69..189fc6fa31 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -348,33 +348,8 @@ bool gui_wps_display(struct gui_wps *gwps)
348 348
349bool gui_wps_update(struct gui_wps *gwps) 349bool gui_wps_update(struct gui_wps *gwps)
350{ 350{
351 bool track_changed = audio_has_changed_track();
352 struct mp3entry *id3 = gwps->state->id3; 351 struct mp3entry *id3 = gwps->state->id3;
353 352 bool retval;
354 gwps->state->nid3 = audio_next_track();
355 if (track_changed)
356 {
357 gwps->state->id3 = id3 = audio_current_track();
358
359 if (cuesheet_is_enabled() && id3->cuesheet_type
360 && strcmp(id3->path, curr_cue->audio_filename))
361 {
362 /* the current cuesheet isn't the right one any more */
363 /* We need to parse the new cuesheet */
364
365 char cuepath[MAX_PATH];
366
367 if (look_for_cuesheet_file(id3->path, cuepath) &&
368 parse_cuesheet(cuepath, curr_cue))
369 {
370 id3->cuesheet_type = 1;
371 strcpy(curr_cue->audio_filename, id3->path);
372 }
373
374 cue_spoof_id3(curr_cue, id3);
375 }
376 }
377
378 if (cuesheet_is_enabled() && id3->cuesheet_type 353 if (cuesheet_is_enabled() && id3->cuesheet_type
379 && (id3->elapsed < curr_cue->curr_track->offset 354 && (id3->elapsed < curr_cue->curr_track->offset
380 || (curr_cue->curr_track_idx < curr_cue->track_count - 1 355 || (curr_cue->curr_track_idx < curr_cue->track_count - 1
@@ -382,17 +357,15 @@ bool gui_wps_update(struct gui_wps *gwps)
382 { 357 {
383 /* We've changed tracks within the cuesheet : 358 /* We've changed tracks within the cuesheet :
384 we need to update the ID3 info and refresh the WPS */ 359 we need to update the ID3 info and refresh the WPS */
385 360 gwps->state->do_full_update = true;
386 track_changed = true;
387 cue_find_current_track(curr_cue, id3->elapsed); 361 cue_find_current_track(curr_cue, id3->elapsed);
388 cue_spoof_id3(curr_cue, id3); 362 cue_spoof_id3(curr_cue, id3);
389 } 363 }
390 364
391 if (track_changed) 365 retval = gui_wps_redraw(gwps, 0,
392 gwps->display->stop_scroll(); 366 gwps->state->do_full_update ?
393 367 WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC);
394 return gui_wps_redraw(gwps, 0, 368 return retval;
395 track_changed ? WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC);
396} 369}
397 370
398 371
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*/
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index 7888c3944c..1042e1a795 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -478,6 +478,7 @@ struct wps_state
478 bool wps_time_countup; 478 bool wps_time_countup;
479 struct mp3entry* id3; 479 struct mp3entry* id3;
480 struct mp3entry* nid3; 480 struct mp3entry* nid3;
481 bool do_full_update;
481}; 482};
482 483
483 484
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index ba2e2173f1..390df56cbb 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -215,16 +215,16 @@ static const struct wps_tag all_tags[] = {
215 parse_dir_level }, 215 parse_dir_level },
216 216
217 /* next file */ 217 /* next file */
218 { WPS_TOKEN_FILE_BITRATE, "Fb", WPS_REFRESH_DYNAMIC, NULL }, 218 { WPS_TOKEN_FILE_BITRATE, "Fb", WPS_REFRESH_STATIC, NULL },
219 { WPS_TOKEN_FILE_CODEC, "Fc", WPS_REFRESH_DYNAMIC, NULL }, 219 { WPS_TOKEN_FILE_CODEC, "Fc", WPS_REFRESH_STATIC, NULL },
220 { WPS_TOKEN_FILE_FREQUENCY, "Ff", WPS_REFRESH_DYNAMIC, NULL }, 220 { WPS_TOKEN_FILE_FREQUENCY, "Ff", WPS_REFRESH_STATIC, NULL },
221 { WPS_TOKEN_FILE_FREQUENCY_KHZ, "Fk", WPS_REFRESH_DYNAMIC, NULL }, 221 { WPS_TOKEN_FILE_FREQUENCY_KHZ, "Fk", WPS_REFRESH_STATIC, NULL },
222 { WPS_TOKEN_FILE_NAME_WITH_EXTENSION, "Fm", WPS_REFRESH_DYNAMIC, NULL }, 222 { WPS_TOKEN_FILE_NAME_WITH_EXTENSION, "Fm", WPS_REFRESH_STATIC, NULL },
223 { WPS_TOKEN_FILE_NAME, "Fn", WPS_REFRESH_DYNAMIC, NULL }, 223 { WPS_TOKEN_FILE_NAME, "Fn", WPS_REFRESH_STATIC, NULL },
224 { WPS_TOKEN_FILE_PATH, "Fp", WPS_REFRESH_DYNAMIC, NULL }, 224 { WPS_TOKEN_FILE_PATH, "Fp", WPS_REFRESH_STATIC, NULL },
225 { WPS_TOKEN_FILE_SIZE, "Fs", WPS_REFRESH_DYNAMIC, NULL }, 225 { WPS_TOKEN_FILE_SIZE, "Fs", WPS_REFRESH_STATIC, NULL },
226 { WPS_TOKEN_FILE_VBR, "Fv", WPS_REFRESH_DYNAMIC, NULL }, 226 { WPS_TOKEN_FILE_VBR, "Fv", WPS_REFRESH_STATIC, NULL },
227 { WPS_TOKEN_FILE_DIRECTORY, "D", WPS_REFRESH_DYNAMIC, 227 { WPS_TOKEN_FILE_DIRECTORY, "D", WPS_REFRESH_STATIC,
228 parse_dir_level }, 228 parse_dir_level },
229 229
230 /* current metadata */ 230 /* current metadata */
@@ -242,18 +242,18 @@ static const struct wps_tag all_tags[] = {
242 { WPS_TOKEN_METADATA_COMMENT, "iC", WPS_REFRESH_STATIC, NULL }, 242 { WPS_TOKEN_METADATA_COMMENT, "iC", WPS_REFRESH_STATIC, NULL },
243 243
244 /* next metadata */ 244 /* next metadata */
245 { WPS_TOKEN_METADATA_ARTIST, "Ia", WPS_REFRESH_DYNAMIC, NULL }, 245 { WPS_TOKEN_METADATA_ARTIST, "Ia", WPS_REFRESH_STATIC, NULL },
246 { WPS_TOKEN_METADATA_COMPOSER, "Ic", WPS_REFRESH_DYNAMIC, NULL }, 246 { WPS_TOKEN_METADATA_COMPOSER, "Ic", WPS_REFRESH_STATIC, NULL },
247 { WPS_TOKEN_METADATA_ALBUM, "Id", WPS_REFRESH_DYNAMIC, NULL }, 247 { WPS_TOKEN_METADATA_ALBUM, "Id", WPS_REFRESH_STATIC, NULL },
248 { WPS_TOKEN_METADATA_ALBUM_ARTIST, "IA", WPS_REFRESH_DYNAMIC, NULL }, 248 { WPS_TOKEN_METADATA_ALBUM_ARTIST, "IA", WPS_REFRESH_STATIC, NULL },
249 { WPS_TOKEN_METADATA_GROUPING, "IG", WPS_REFRESH_DYNAMIC, NULL }, 249 { WPS_TOKEN_METADATA_GROUPING, "IG", WPS_REFRESH_STATIC, NULL },
250 { WPS_TOKEN_METADATA_GENRE, "Ig", WPS_REFRESH_DYNAMIC, NULL }, 250 { WPS_TOKEN_METADATA_GENRE, "Ig", WPS_REFRESH_STATIC, NULL },
251 { WPS_TOKEN_METADATA_DISC_NUMBER, "Ik", WPS_REFRESH_DYNAMIC, NULL }, 251 { WPS_TOKEN_METADATA_DISC_NUMBER, "Ik", WPS_REFRESH_STATIC, NULL },
252 { WPS_TOKEN_METADATA_TRACK_NUMBER, "In", WPS_REFRESH_DYNAMIC, NULL }, 252 { WPS_TOKEN_METADATA_TRACK_NUMBER, "In", WPS_REFRESH_STATIC, NULL },
253 { WPS_TOKEN_METADATA_TRACK_TITLE, "It", WPS_REFRESH_DYNAMIC, NULL }, 253 { WPS_TOKEN_METADATA_TRACK_TITLE, "It", WPS_REFRESH_STATIC, NULL },
254 { WPS_TOKEN_METADATA_VERSION, "Iv", WPS_REFRESH_DYNAMIC, NULL }, 254 { WPS_TOKEN_METADATA_VERSION, "Iv", WPS_REFRESH_STATIC, NULL },
255 { WPS_TOKEN_METADATA_YEAR, "Iy", WPS_REFRESH_DYNAMIC, NULL }, 255 { WPS_TOKEN_METADATA_YEAR, "Iy", WPS_REFRESH_STATIC, NULL },
256 { WPS_TOKEN_METADATA_COMMENT, "IC", WPS_REFRESH_DYNAMIC, NULL }, 256 { WPS_TOKEN_METADATA_COMMENT, "IC", WPS_REFRESH_STATIC, NULL },
257 257
258#if (CONFIG_CODEC != MAS3507D) 258#if (CONFIG_CODEC != MAS3507D)
259 { WPS_TOKEN_SOUND_PITCH, "Sp", WPS_REFRESH_DYNAMIC, NULL }, 259 { WPS_TOKEN_SOUND_PITCH, "Sp", WPS_REFRESH_DYNAMIC, NULL },