diff options
Diffstat (limited to 'apps/gui/gwps-common.c')
-rw-r--r-- | apps/gui/gwps-common.c | 228 |
1 files changed, 99 insertions, 129 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 005fefd0fb..198d62d891 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -74,8 +74,6 @@ | |||
74 | #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */ | 74 | #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */ |
75 | #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */ | 75 | #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */ |
76 | 76 | ||
77 | |||
78 | /* fades the volume */ | ||
79 | bool wps_fading_out = false; | 77 | bool wps_fading_out = false; |
80 | void fade(bool fade_in, bool updatewps) | 78 | void fade(bool fade_in, bool updatewps) |
81 | { | 79 | { |
@@ -100,7 +98,7 @@ void fade(bool fade_in, bool updatewps) | |||
100 | if (updatewps) | 98 | if (updatewps) |
101 | { | 99 | { |
102 | FOR_NB_SCREENS(i) | 100 | FOR_NB_SCREENS(i) |
103 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); | 101 | gui_wps_redraw(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); |
104 | } | 102 | } |
105 | sleep(1); | 103 | sleep(1); |
106 | } | 104 | } |
@@ -116,7 +114,7 @@ void fade(bool fade_in, bool updatewps) | |||
116 | if (updatewps) | 114 | if (updatewps) |
117 | { | 115 | { |
118 | FOR_NB_SCREENS(i) | 116 | FOR_NB_SCREENS(i) |
119 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); | 117 | gui_wps_redraw(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); |
120 | } | 118 | } |
121 | sleep(1); | 119 | sleep(1); |
122 | } | 120 | } |
@@ -135,12 +133,9 @@ void fade(bool fade_in, bool updatewps) | |||
135 | } | 133 | } |
136 | } | 134 | } |
137 | 135 | ||
138 | /* return true if screen restore is needed | ||
139 | return false otherwise | ||
140 | */ | ||
141 | bool update_onvol_change(struct gui_wps * gwps) | 136 | bool update_onvol_change(struct gui_wps * gwps) |
142 | { | 137 | { |
143 | gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); | 138 | gui_wps_redraw(gwps, 0, WPS_REFRESH_NON_STATIC); |
144 | 139 | ||
145 | #ifdef HAVE_LCD_CHARCELLS | 140 | #ifdef HAVE_LCD_CHARCELLS |
146 | splashf(0, "Vol: %3d dB", | 141 | splashf(0, "Vol: %3d dB", |
@@ -240,7 +235,7 @@ bool ffwd_rew(int button) | |||
240 | } | 235 | } |
241 | 236 | ||
242 | FOR_NB_SCREENS(i) | 237 | FOR_NB_SCREENS(i) |
243 | gui_wps_refresh(&gui_wps[i], | 238 | gui_wps_redraw(&gui_wps[i], |
244 | (wps_state.wps_time_countup == false)? | 239 | (wps_state.wps_time_countup == false)? |
245 | ff_rewind_count:-ff_rewind_count, | 240 | ff_rewind_count:-ff_rewind_count, |
246 | WPS_REFRESH_PLAYER_PROGRESS | | 241 | WPS_REFRESH_PLAYER_PROGRESS | |
@@ -259,7 +254,8 @@ bool ffwd_rew(int button) | |||
259 | audio_resume(); | 254 | audio_resume(); |
260 | #endif | 255 | #endif |
261 | #ifdef HAVE_LCD_CHARCELLS | 256 | #ifdef HAVE_LCD_CHARCELLS |
262 | gui_wps_display(); | 257 | FOR_NB_SCREENS(i) |
258 | gui_wps_redraw(gwps,0, WPS_REFRESH_ALL); | ||
263 | #endif | 259 | #endif |
264 | exit = true; | 260 | exit = true; |
265 | break; | 261 | break; |
@@ -278,145 +274,125 @@ bool ffwd_rew(int button) | |||
278 | return usb; | 274 | return usb; |
279 | } | 275 | } |
280 | 276 | ||
281 | bool gui_wps_display(void) | 277 | bool gui_wps_display(struct gui_wps *gwps) |
282 | { | 278 | { |
283 | int i; | 279 | struct screen *display = gwps->display; |
284 | if (!wps_state.id3 && !(audio_status() & AUDIO_STATUS_PLAY)) | 280 | struct wps_data *data = gwps->data; |
281 | int screen = display->screen_type; | ||
282 | |||
283 | /* Update the values in the first (default) viewport - in case the user | ||
284 | has modified the statusbar or colour settings */ | ||
285 | #if LCD_DEPTH > 1 | ||
286 | if (display->depth > 1) | ||
285 | { | 287 | { |
286 | global_status.resume_index = -1; | 288 | data->viewports[0].vp.fg_pattern = display->get_foreground(); |
287 | splash(HZ, ID2P(LANG_END_PLAYLIST)); | 289 | data->viewports[0].vp.bg_pattern = display->get_background(); |
288 | return true; | ||
289 | } | 290 | } |
290 | else | ||
291 | { | ||
292 | FOR_NB_SCREENS(i) | ||
293 | { | ||
294 | /* Update the values in the first (default) viewport - in case the user | ||
295 | has modified the statusbar or colour settings */ | ||
296 | #ifdef HAVE_LCD_BITMAP | ||
297 | #if LCD_DEPTH > 1 | ||
298 | if (gui_wps[i].display->depth > 1) | ||
299 | { | ||
300 | gui_wps[i].data->viewports[0].vp.fg_pattern = gui_wps[i].display->get_foreground(); | ||
301 | gui_wps[i].data->viewports[0].vp.bg_pattern = gui_wps[i].display->get_background(); | ||
302 | } | ||
303 | #endif | 291 | #endif |
304 | #endif | 292 | display->clear_display(); |
305 | gui_wps[i].display->clear_display(); | 293 | if (!data->wps_loaded) { |
306 | if (!gui_wps[i].data->wps_loaded) { | 294 | if ( !data->num_tokens ) { |
307 | if ( !gui_wps[i].data->num_tokens ) { | 295 | /* set the default wps for the main-screen */ |
308 | /* set the default wps for the main-screen */ | 296 | if(screen == SCREEN_MAIN) |
309 | if(i == 0) | 297 | { |
310 | { | ||
311 | #ifdef HAVE_LCD_BITMAP | ||
312 | #if LCD_DEPTH > 1 | 298 | #if LCD_DEPTH > 1 |
313 | unload_wps_backdrop(); | 299 | unload_wps_backdrop(); |
314 | #endif | 300 | #endif |
315 | wps_data_load(gui_wps[i].data, | 301 | wps_data_load(data, |
316 | gui_wps[i].display, | 302 | display, |
317 | "%s%?it<%?in<%in. |>%it|%fn>\n" | 303 | #ifdef HAVE_LCD_BITMAP |
318 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" | 304 | "%s%?it<%?in<%in. |>%it|%fn>\n" |
319 | "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" | 305 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" |
320 | "\n" | 306 | "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" |
321 | "%al%pc/%pt%ar[%pp:%pe]\n" | 307 | "\n" |
322 | "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" | 308 | "%al%pc/%pt%ar[%pp:%pe]\n" |
323 | "%pb\n" | 309 | "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" |
324 | "%pm\n", false); | 310 | "%pb\n" |
311 | "%pm\n", false); | ||
325 | #else | 312 | #else |
326 | wps_data_load(gui_wps[i].data, | 313 | "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n" |
327 | gui_wps[i].display, | 314 | "%pc%?ps<*|/>%pt\n", false); |
328 | "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n" | ||
329 | "%pc%?ps<*|/>%pt\n", false); | ||
330 | #endif | 315 | #endif |
331 | } | 316 | } |
332 | #if NB_SCREENS == 2 | 317 | #ifdef HAVE_REMOTE_LCD |
333 | /* set the default wps for the remote-screen */ | 318 | /* set the default wps for the remote-screen */ |
334 | else if(i == 1) | 319 | else if(screen == SCREEN_REMOTE) |
335 | { | 320 | { |
336 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | 321 | #if LCD_REMOTE_DEPTH > 1 |
337 | unload_remote_wps_backdrop(); | 322 | unload_remote_wps_backdrop(); |
338 | #endif | 323 | #endif |
339 | wps_data_load(gui_wps[i].data, | 324 | wps_data_load(data, |
340 | gui_wps[i].display, | 325 | display, |
341 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" | 326 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" |
342 | "%s%?it<%?in<%in. |>%it|%fn>\n" | 327 | "%s%?it<%?in<%in. |>%it|%fn>\n" |
343 | "%al%pc/%pt%ar[%pp:%pe]\n" | 328 | "%al%pc/%pt%ar[%pp:%pe]\n" |
344 | "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" | 329 | "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" |
345 | "%pb\n", false); | 330 | "%pb\n", false); |
346 | } | 331 | } |
347 | #endif | 332 | #endif |
348 | } | ||
349 | } | ||
350 | } | 333 | } |
351 | } | 334 | } |
352 | yield(); | 335 | else |
353 | FOR_NB_SCREENS(i) | ||
354 | { | 336 | { |
355 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); | 337 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
338 | if (screen == SCREEN_REMOTE) | ||
339 | show_remote_wps_backdrop(); | ||
340 | else if (screen == SCREEN_MAIN) | ||
341 | #endif | ||
342 | #if LCD_DEPTH > 1 | ||
343 | show_wps_backdrop(); | ||
344 | #endif | ||
356 | } | 345 | } |
357 | return false; | 346 | return gui_wps_redraw(gwps, 0, WPS_REFRESH_ALL); |
358 | } | 347 | } |
359 | 348 | ||
360 | bool update(struct gui_wps *gwps) | 349 | bool gui_wps_update(struct gui_wps *gwps) |
361 | { | 350 | { |
362 | bool track_changed = audio_has_changed_track(); | 351 | bool track_changed = audio_has_changed_track(); |
363 | bool retcode = false; | 352 | struct mp3entry *id3 = gwps->state->id3; |
364 | 353 | ||
365 | gwps->state->nid3 = audio_next_track(); | 354 | gwps->state->nid3 = audio_next_track(); |
366 | if (track_changed) | 355 | if (track_changed) |
367 | { | 356 | { |
368 | gwps->display->stop_scroll(); | 357 | gwps->state->id3 = id3 = audio_current_track(); |
369 | gwps->state->id3 = audio_current_track(); | ||
370 | 358 | ||
371 | if (cuesheet_is_enabled() && gwps->state->id3->cuesheet_type | 359 | if (cuesheet_is_enabled() && id3->cuesheet_type |
372 | && strcmp(gwps->state->id3->path, curr_cue->audio_filename)) | 360 | && strcmp(id3->path, curr_cue->audio_filename)) |
373 | { | 361 | { |
374 | /* the current cuesheet isn't the right one any more */ | 362 | /* the current cuesheet isn't the right one any more */ |
375 | /* We need to parse the new cuesheet */ | 363 | /* We need to parse the new cuesheet */ |
376 | 364 | ||
377 | char cuepath[MAX_PATH]; | 365 | char cuepath[MAX_PATH]; |
378 | 366 | ||
379 | if (look_for_cuesheet_file(gwps->state->id3->path, cuepath) && | 367 | if (look_for_cuesheet_file(id3->path, cuepath) && |
380 | parse_cuesheet(cuepath, curr_cue)) | 368 | parse_cuesheet(cuepath, curr_cue)) |
381 | { | 369 | { |
382 | gwps->state->id3->cuesheet_type = 1; | 370 | id3->cuesheet_type = 1; |
383 | strcpy(curr_cue->audio_filename, gwps->state->id3->path); | 371 | strcpy(curr_cue->audio_filename, id3->path); |
384 | } | 372 | } |
385 | 373 | ||
386 | cue_spoof_id3(curr_cue, gwps->state->id3); | 374 | cue_spoof_id3(curr_cue, id3); |
387 | } | ||
388 | |||
389 | if (gui_wps_display()) | ||
390 | retcode = true; | ||
391 | else{ | ||
392 | gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); | ||
393 | } | 375 | } |
394 | } | 376 | } |
395 | 377 | ||
396 | if (gwps->state->id3) | 378 | if (cuesheet_is_enabled() && id3->cuesheet_type |
379 | && (id3->elapsed < curr_cue->curr_track->offset | ||
380 | || (curr_cue->curr_track_idx < curr_cue->track_count - 1 | ||
381 | && id3->elapsed >= (curr_cue->curr_track+1)->offset))) | ||
397 | { | 382 | { |
398 | if (cuesheet_is_enabled() && gwps->state->id3->cuesheet_type | 383 | /* We've changed tracks within the cuesheet : |
399 | && (gwps->state->id3->elapsed < curr_cue->curr_track->offset | 384 | we need to update the ID3 info and refresh the WPS */ |
400 | || (curr_cue->curr_track_idx < curr_cue->track_count - 1 | ||
401 | && gwps->state->id3->elapsed >= (curr_cue->curr_track+1)->offset))) | ||
402 | { | ||
403 | /* We've changed tracks within the cuesheet : | ||
404 | we need to update the ID3 info and refresh the WPS */ | ||
405 | |||
406 | cue_find_current_track(curr_cue, gwps->state->id3->elapsed); | ||
407 | cue_spoof_id3(curr_cue, gwps->state->id3); | ||
408 | 385 | ||
409 | gwps->display->stop_scroll(); | 386 | track_changed = true; |
410 | if (gui_wps_display()) | 387 | cue_find_current_track(curr_cue, id3->elapsed); |
411 | retcode = true; | 388 | cue_spoof_id3(curr_cue, id3); |
412 | else | ||
413 | gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL); | ||
414 | } | ||
415 | else | ||
416 | gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); | ||
417 | } | 389 | } |
418 | 390 | ||
419 | return retcode; | 391 | if (track_changed) |
392 | gwps->display->stop_scroll(); | ||
393 | |||
394 | return gui_wps_redraw(gwps, 0, | ||
395 | track_changed ? WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC); | ||
420 | } | 396 | } |
421 | 397 | ||
422 | 398 | ||
@@ -1745,7 +1721,6 @@ static void write_line(struct screen *display, | |||
1745 | int line, | 1721 | int line, |
1746 | bool scroll) | 1722 | bool scroll) |
1747 | { | 1723 | { |
1748 | |||
1749 | int left_width = 0, left_xpos; | 1724 | int left_width = 0, left_xpos; |
1750 | int center_width = 0, center_xpos; | 1725 | int center_width = 0, center_xpos; |
1751 | int right_width = 0, right_xpos; | 1726 | int right_width = 0, right_xpos; |
@@ -1898,22 +1873,23 @@ static void write_line(struct screen *display, | |||
1898 | } | 1873 | } |
1899 | } | 1874 | } |
1900 | 1875 | ||
1901 | /* Refresh the WPS according to refresh_mode. */ | 1876 | bool gui_wps_redraw(struct gui_wps *gwps, |
1902 | bool gui_wps_refresh(struct gui_wps *gwps, | ||
1903 | int ffwd_offset, | 1877 | int ffwd_offset, |
1904 | unsigned char refresh_mode) | 1878 | unsigned refresh_mode) |
1905 | { | 1879 | { |
1906 | struct wps_data *data = gwps->data; | 1880 | struct wps_data *data = gwps->data; |
1907 | struct screen *display = gwps->display; | 1881 | struct screen *display = gwps->display; |
1908 | struct wps_state *state = gwps->state; | 1882 | struct wps_state *state = gwps->state; |
1883 | struct mp3entry *id3 = state->id3; | ||
1909 | 1884 | ||
1910 | if(!gwps || !data || !state || !display) | 1885 | if(!data || !state || !display || !id3) |
1886 | { | ||
1911 | return false; | 1887 | return false; |
1888 | } | ||
1912 | 1889 | ||
1913 | int v, line, i, subline_idx; | 1890 | int v, line, i, subline_idx; |
1914 | unsigned char flags; | 1891 | unsigned flags; |
1915 | char linebuf[MAX_PATH]; | 1892 | char linebuf[MAX_PATH]; |
1916 | unsigned char vp_refresh_mode; | ||
1917 | 1893 | ||
1918 | struct align_pos align; | 1894 | struct align_pos align; |
1919 | align.left = NULL; | 1895 | align.left = NULL; |
@@ -1955,12 +1931,6 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1955 | } | 1931 | } |
1956 | #endif | 1932 | #endif |
1957 | 1933 | ||
1958 | if (!state->id3) | ||
1959 | { | ||
1960 | display->stop_scroll(); | ||
1961 | return false; | ||
1962 | } | ||
1963 | |||
1964 | state->ff_rewind_count = ffwd_offset; | 1934 | state->ff_rewind_count = ffwd_offset; |
1965 | 1935 | ||
1966 | /* disable any viewports which are conditionally displayed */ | 1936 | /* disable any viewports which are conditionally displayed */ |
@@ -1977,8 +1947,8 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1977 | for (v = 0; v < data->num_viewports; v++) | 1947 | for (v = 0; v < data->num_viewports; v++) |
1978 | { | 1948 | { |
1979 | struct wps_viewport *wps_vp = &(data->viewports[v]); | 1949 | struct wps_viewport *wps_vp = &(data->viewports[v]); |
1950 | unsigned vp_refresh_mode = refresh_mode; | ||
1980 | display->set_viewport(&wps_vp->vp); | 1951 | display->set_viewport(&wps_vp->vp); |
1981 | vp_refresh_mode = refresh_mode; | ||
1982 | 1952 | ||
1983 | #ifdef HAVE_LCD_BITMAP | 1953 | #ifdef HAVE_LCD_BITMAP |
1984 | /* Set images to not to be displayed */ | 1954 | /* Set images to not to be displayed */ |
@@ -2114,7 +2084,7 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2114 | display->update(); | 2084 | display->update(); |
2115 | 2085 | ||
2116 | #ifdef HAVE_BACKLIGHT | 2086 | #ifdef HAVE_BACKLIGHT |
2117 | if (global_settings.caption_backlight && state->id3) | 2087 | if (global_settings.caption_backlight) |
2118 | { | 2088 | { |
2119 | /* turn on backlight n seconds before track ends, and turn it off n | 2089 | /* turn on backlight n seconds before track ends, and turn it off n |
2120 | seconds into the new track. n == backlight_timeout, or 5s */ | 2090 | seconds into the new track. n == backlight_timeout, or 5s */ |
@@ -2123,14 +2093,14 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2123 | if ( n < 1000 ) | 2093 | if ( n < 1000 ) |
2124 | n = 5000; /* use 5s if backlight is always on or off */ | 2094 | n = 5000; /* use 5s if backlight is always on or off */ |
2125 | 2095 | ||
2126 | if (((state->id3->elapsed < 1000) || | 2096 | if (((id3->elapsed < 1000) || |
2127 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && | 2097 | ((id3->length - id3->elapsed) < (unsigned)n)) && |
2128 | (state->paused == false)) | 2098 | (state->paused == false)) |
2129 | backlight_on(); | 2099 | backlight_on(); |
2130 | } | 2100 | } |
2131 | #endif | 2101 | #endif |
2132 | #ifdef HAVE_REMOTE_LCD | 2102 | #ifdef HAVE_REMOTE_LCD |
2133 | if (global_settings.remote_caption_backlight && state->id3) | 2103 | if (global_settings.remote_caption_backlight) |
2134 | { | 2104 | { |
2135 | /* turn on remote backlight n seconds before track ends, and turn it | 2105 | /* turn on remote backlight n seconds before track ends, and turn it |
2136 | off n seconds into the new track. n == remote_backlight_timeout, | 2106 | off n seconds into the new track. n == remote_backlight_timeout, |
@@ -2140,8 +2110,8 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2140 | if ( n < 1000 ) | 2110 | if ( n < 1000 ) |
2141 | n = 5000; /* use 5s if backlight is always on or off */ | 2111 | n = 5000; /* use 5s if backlight is always on or off */ |
2142 | 2112 | ||
2143 | if (((state->id3->elapsed < 1000) || | 2113 | if (((id3->elapsed < 1000) || |
2144 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && | 2114 | ((id3->length - id3->elapsed) < (unsigned)n)) && |
2145 | (state->paused == false)) | 2115 | (state->paused == false)) |
2146 | remote_backlight_on(); | 2116 | remote_backlight_on(); |
2147 | } | 2117 | } |