Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
#define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */ #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */ - /* fades the volume */ bool wps_fading_out = false; void fade(bool fade_in, bool updatewps) if (!wps_state.paused) audio_resume(); #endif -#ifdef HAVE_LCD_CHARCELLS - gui_wps_display(); -#endif exit = true; break; return usb; } -bool gui_wps_display(void) +/* Wrapper for gui_wps_refresh, should be used to initially display the wps + * since it can revert to the build-in wps if the chosen wps is invalid */ + +bool gui_wps_display(struct gui_wps *gwps) { - int i; - if (!wps_state.id3 && !(audio_status() & AUDIO_STATUS_PLAY)) + struct screen *display = gwps->display; + struct wps_data *data = gwps->data; + int screen = display->screen_type; { - global_status.resume_index = -1; - splash(HZ, ID2P(LANG_END_PLAYLIST)); - return true; - } - else - { - FOR_NB_SCREENS(i) - { - /* Update the values in the first (default) viewport - in case the user - has modified the statusbar or colour settings */ -#ifdef HAVE_LCD_BITMAP + /* Update the values in the first (default) viewport - in case the user + has modified the statusbar or colour settings */ #if LCD_DEPTH > 1 - if (gui_wps[i].display->depth > 1) - { - gui_wps[i].data->viewports[0].vp.fg_pattern = gui_wps[i].display->get_foreground(); - gui_wps[i].data->viewports[0].vp.bg_pattern = gui_wps[i].display->get_background(); - } + if (display->depth > 1) + { + data->viewports[0].vp.fg_pattern = display->get_foreground(); + data->viewports[0].vp.bg_pattern = display->get_background(); + } #endif -#endif - gui_wps[i].display->clear_display(); - if (!gui_wps[i].data->wps_loaded) { - if ( !gui_wps[i].data->num_tokens ) { - /* set the default wps for the main-screen */ - if(i == 0) - { -#ifdef HAVE_LCD_BITMAP + display->clear_display(); + if (!data->wps_loaded) { + if ( !data->num_tokens ) { + /* set the default wps for the main-screen */ + if(screen == SCREEN_MAIN) + { #if LCD_DEPTH > 1 - unload_wps_backdrop(); + unload_wps_backdrop(); #endif - wps_data_load(gui_wps[i].data, - gui_wps[i].display, - "%s%?it<%?in<%in. |>%it|%fn>\n" - "%s%?ia<%ia|%?d2<%d2|(root)>>\n" - "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" - "\n" - "%al%pc/%pt%ar[%pp:%pe]\n" - "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" - "%pb\n" - "%pm\n", false); + wps_data_load(data, + display, +#ifdef HAVE_LCD_BITMAP + "%s%?it<%?in<%in. |>%it|%fn>\n" + "%s%?ia<%ia|%?d2<%d2|(root)>>\n" + "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" + "\n" + "%al%pc/%pt%ar[%pp:%pe]\n" + "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" + "%pb\n" + "%pm\n", false); #else - wps_data_load(gui_wps[i].data, - gui_wps[i].display, - "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n" - "%pc%?ps<*|/>%pt\n", false); + "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n" + "%pc%?ps<*|/>%pt\n", false); #endif - } -#if NB_SCREENS == 2 - /* set the default wps for the remote-screen */ - else if(i == 1) - { -#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 - unload_remote_wps_backdrop(); + } +#ifdef HAVE_REMOTE_LCD + /* set the default wps for the remote-screen */ + else if(screen == SCREEN_REMOTE) + { +#if LCD_REMOTE_DEPTH > 1 + unload_remote_wps_backdrop(); #endif - wps_data_load(gui_wps[i].data, - gui_wps[i].display, - "%s%?ia<%ia|%?d2<%d2|(root)>>\n" - "%s%?it<%?in<%in. |>%it|%fn>\n" - "%al%pc/%pt%ar[%pp:%pe]\n" - "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" - "%pb\n", false); - } + wps_data_load(data, + display, + "%s%?ia<%ia|%?d2<%d2|(root)>>\n" + "%s%?it<%?in<%in. |>%it|%fn>\n" + "%al%pc/%pt%ar[%pp:%pe]\n" + "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" + "%pb\n", false); + } #endif - } } } + else + { +#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 + if (screen == SCREEN_REMOTE) + show_remote_wps_backdrop(); + else if (screen == SCREEN_MAIN) +#endif +#if LCD_DEPTH > 1 + show_wps_backdrop(); +#endif + } } - yield(); - FOR_NB_SCREENS(i) - { - gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); - } - return false; + if (screen == SCREEN_MAIN) /* yield once per wps, not per screen */ + yield(); + return gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); } -bool update(struct gui_wps *gwps) +/* Update track change related stuff, handles cue sheets as well */ +bool gui_track_changed_update(struct gui_wps *gwps) { bool track_changed = audio_has_changed_track(); bool retcode = false; + struct mp3entry *id3 = gwps->state->id3; gwps->state->nid3 = audio_next_track(); if (track_changed) { gwps->display->stop_scroll(); - gwps->state->id3 = audio_current_track(); + gwps->state->id3 = id3 = audio_current_track(); - if (cuesheet_is_enabled() && gwps->state->id3->cuesheet_type - && strcmp(gwps->state->id3->path, curr_cue->audio_filename)) + if (cuesheet_is_enabled() && id3->cuesheet_type + && strcmp(id3->path, curr_cue->audio_filename)) { /* the current cuesheet isn't the right one any more */ /* We need to parse the new cuesheet */ char cuepath[MAX_PATH]; - if (look_for_cuesheet_file(gwps->state->id3->path, cuepath) && + if (look_for_cuesheet_file(id3->path, cuepath) && parse_cuesheet(cuepath, curr_cue)) { - gwps->state->id3->cuesheet_type = 1; - strcpy(curr_cue->audio_filename, gwps->state->id3->path); + id3->cuesheet_type = 1; + strcpy(curr_cue->audio_filename, id3->path); } - cue_spoof_id3(curr_cue, gwps->state->id3); + cue_spoof_id3(curr_cue, id3); } - - if (gui_wps_display()) - retcode = true; - else{ - gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); - } + gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); } - if (gwps->state->id3) + if (id3) { - if (cuesheet_is_enabled() && gwps->state->id3->cuesheet_type - && (gwps->state->id3->elapsed < curr_cue->curr_track->offset + if (cuesheet_is_enabled() && id3->cuesheet_type + && (id3->elapsed < curr_cue->curr_track->offset || (curr_cue->curr_track_idx < curr_cue->track_count - 1 - && gwps->state->id3->elapsed >= (curr_cue->curr_track+1)->offset))) + && id3->elapsed >= (curr_cue->curr_track+1)->offset))) { /* We've changed tracks within the cuesheet : we need to update the ID3 info and refresh the WPS */ - cue_find_current_track(curr_cue, gwps->state->id3->elapsed); - cue_spoof_id3(curr_cue, gwps->state->id3); + cue_find_current_track(curr_cue, id3->elapsed); + cue_spoof_id3(curr_cue, id3); gwps->display->stop_scroll(); - if (gui_wps_display()) - retcode = true; - else - gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); + retcode = gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); } else - gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); + retcode = gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); } return retcode; int line, bool scroll) { - int left_width = 0, left_xpos; int center_width = 0, center_xpos; int right_width = 0, right_xpos; struct wps_data *data = gwps->data; struct screen *display = gwps->display; struct wps_state *state = gwps->state; + struct mp3entry *id3 = state->id3; - if(!gwps || !data || !state || !display) + if(!data || !state || !display || !id3) + { return false; + } int v, line, i, subline_idx; unsigned char flags; } #endif - if (!state->id3) - { - display->stop_scroll(); - return false; - } - state->ff_rewind_count = ffwd_offset; /* disable any viewports which are conditionally displayed */ display->update(); #ifdef HAVE_BACKLIGHT - if (global_settings.caption_backlight && state->id3) + if (global_settings.caption_backlight) { /* turn on backlight n seconds before track ends, and turn it off n seconds into the new track. n == backlight_timeout, or 5s */ if ( n < 1000 ) n = 5000; /* use 5s if backlight is always on or off */ - if (((state->id3->elapsed < 1000) || - ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && + if (((id3->elapsed < 1000) || + ((id3->length - id3->elapsed) < (unsigned)n)) && (state->paused == false)) backlight_on(); } #endif #ifdef HAVE_REMOTE_LCD - if (global_settings.remote_caption_backlight && state->id3) + if (global_settings.remote_caption_backlight) { /* turn on remote backlight n seconds before track ends, and turn it off n seconds into the new track. n == remote_backlight_timeout, if ( n < 1000 ) n = 5000; /* use 5s if backlight is always on or off */ - if (((state->id3->elapsed < 1000) || - ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && + if (((id3->elapsed < 1000) || + ((id3->length - id3->elapsed) < (unsigned)n)) && (state->paused == false)) remote_backlight_on(); } #include "gwps.h" void fade(bool fade_in, bool updatewps); -bool gui_wps_display(void); +bool gui_wps_display(struct gui_wps *gui_wps); bool update_onvol_change(struct gui_wps * gwps); -bool update(struct gui_wps *gwps); +bool gui_track_changed_update(struct gui_wps *gwps); bool ffwd_rew(int button); void display_keylock_text(bool locked); #ifdef HAVE_LCD_CHARCELLS status_set_audio(true); status_set_param(false); -#else -#if LCD_DEPTH > 1 - show_wps_backdrop(); -#endif /* LCD_DEPTH > 1 */ #endif -#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 - show_remote_wps_backdrop(); -#endif gwps_fix_statusbars(); #ifdef AB_REPEAT_ENABLE wps_state.id3 = audio_current_track(); wps_state.nid3 = audio_next_track(); if (wps_state.id3) { - if (gui_wps_display()) + FOR_NB_SCREENS(i) { - gwps_leave_wps(); - return 0; + if (!gui_wps_display(&gui_wps[i])) + exit = true; } } - - restore = true; } while ( 1 ) { FOR_NB_SCREENS(i) { - if(update(&gui_wps[i])) + if(!gui_track_changed_update(&gui_wps[i])) exit = true; } update_track = false; #endif restore = false; restoretimer = RESTORE_WPS_INSTANTLY; - if (gui_wps_display()) { - exit = true; + FOR_NB_SCREENS(i) + { + if (!gui_wps_refresh(gui_wps, 0, WPS_REFRESH_ALL)) + exit = true; } } |