diff options
Diffstat (limited to 'apps/gui/wps.c')
-rw-r--r-- | apps/gui/wps.c | 1216 |
1 files changed, 1216 insertions, 0 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c new file mode 100644 index 0000000000..4a7de875d2 --- /dev/null +++ b/apps/gui/wps.c | |||
@@ -0,0 +1,1216 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Jerome Kuptz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <stdlib.h> | ||
24 | #include "config.h" | ||
25 | |||
26 | #include "system.h" | ||
27 | #include "file.h" | ||
28 | #include "lcd.h" | ||
29 | #include "font.h" | ||
30 | #include "backlight.h" | ||
31 | #include "action.h" | ||
32 | #include "kernel.h" | ||
33 | #include "filetypes.h" | ||
34 | #include "debug.h" | ||
35 | #include "sprintf.h" | ||
36 | #include "settings.h" | ||
37 | #include "skin_engine/skin_engine.h" | ||
38 | #include "mp3_playback.h" | ||
39 | #include "audio.h" | ||
40 | #include "usb.h" | ||
41 | #include "status.h" | ||
42 | #include "storage.h" | ||
43 | #include "screens.h" | ||
44 | #include "playlist.h" | ||
45 | #ifdef HAVE_LCD_BITMAP | ||
46 | #include "icons.h" | ||
47 | #include "peakmeter.h" | ||
48 | #endif | ||
49 | #include "lang.h" | ||
50 | #include "bookmark.h" | ||
51 | #include "misc.h" | ||
52 | #include "sound.h" | ||
53 | #include "onplay.h" | ||
54 | #include "abrepeat.h" | ||
55 | #include "playback.h" | ||
56 | #include "splash.h" | ||
57 | #include "cuesheet.h" | ||
58 | #include "ata_idle_notify.h" | ||
59 | #include "root_menu.h" | ||
60 | #include "backdrop.h" | ||
61 | #include "quickscreen.h" | ||
62 | #include "pitchscreen.h" | ||
63 | #include "appevents.h" | ||
64 | #include "viewport.h" | ||
65 | #include "pcmbuf.h" | ||
66 | #include "option_select.h" | ||
67 | #include "dsp.h" | ||
68 | #include "playlist_viewer.h" | ||
69 | #include "wps.h" | ||
70 | |||
71 | #define RESTORE_WPS_INSTANTLY 0l | ||
72 | #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) | ||
73 | /* in milliseconds */ | ||
74 | #define DEFAULT_SKIP_TRESH 3000ul | ||
75 | |||
76 | static int wpsbars; | ||
77 | /* currently only one wps_state is needed */ | ||
78 | struct wps_state wps_state; | ||
79 | struct gui_wps gui_wps[NB_SCREENS]; | ||
80 | static struct wps_data wps_datas[NB_SCREENS]; | ||
81 | |||
82 | /* initial setup of wps_data */ | ||
83 | static void wps_state_init(void); | ||
84 | static void track_changed_callback(void *param); | ||
85 | static void nextid3available_callback(void* param); | ||
86 | |||
87 | |||
88 | |||
89 | #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ | ||
90 | /* 3% of 30min file == 54s step size */ | ||
91 | #define MIN_FF_REWIND_STEP 500 | ||
92 | |||
93 | bool wps_fading_out = false; | ||
94 | void fade(bool fade_in, bool updatewps) | ||
95 | { | ||
96 | int fp_global_vol = global_settings.volume << 8; | ||
97 | int fp_min_vol = sound_min(SOUND_VOLUME) << 8; | ||
98 | int fp_step = (fp_global_vol - fp_min_vol) / 30; | ||
99 | int i; | ||
100 | wps_fading_out = !fade_in; | ||
101 | if (fade_in) { | ||
102 | /* fade in */ | ||
103 | int fp_volume = fp_min_vol; | ||
104 | |||
105 | /* zero out the sound */ | ||
106 | sound_set_volume(fp_min_vol >> 8); | ||
107 | |||
108 | sleep(HZ/10); /* let audio thread run */ | ||
109 | audio_resume(); | ||
110 | |||
111 | while (fp_volume < fp_global_vol - fp_step) { | ||
112 | fp_volume += fp_step; | ||
113 | sound_set_volume(fp_volume >> 8); | ||
114 | if (updatewps) | ||
115 | { | ||
116 | FOR_NB_SCREENS(i) | ||
117 | skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC); | ||
118 | } | ||
119 | sleep(1); | ||
120 | } | ||
121 | sound_set_volume(global_settings.volume); | ||
122 | } | ||
123 | else { | ||
124 | /* fade out */ | ||
125 | int fp_volume = fp_global_vol; | ||
126 | |||
127 | while (fp_volume > fp_min_vol + fp_step) { | ||
128 | fp_volume -= fp_step; | ||
129 | sound_set_volume(fp_volume >> 8); | ||
130 | if (updatewps) | ||
131 | { | ||
132 | FOR_NB_SCREENS(i) | ||
133 | skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC); | ||
134 | } | ||
135 | sleep(1); | ||
136 | } | ||
137 | audio_pause(); | ||
138 | wps_fading_out = false; | ||
139 | #if CONFIG_CODEC != SWCODEC | ||
140 | #ifndef SIMULATOR | ||
141 | /* let audio thread run and wait for the mas to run out of data */ | ||
142 | while (!mp3_pause_done()) | ||
143 | #endif | ||
144 | sleep(HZ/10); | ||
145 | #endif | ||
146 | |||
147 | /* reset volume to what it was before the fade */ | ||
148 | sound_set_volume(global_settings.volume); | ||
149 | } | ||
150 | } | ||
151 | bool is_wps_fading(void) | ||
152 | { | ||
153 | return wps_fading_out; | ||
154 | } | ||
155 | |||
156 | bool update_onvol_change(struct gui_wps * gwps) | ||
157 | { | ||
158 | skin_update(gwps, WPS_REFRESH_NON_STATIC); | ||
159 | |||
160 | #ifdef HAVE_LCD_CHARCELLS | ||
161 | splashf(0, "Vol: %3d dB", | ||
162 | sound_val2phys(SOUND_VOLUME, global_settings.volume)); | ||
163 | return true; | ||
164 | #endif | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | bool ffwd_rew(int button) | ||
169 | { | ||
170 | unsigned int step = 0; /* current ff/rewind step */ | ||
171 | unsigned int max_step = 0; /* maximum ff/rewind step */ | ||
172 | int ff_rewind_count = 0; /* current ff/rewind count (in ticks) */ | ||
173 | int direction = -1; /* forward=1 or backward=-1 */ | ||
174 | bool exit = false; | ||
175 | bool usb = false; | ||
176 | int i = 0; | ||
177 | const long ff_rw_accel = (global_settings.ff_rewind_accel + 3); | ||
178 | |||
179 | if (button == ACTION_NONE) | ||
180 | { | ||
181 | status_set_ffmode(0); | ||
182 | return usb; | ||
183 | } | ||
184 | while (!exit) | ||
185 | { | ||
186 | switch ( button ) | ||
187 | { | ||
188 | case ACTION_WPS_SEEKFWD: | ||
189 | direction = 1; | ||
190 | case ACTION_WPS_SEEKBACK: | ||
191 | if (wps_state.ff_rewind) | ||
192 | { | ||
193 | if (direction == 1) | ||
194 | { | ||
195 | /* fast forwarding, calc max step relative to end */ | ||
196 | max_step = (wps_state.id3->length - | ||
197 | (wps_state.id3->elapsed + | ||
198 | ff_rewind_count)) * | ||
199 | FF_REWIND_MAX_PERCENT / 100; | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | /* rewinding, calc max step relative to start */ | ||
204 | max_step = (wps_state.id3->elapsed + ff_rewind_count) * | ||
205 | FF_REWIND_MAX_PERCENT / 100; | ||
206 | } | ||
207 | |||
208 | max_step = MAX(max_step, MIN_FF_REWIND_STEP); | ||
209 | |||
210 | if (step > max_step) | ||
211 | step = max_step; | ||
212 | |||
213 | ff_rewind_count += step * direction; | ||
214 | |||
215 | /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */ | ||
216 | step += step >> ff_rw_accel; | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | if ( (audio_status() & AUDIO_STATUS_PLAY) && | ||
221 | wps_state.id3 && wps_state.id3->length ) | ||
222 | { | ||
223 | if (!wps_state.paused) | ||
224 | #if (CONFIG_CODEC == SWCODEC) | ||
225 | audio_pre_ff_rewind(); | ||
226 | #else | ||
227 | audio_pause(); | ||
228 | #endif | ||
229 | #if CONFIG_KEYPAD == PLAYER_PAD | ||
230 | FOR_NB_SCREENS(i) | ||
231 | gui_wps[i].display->stop_scroll(); | ||
232 | #endif | ||
233 | if (direction > 0) | ||
234 | status_set_ffmode(STATUS_FASTFORWARD); | ||
235 | else | ||
236 | status_set_ffmode(STATUS_FASTBACKWARD); | ||
237 | |||
238 | wps_state.ff_rewind = true; | ||
239 | |||
240 | step = 1000 * global_settings.ff_rewind_min_step; | ||
241 | } | ||
242 | else | ||
243 | break; | ||
244 | } | ||
245 | |||
246 | if (direction > 0) { | ||
247 | if ((wps_state.id3->elapsed + ff_rewind_count) > | ||
248 | wps_state.id3->length) | ||
249 | ff_rewind_count = wps_state.id3->length - | ||
250 | wps_state.id3->elapsed; | ||
251 | } | ||
252 | else { | ||
253 | if ((int)(wps_state.id3->elapsed + ff_rewind_count) < 0) | ||
254 | ff_rewind_count = -wps_state.id3->elapsed; | ||
255 | } | ||
256 | |||
257 | /* set the wps state ff_rewind_count so the progess info | ||
258 | displays corectly */ | ||
259 | wps_state.ff_rewind_count = (wps_state.wps_time_countup == false)? | ||
260 | ff_rewind_count:-ff_rewind_count; | ||
261 | FOR_NB_SCREENS(i) | ||
262 | { | ||
263 | skin_update(&gui_wps[i], | ||
264 | WPS_REFRESH_PLAYER_PROGRESS | | ||
265 | WPS_REFRESH_DYNAMIC); | ||
266 | } | ||
267 | |||
268 | break; | ||
269 | |||
270 | case ACTION_WPS_STOPSEEK: | ||
271 | wps_state.id3->elapsed = wps_state.id3->elapsed+ff_rewind_count; | ||
272 | audio_ff_rewind(wps_state.id3->elapsed); | ||
273 | wps_state.ff_rewind_count = 0; | ||
274 | wps_state.ff_rewind = false; | ||
275 | status_set_ffmode(0); | ||
276 | #if (CONFIG_CODEC != SWCODEC) | ||
277 | if (!wps_state.paused) | ||
278 | audio_resume(); | ||
279 | #endif | ||
280 | #ifdef HAVE_LCD_CHARCELLS | ||
281 | FOR_NB_SCREENS(i) | ||
282 | skin_update(&gui_wps[i], WPS_REFRESH_ALL); | ||
283 | #endif | ||
284 | exit = true; | ||
285 | break; | ||
286 | |||
287 | default: | ||
288 | if(default_event_handler(button) == SYS_USB_CONNECTED) { | ||
289 | status_set_ffmode(0); | ||
290 | usb = true; | ||
291 | exit = true; | ||
292 | } | ||
293 | break; | ||
294 | } | ||
295 | if (!exit) | ||
296 | { | ||
297 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); | ||
298 | #ifdef HAVE_TOUCHSCREEN | ||
299 | if (button == ACTION_TOUCHSCREEN) | ||
300 | button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data); | ||
301 | #endif | ||
302 | } | ||
303 | } | ||
304 | return usb; | ||
305 | } | ||
306 | |||
307 | |||
308 | void display_keylock_text(bool locked) | ||
309 | { | ||
310 | int i; | ||
311 | FOR_NB_SCREENS(i) | ||
312 | gui_wps[i].display->stop_scroll(); | ||
313 | |||
314 | splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF)); | ||
315 | } | ||
316 | |||
317 | |||
318 | |||
319 | |||
320 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) | ||
321 | static void gwps_caption_backlight(struct wps_state *state) | ||
322 | { | ||
323 | if (state && state->id3) | ||
324 | { | ||
325 | #ifdef HAVE_BACKLIGHT | ||
326 | if (global_settings.caption_backlight) | ||
327 | { | ||
328 | /* turn on backlight n seconds before track ends, and turn it off n | ||
329 | seconds into the new track. n == backlight_timeout, or 5s */ | ||
330 | int n = global_settings.backlight_timeout * 1000; | ||
331 | |||
332 | if ( n < 1000 ) | ||
333 | n = 5000; /* use 5s if backlight is always on or off */ | ||
334 | |||
335 | if (((state->id3->elapsed < 1000) || | ||
336 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && | ||
337 | (state->paused == false)) | ||
338 | backlight_on(); | ||
339 | } | ||
340 | #endif | ||
341 | #ifdef HAVE_REMOTE_LCD | ||
342 | if (global_settings.remote_caption_backlight) | ||
343 | { | ||
344 | /* turn on remote backlight n seconds before track ends, and turn it | ||
345 | off n seconds into the new track. n == remote_backlight_timeout, | ||
346 | or 5s */ | ||
347 | int n = global_settings.remote_backlight_timeout * 1000; | ||
348 | |||
349 | if ( n < 1000 ) | ||
350 | n = 5000; /* use 5s if backlight is always on or off */ | ||
351 | |||
352 | if (((state->id3->elapsed < 1000) || | ||
353 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && | ||
354 | (state->paused == false)) | ||
355 | remote_backlight_on(); | ||
356 | } | ||
357 | #endif | ||
358 | } | ||
359 | } | ||
360 | #endif | ||
361 | |||
362 | |||
363 | static void change_dir(int direction) | ||
364 | { | ||
365 | if (global_settings.prevent_skip) | ||
366 | return; | ||
367 | |||
368 | if (direction < 0) | ||
369 | audio_prev_dir(); | ||
370 | else if (direction > 0) | ||
371 | audio_next_dir(); | ||
372 | /* prevent the next dir to immediatly start being ffw'd */ | ||
373 | action_wait_for_release(); | ||
374 | } | ||
375 | |||
376 | static void prev_track(unsigned long skip_thresh) | ||
377 | { | ||
378 | if (wps_state.id3->elapsed < skip_thresh) | ||
379 | { | ||
380 | audio_prev(); | ||
381 | return; | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | if (wps_state.id3->cuesheet) | ||
386 | { | ||
387 | curr_cuesheet_skip(wps_state.id3->cuesheet, -1, wps_state.id3->elapsed); | ||
388 | return; | ||
389 | } | ||
390 | |||
391 | if (!wps_state.paused) | ||
392 | #if (CONFIG_CODEC == SWCODEC) | ||
393 | audio_pre_ff_rewind(); | ||
394 | #else | ||
395 | audio_pause(); | ||
396 | #endif | ||
397 | |||
398 | audio_ff_rewind(0); | ||
399 | |||
400 | #if (CONFIG_CODEC != SWCODEC) | ||
401 | if (!wps_state.paused) | ||
402 | audio_resume(); | ||
403 | #endif | ||
404 | } | ||
405 | } | ||
406 | |||
407 | static void next_track(void) | ||
408 | { | ||
409 | /* take care of if we're playing a cuesheet */ | ||
410 | if (wps_state.id3->cuesheet) | ||
411 | { | ||
412 | if (curr_cuesheet_skip(wps_state.id3->cuesheet, 1, wps_state.id3->elapsed)) | ||
413 | { | ||
414 | /* if the result was false, then we really want | ||
415 | to skip to the next track */ | ||
416 | return; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | audio_next(); | ||
421 | } | ||
422 | |||
423 | static void play_hop(int direction) | ||
424 | { | ||
425 | unsigned long step = ((unsigned long)global_settings.skip_length)*1000; | ||
426 | unsigned long elapsed = wps_state.id3->elapsed; | ||
427 | unsigned long remaining = wps_state.id3->length - elapsed; | ||
428 | |||
429 | if (!global_settings.prevent_skip && | ||
430 | (!step || | ||
431 | (direction > 0 && step >= remaining) || | ||
432 | (direction < 0 && elapsed < DEFAULT_SKIP_TRESH))) | ||
433 | { /* Do normal track skipping */ | ||
434 | if (direction > 0) | ||
435 | next_track(); | ||
436 | else if (direction < 0) | ||
437 | prev_track(DEFAULT_SKIP_TRESH); | ||
438 | return; | ||
439 | } | ||
440 | |||
441 | if (direction == 1 && step >= remaining) | ||
442 | { | ||
443 | #if CONFIG_CODEC == SWCODEC | ||
444 | if(global_settings.beep) | ||
445 | pcmbuf_beep(1000, 150, 1500*global_settings.beep); | ||
446 | #endif | ||
447 | return; | ||
448 | } | ||
449 | else if ((direction == -1 && elapsed < step)) | ||
450 | { | ||
451 | elapsed = 0; | ||
452 | } | ||
453 | else | ||
454 | { | ||
455 | elapsed += step * direction; | ||
456 | } | ||
457 | if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) | ||
458 | { | ||
459 | #if (CONFIG_CODEC == SWCODEC) | ||
460 | audio_pre_ff_rewind(); | ||
461 | #else | ||
462 | audio_pause(); | ||
463 | #endif | ||
464 | } | ||
465 | audio_ff_rewind(wps_state.id3->elapsed = elapsed); | ||
466 | #if (CONFIG_CODEC != SWCODEC) | ||
467 | if (!wps_state.paused) | ||
468 | audio_resume(); | ||
469 | #endif | ||
470 | } | ||
471 | |||
472 | static void gwps_fix_statusbars(void) | ||
473 | { | ||
474 | #ifdef HAVE_LCD_BITMAP | ||
475 | int i; | ||
476 | wpsbars = VP_SB_HIDE_ALL; | ||
477 | FOR_NB_SCREENS(i) | ||
478 | { | ||
479 | bool draw = false; | ||
480 | if (gui_wps[i].data->wps_sb_tag) | ||
481 | draw = gui_wps[i].data->show_sb_on_wps; | ||
482 | else if (statusbar_position(i) != STATUSBAR_OFF) | ||
483 | draw = true; | ||
484 | if (draw) | ||
485 | wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); | ||
486 | } | ||
487 | #else | ||
488 | wpsbars = VP_SB_ALLSCREENS; | ||
489 | #endif | ||
490 | } | ||
491 | |||
492 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
493 | /* | ||
494 | * If the user is unable to see the wps, because the display is deactivated, | ||
495 | * we suppress updates until the wps is activated again (the lcd driver will | ||
496 | * call this hook to issue an instant update) | ||
497 | * */ | ||
498 | static void wps_lcd_activation_hook(void) | ||
499 | { | ||
500 | wps_state.do_full_update = true; | ||
501 | /* force timeout in wps main loop, so that the update is instantly */ | ||
502 | queue_post(&button_queue, BUTTON_NONE, 0); | ||
503 | } | ||
504 | #endif | ||
505 | |||
506 | static void gwps_leave_wps(void) | ||
507 | { | ||
508 | int i, oldbars = VP_SB_HIDE_ALL; | ||
509 | |||
510 | FOR_NB_SCREENS(i) | ||
511 | gui_wps[i].display->stop_scroll(); | ||
512 | if (global_settings.statusbar) | ||
513 | oldbars = VP_SB_ALLSCREENS; | ||
514 | |||
515 | #if LCD_DEPTH > 1 | ||
516 | show_main_backdrop(); | ||
517 | #endif | ||
518 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
519 | show_remote_main_backdrop(); | ||
520 | #endif | ||
521 | viewportmanager_set_statusbar(oldbars); | ||
522 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
523 | /* Play safe and unregister the hook */ | ||
524 | lcd_activation_set_hook(NULL); | ||
525 | #endif | ||
526 | } | ||
527 | |||
528 | void gwps_draw_statusbars(void) | ||
529 | { | ||
530 | viewportmanager_set_statusbar(wpsbars); | ||
531 | } | ||
532 | #ifdef HAVE_TOUCHSCREEN | ||
533 | int wps_get_touchaction(struct wps_data *data) | ||
534 | { | ||
535 | short x,y; | ||
536 | short vx, vy; | ||
537 | int type = action_get_touchscreen_press(&x, &y); | ||
538 | int i; | ||
539 | static int last_action = ACTION_NONE; | ||
540 | struct touchregion *r; | ||
541 | bool repeated = (type == BUTTON_REPEAT); | ||
542 | bool released = (type == BUTTON_REL); | ||
543 | for (i=0; i<data->touchregion_count; i++) | ||
544 | { | ||
545 | r = &data->touchregion[i]; | ||
546 | /* make sure this region's viewport is visible */ | ||
547 | if (r->wvp->hidden_flags&VP_DRAW_HIDDEN) | ||
548 | continue; | ||
549 | /* reposition the touch inside the viewport */ | ||
550 | vx = x - r->wvp->vp.x; | ||
551 | vy = y - r->wvp->vp.y; | ||
552 | /* check if it's inside this viewport */ | ||
553 | if (vx >= 0 && vx < r->wvp->vp.x + r->wvp->vp.width && | ||
554 | vy >= 0 && vy < r->wvp->vp.y + r->wvp->vp.height) | ||
555 | { | ||
556 | /* now see if the point is inside this region */ | ||
557 | if (vx >= r->x && vx < r->x+r->width && | ||
558 | vy >= r->y && vy < r->y+r->height) | ||
559 | { | ||
560 | if ((repeated && r->repeat) || | ||
561 | (released && !r->repeat)) | ||
562 | { | ||
563 | last_action = r->action; | ||
564 | return r->action; | ||
565 | } | ||
566 | } | ||
567 | } | ||
568 | } | ||
569 | if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) | ||
570 | return ACTION_WPS_STOPSEEK; | ||
571 | last_action = ACTION_TOUCHSCREEN; | ||
572 | return ACTION_TOUCHSCREEN; | ||
573 | } | ||
574 | #endif | ||
575 | /* The WPS can be left in two ways: | ||
576 | * a) call a function, which draws over the wps. In this case, the wps | ||
577 | * will be still active (i.e. the below function didn't return) | ||
578 | * b) return with a value evaluated by root_menu.c, in this case the wps | ||
579 | * is really left, and root_menu will handle the next screen | ||
580 | * | ||
581 | * In either way, call gwps_leave_wps(), in order to restore the correct | ||
582 | * "main screen" backdrops and statusbars | ||
583 | */ | ||
584 | long gui_wps_show(void) | ||
585 | { | ||
586 | long button = 0; | ||
587 | bool restore = true; | ||
588 | long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ | ||
589 | bool exit = false; | ||
590 | bool bookmark = false; | ||
591 | bool update = false; | ||
592 | int i; | ||
593 | long last_left = 0, last_right = 0; | ||
594 | |||
595 | #ifdef HAVE_LCD_CHARCELLS | ||
596 | status_set_audio(true); | ||
597 | status_set_param(false); | ||
598 | #endif | ||
599 | |||
600 | #ifdef AB_REPEAT_ENABLE | ||
601 | ab_repeat_init(); | ||
602 | ab_reset_markers(); | ||
603 | #endif | ||
604 | wps_state_init(); | ||
605 | |||
606 | while ( 1 ) | ||
607 | { | ||
608 | bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; | ||
609 | |||
610 | /* did someone else (i.e power thread) change audio pause mode? */ | ||
611 | if (wps_state.paused != audio_paused) { | ||
612 | wps_state.paused = audio_paused; | ||
613 | |||
614 | /* if another thread paused audio, we are probably in car mode, | ||
615 | about to shut down. lets save the settings. */ | ||
616 | if (wps_state.paused) { | ||
617 | settings_save(); | ||
618 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | ||
619 | call_storage_idle_notifys(true); | ||
620 | #endif | ||
621 | } | ||
622 | } | ||
623 | |||
624 | #ifdef HAVE_LCD_BITMAP | ||
625 | /* when the peak meter is enabled we want to have a | ||
626 | few extra updates to make it look smooth. On the | ||
627 | other hand we don't want to waste energy if it | ||
628 | isn't displayed */ | ||
629 | bool pm=false; | ||
630 | FOR_NB_SCREENS(i) | ||
631 | { | ||
632 | if(gui_wps[i].data->peak_meter_enabled) | ||
633 | pm = true; | ||
634 | } | ||
635 | |||
636 | if (pm) { | ||
637 | long next_refresh = current_tick; | ||
638 | long next_big_refresh = current_tick + HZ / 5; | ||
639 | button = BUTTON_NONE; | ||
640 | while (TIME_BEFORE(current_tick, next_big_refresh)) { | ||
641 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_NOBLOCK); | ||
642 | if (button != ACTION_NONE) { | ||
643 | break; | ||
644 | } | ||
645 | peak_meter_peek(); | ||
646 | sleep(0); /* Sleep until end of current tick. */ | ||
647 | |||
648 | if (TIME_AFTER(current_tick, next_refresh)) { | ||
649 | FOR_NB_SCREENS(i) | ||
650 | { | ||
651 | if(gui_wps[i].data->peak_meter_enabled) | ||
652 | skin_update(&gui_wps[i], WPS_REFRESH_PEAK_METER); | ||
653 | next_refresh += HZ / PEAK_METER_FPS; | ||
654 | } | ||
655 | } | ||
656 | } | ||
657 | |||
658 | } | ||
659 | |||
660 | /* The peak meter is disabled | ||
661 | -> no additional screen updates needed */ | ||
662 | else | ||
663 | #endif | ||
664 | { | ||
665 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK, | ||
666 | restore ? HZ/100 : HZ/5); | ||
667 | } | ||
668 | |||
669 | /* Exit if audio has stopped playing. This happens e.g. at end of | ||
670 | playlist or if using the sleep timer. */ | ||
671 | if (!(audio_status() & AUDIO_STATUS_PLAY)) | ||
672 | exit = true; | ||
673 | #ifdef HAVE_TOUCHSCREEN | ||
674 | if (button == ACTION_TOUCHSCREEN) | ||
675 | button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data); | ||
676 | #endif | ||
677 | /* The iPods/X5/M5 use a single button for the A-B mode markers, | ||
678 | defined as ACTION_WPSAB_SINGLE in their config files. */ | ||
679 | #ifdef ACTION_WPSAB_SINGLE | ||
680 | if (!global_settings.party_mode && ab_repeat_mode_enabled()) | ||
681 | { | ||
682 | static int wps_ab_state = 0; | ||
683 | if (button == ACTION_WPSAB_SINGLE) | ||
684 | { | ||
685 | switch (wps_ab_state) | ||
686 | { | ||
687 | case 0: /* set the A spot */ | ||
688 | button = ACTION_WPS_ABSETA_PREVDIR; | ||
689 | break; | ||
690 | case 1: /* set the B spot */ | ||
691 | button = ACTION_WPS_ABSETB_NEXTDIR; | ||
692 | break; | ||
693 | case 2: | ||
694 | button = ACTION_WPS_ABRESET; | ||
695 | break; | ||
696 | } | ||
697 | wps_ab_state = (wps_ab_state+1) % 3; | ||
698 | } | ||
699 | } | ||
700 | #endif | ||
701 | switch(button) | ||
702 | { | ||
703 | case ACTION_WPS_CONTEXT: | ||
704 | { | ||
705 | gwps_leave_wps(); | ||
706 | /* if music is stopped in the context menu we want to exit the wps */ | ||
707 | if (onplay(wps_state.id3->path, | ||
708 | FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU | ||
709 | || !audio_status()) | ||
710 | return GO_TO_ROOT; | ||
711 | restore = true; | ||
712 | } | ||
713 | break; | ||
714 | |||
715 | case ACTION_WPS_BROWSE: | ||
716 | #ifdef HAVE_LCD_CHARCELLS | ||
717 | status_set_record(false); | ||
718 | status_set_audio(false); | ||
719 | #endif | ||
720 | gwps_leave_wps(); | ||
721 | return GO_TO_PREVIOUS_BROWSER; | ||
722 | break; | ||
723 | |||
724 | /* play/pause */ | ||
725 | case ACTION_WPS_PLAY: | ||
726 | if (global_settings.party_mode) | ||
727 | break; | ||
728 | if ( wps_state.paused ) | ||
729 | { | ||
730 | wps_state.paused = false; | ||
731 | if ( global_settings.fade_on_stop ) | ||
732 | fade(true, true); | ||
733 | else | ||
734 | audio_resume(); | ||
735 | } | ||
736 | else | ||
737 | { | ||
738 | wps_state.paused = true; | ||
739 | if ( global_settings.fade_on_stop ) | ||
740 | fade(false, true); | ||
741 | else | ||
742 | audio_pause(); | ||
743 | settings_save(); | ||
744 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | ||
745 | call_storage_idle_notifys(true); /* make sure resume info is saved */ | ||
746 | #endif | ||
747 | } | ||
748 | break; | ||
749 | |||
750 | case ACTION_WPS_VOLUP: | ||
751 | { | ||
752 | FOR_NB_SCREENS(i) | ||
753 | gui_wps[i].data->button_time_volume = current_tick; | ||
754 | global_settings.volume++; | ||
755 | bool res = false; | ||
756 | setvol(); | ||
757 | FOR_NB_SCREENS(i) | ||
758 | { | ||
759 | if(update_onvol_change(&gui_wps[i])) | ||
760 | res = true; | ||
761 | } | ||
762 | if (res) { | ||
763 | restore = true; | ||
764 | restoretimer = RESTORE_WPS_NEXT_SECOND; | ||
765 | } | ||
766 | } | ||
767 | break; | ||
768 | case ACTION_WPS_VOLDOWN: | ||
769 | { | ||
770 | FOR_NB_SCREENS(i) | ||
771 | gui_wps[i].data->button_time_volume = current_tick; | ||
772 | global_settings.volume--; | ||
773 | setvol(); | ||
774 | bool res = false; | ||
775 | FOR_NB_SCREENS(i) | ||
776 | { | ||
777 | if(update_onvol_change(&gui_wps[i])) | ||
778 | res = true; | ||
779 | } | ||
780 | if (res) { | ||
781 | restore = true; | ||
782 | restoretimer = RESTORE_WPS_NEXT_SECOND; | ||
783 | } | ||
784 | } | ||
785 | break; | ||
786 | /* fast forward | ||
787 | OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ | ||
788 | case ACTION_WPS_SEEKFWD: | ||
789 | if (global_settings.party_mode) | ||
790 | break; | ||
791 | if (current_tick -last_right < HZ) | ||
792 | { | ||
793 | if (wps_state.id3->cuesheet) | ||
794 | { | ||
795 | audio_next(); | ||
796 | } | ||
797 | else | ||
798 | { | ||
799 | change_dir(1); | ||
800 | } | ||
801 | } | ||
802 | else | ||
803 | ffwd_rew(ACTION_WPS_SEEKFWD); | ||
804 | last_right = last_left = 0; | ||
805 | break; | ||
806 | /* fast rewind | ||
807 | OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/ | ||
808 | case ACTION_WPS_SEEKBACK: | ||
809 | if (global_settings.party_mode) | ||
810 | break; | ||
811 | if (current_tick -last_left < HZ) | ||
812 | { | ||
813 | if (wps_state.id3->cuesheet) | ||
814 | { | ||
815 | if (!wps_state.paused) | ||
816 | #if (CONFIG_CODEC == SWCODEC) | ||
817 | audio_pre_ff_rewind(); | ||
818 | #else | ||
819 | audio_pause(); | ||
820 | #endif | ||
821 | audio_ff_rewind(0); | ||
822 | } | ||
823 | else | ||
824 | { | ||
825 | change_dir(-1); | ||
826 | } | ||
827 | } | ||
828 | else | ||
829 | ffwd_rew(ACTION_WPS_SEEKBACK); | ||
830 | last_left = last_right = 0; | ||
831 | break; | ||
832 | |||
833 | /* prev / restart */ | ||
834 | case ACTION_WPS_SKIPPREV: | ||
835 | if (global_settings.party_mode) | ||
836 | break; | ||
837 | last_left = current_tick; | ||
838 | #ifdef AB_REPEAT_ENABLE | ||
839 | /* if we're in A/B repeat mode and the current position | ||
840 | is past the A marker, jump back to the A marker... */ | ||
841 | if ( ab_repeat_mode_enabled() ) | ||
842 | { | ||
843 | if ( ab_after_A_marker(wps_state.id3->elapsed) ) | ||
844 | { | ||
845 | ab_jump_to_A_marker(); | ||
846 | break; | ||
847 | #if (AB_REPEAT_ENABLE == 2) | ||
848 | } else { | ||
849 | ab_reset_markers(); | ||
850 | #endif | ||
851 | } | ||
852 | } | ||
853 | else | ||
854 | /* ...otherwise, do it normally */ | ||
855 | #endif | ||
856 | play_hop(-1); | ||
857 | break; | ||
858 | |||
859 | /* next | ||
860 | OR if skip length set, hop by predetermined amount. */ | ||
861 | case ACTION_WPS_SKIPNEXT: | ||
862 | if (global_settings.party_mode) | ||
863 | break; | ||
864 | last_right = current_tick; | ||
865 | #ifdef AB_REPEAT_ENABLE | ||
866 | /* if we're in A/B repeat mode and the current position is | ||
867 | before the A marker, jump to the A marker... */ | ||
868 | if ( ab_repeat_mode_enabled() ) | ||
869 | { | ||
870 | if ( ab_before_A_marker(wps_state.id3->elapsed) ) | ||
871 | { | ||
872 | ab_jump_to_A_marker(); | ||
873 | break; | ||
874 | #if (AB_REPEAT_ENABLE == 2) | ||
875 | } else { | ||
876 | ab_reset_markers(); | ||
877 | #endif | ||
878 | } | ||
879 | } | ||
880 | else | ||
881 | /* ...otherwise, do it normally */ | ||
882 | #endif | ||
883 | play_hop(1); | ||
884 | break; | ||
885 | /* next / prev directories */ | ||
886 | /* and set A-B markers if in a-b mode */ | ||
887 | case ACTION_WPS_ABSETB_NEXTDIR: | ||
888 | if (global_settings.party_mode) | ||
889 | break; | ||
890 | #if defined(AB_REPEAT_ENABLE) | ||
891 | if (ab_repeat_mode_enabled()) | ||
892 | { | ||
893 | ab_set_B_marker(wps_state.id3->elapsed); | ||
894 | ab_jump_to_A_marker(); | ||
895 | } | ||
896 | else | ||
897 | #endif | ||
898 | { | ||
899 | change_dir(1); | ||
900 | } | ||
901 | break; | ||
902 | case ACTION_WPS_ABSETA_PREVDIR: | ||
903 | if (global_settings.party_mode) | ||
904 | break; | ||
905 | #if defined(AB_REPEAT_ENABLE) | ||
906 | if (ab_repeat_mode_enabled()) | ||
907 | ab_set_A_marker(wps_state.id3->elapsed); | ||
908 | else | ||
909 | #endif | ||
910 | { | ||
911 | change_dir(-1); | ||
912 | } | ||
913 | break; | ||
914 | /* menu key functions */ | ||
915 | case ACTION_WPS_MENU: | ||
916 | gwps_leave_wps(); | ||
917 | return GO_TO_ROOT; | ||
918 | break; | ||
919 | |||
920 | |||
921 | #ifdef HAVE_QUICKSCREEN | ||
922 | case ACTION_WPS_QUICKSCREEN: | ||
923 | { | ||
924 | gwps_leave_wps(); | ||
925 | if (quick_screen_quick(button)) | ||
926 | return SYS_USB_CONNECTED; | ||
927 | restore = true; | ||
928 | } | ||
929 | break; | ||
930 | #endif /* HAVE_QUICKSCREEN */ | ||
931 | |||
932 | /* screen settings */ | ||
933 | #ifdef BUTTON_F3 | ||
934 | case ACTION_F3: | ||
935 | { | ||
936 | gwps_leave_wps(); | ||
937 | if (quick_screen_f3(BUTTON_F3)) | ||
938 | return SYS_USB_CONNECTED; | ||
939 | restore = true; | ||
940 | } | ||
941 | break; | ||
942 | #endif /* BUTTON_F3 */ | ||
943 | |||
944 | /* pitch screen */ | ||
945 | #ifdef HAVE_PITCHSCREEN | ||
946 | case ACTION_WPS_PITCHSCREEN: | ||
947 | { | ||
948 | gwps_leave_wps(); | ||
949 | if (1 == gui_syncpitchscreen_run()) | ||
950 | return SYS_USB_CONNECTED; | ||
951 | restore = true; | ||
952 | } | ||
953 | break; | ||
954 | #endif /* HAVE_PITCHSCREEN */ | ||
955 | |||
956 | #ifdef AB_REPEAT_ENABLE | ||
957 | /* reset A&B markers */ | ||
958 | case ACTION_WPS_ABRESET: | ||
959 | if (ab_repeat_mode_enabled()) | ||
960 | { | ||
961 | ab_reset_markers(); | ||
962 | update = true; | ||
963 | } | ||
964 | break; | ||
965 | #endif /* AB_REPEAT_ENABLE */ | ||
966 | |||
967 | /* stop and exit wps */ | ||
968 | case ACTION_WPS_STOP: | ||
969 | if (global_settings.party_mode) | ||
970 | break; | ||
971 | bookmark = true; | ||
972 | exit = true; | ||
973 | break; | ||
974 | |||
975 | case ACTION_WPS_ID3SCREEN: | ||
976 | { | ||
977 | gwps_leave_wps(); | ||
978 | browse_id3(); | ||
979 | restore = true; | ||
980 | } | ||
981 | break; | ||
982 | #ifdef HAVE_TOUCHSCREEN | ||
983 | case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ | ||
984 | { | ||
985 | global_settings.playlist_shuffle = | ||
986 | !global_settings.playlist_shuffle; | ||
987 | #if CONFIG_CODEC == SWCODEC | ||
988 | dsp_set_replaygain(); | ||
989 | #endif | ||
990 | if (global_settings.playlist_shuffle) | ||
991 | playlist_randomise(NULL, current_tick, true); | ||
992 | else | ||
993 | playlist_sort(NULL, true); | ||
994 | } | ||
995 | break; | ||
996 | case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ | ||
997 | { | ||
998 | const struct settings_list *rep_setting = | ||
999 | find_setting(&global_settings.repeat_mode, NULL); | ||
1000 | option_select_next_val(rep_setting, false, true); | ||
1001 | audio_flush_and_reload_tracks(); | ||
1002 | } | ||
1003 | break; | ||
1004 | #endif /* HAVE_TOUCHSCREEN */ | ||
1005 | /* this case is used by the softlock feature | ||
1006 | * it requests a full update here */ | ||
1007 | case ACTION_REDRAW: | ||
1008 | wps_state.do_full_update = true; | ||
1009 | break; | ||
1010 | case ACTION_NONE: /* Timeout, do a partial update */ | ||
1011 | update = true; | ||
1012 | ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ | ||
1013 | break; | ||
1014 | #ifdef HAVE_RECORDING | ||
1015 | case ACTION_WPS_REC: | ||
1016 | exit = true; | ||
1017 | break; | ||
1018 | #endif | ||
1019 | case SYS_POWEROFF: | ||
1020 | default_event_handler(SYS_POWEROFF); | ||
1021 | break; | ||
1022 | case ACTION_WPS_VIEW_PLAYLIST: | ||
1023 | gwps_leave_wps(); | ||
1024 | if (playlist_viewer()) /* true if USB connected */ | ||
1025 | return SYS_USB_CONNECTED; | ||
1026 | restore = true; | ||
1027 | break; | ||
1028 | default: | ||
1029 | if(default_event_handler(button) == SYS_USB_CONNECTED) | ||
1030 | return GO_TO_ROOT; | ||
1031 | update = true; | ||
1032 | break; | ||
1033 | } | ||
1034 | |||
1035 | if (wps_state.do_full_update || update) | ||
1036 | { | ||
1037 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) | ||
1038 | gwps_caption_backlight(&wps_state); | ||
1039 | #endif | ||
1040 | FOR_NB_SCREENS(i) | ||
1041 | { | ||
1042 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
1043 | if (lcd_active() | ||
1044 | #ifdef HAVE_REMOTE_LCD | ||
1045 | /* currently, all remotes are readable without backlight | ||
1046 | * so still update those */ | ||
1047 | || (i == SCREEN_REMOTE) | ||
1048 | #endif | ||
1049 | ) | ||
1050 | #endif | ||
1051 | { | ||
1052 | skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC); | ||
1053 | } | ||
1054 | } | ||
1055 | wps_state.do_full_update = false; | ||
1056 | update = false; | ||
1057 | } | ||
1058 | |||
1059 | if (restore && wps_state.id3 && | ||
1060 | ((restoretimer == RESTORE_WPS_INSTANTLY) || | ||
1061 | TIME_AFTER(current_tick, restoretimer))) | ||
1062 | { | ||
1063 | restore = false; | ||
1064 | restoretimer = RESTORE_WPS_INSTANTLY; | ||
1065 | gwps_fix_statusbars(); | ||
1066 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
1067 | lcd_activation_set_hook(wps_lcd_activation_hook); | ||
1068 | #endif | ||
1069 | FOR_NB_SCREENS(i) | ||
1070 | { | ||
1071 | screens[i].stop_scroll(); | ||
1072 | gui_wps_display(&gui_wps[i]); | ||
1073 | } | ||
1074 | } | ||
1075 | |||
1076 | if (exit) { | ||
1077 | #ifdef HAVE_LCD_CHARCELLS | ||
1078 | status_set_record(false); | ||
1079 | status_set_audio(false); | ||
1080 | #endif | ||
1081 | if (global_settings.fade_on_stop) | ||
1082 | fade(false, true); | ||
1083 | |||
1084 | if (bookmark) | ||
1085 | bookmark_autobookmark(); | ||
1086 | audio_stop(); | ||
1087 | #ifdef AB_REPEAT_ENABLE | ||
1088 | ab_reset_markers(); | ||
1089 | #endif | ||
1090 | gwps_leave_wps(); | ||
1091 | #ifdef HAVE_RECORDING | ||
1092 | if (button == ACTION_WPS_REC) | ||
1093 | return GO_TO_RECSCREEN; | ||
1094 | #endif | ||
1095 | if (global_settings.browse_current) | ||
1096 | return GO_TO_PREVIOUS_BROWSER; | ||
1097 | return GO_TO_PREVIOUS; | ||
1098 | } | ||
1099 | |||
1100 | if (button && !IS_SYSEVENT(button) ) | ||
1101 | storage_spin(); | ||
1102 | } | ||
1103 | return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ | ||
1104 | } | ||
1105 | |||
1106 | /* this is called from the playback thread so NO DRAWING! */ | ||
1107 | static void track_changed_callback(void *param) | ||
1108 | { | ||
1109 | wps_state.id3 = (struct mp3entry*)param; | ||
1110 | wps_state.nid3 = audio_next_track(); | ||
1111 | if (wps_state.id3->cuesheet) | ||
1112 | { | ||
1113 | cue_find_current_track(wps_state.id3->cuesheet, wps_state.id3->elapsed); | ||
1114 | cue_spoof_id3(wps_state.id3->cuesheet, wps_state.id3); | ||
1115 | } | ||
1116 | wps_state.do_full_update = true; | ||
1117 | } | ||
1118 | static void nextid3available_callback(void* param) | ||
1119 | { | ||
1120 | (void)param; | ||
1121 | wps_state.nid3 = audio_next_track(); | ||
1122 | wps_state.do_full_update = true; | ||
1123 | } | ||
1124 | |||
1125 | |||
1126 | static void wps_state_init(void) | ||
1127 | { | ||
1128 | wps_state.ff_rewind = false; | ||
1129 | wps_state.paused = false; | ||
1130 | if(audio_status() & AUDIO_STATUS_PLAY) | ||
1131 | { | ||
1132 | wps_state.id3 = audio_current_track(); | ||
1133 | wps_state.nid3 = audio_next_track(); | ||
1134 | } | ||
1135 | else | ||
1136 | { | ||
1137 | wps_state.id3 = NULL; | ||
1138 | wps_state.nid3 = NULL; | ||
1139 | } | ||
1140 | /* We'll be updating due to restore initialized with true */ | ||
1141 | wps_state.do_full_update = false; | ||
1142 | /* add the WPS track event callbacks */ | ||
1143 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); | ||
1144 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); | ||
1145 | } | ||
1146 | |||
1147 | |||
1148 | #ifdef HAVE_LCD_BITMAP | ||
1149 | static void statusbar_toggle_handler(void *data) | ||
1150 | { | ||
1151 | (void)data; | ||
1152 | int i; | ||
1153 | gwps_fix_statusbars(); | ||
1154 | |||
1155 | FOR_NB_SCREENS(i) | ||
1156 | { | ||
1157 | struct viewport *vp = &gui_wps[i].data->viewports[0].vp; | ||
1158 | bool draw = wpsbars & (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); | ||
1159 | if (!draw) | ||
1160 | { | ||
1161 | vp->y = 0; | ||
1162 | vp->height = screens[i].lcdheight; | ||
1163 | } | ||
1164 | else | ||
1165 | { | ||
1166 | bool bar_at_top = statusbar_position(i) != STATUSBAR_BOTTOM; | ||
1167 | vp->y = bar_at_top?STATUSBAR_HEIGHT:0; | ||
1168 | vp->height = screens[i].lcdheight - STATUSBAR_HEIGHT; | ||
1169 | } | ||
1170 | } | ||
1171 | } | ||
1172 | #endif | ||
1173 | |||
1174 | void gui_sync_wps_init(void) | ||
1175 | { | ||
1176 | int i; | ||
1177 | FOR_NB_SCREENS(i) | ||
1178 | { | ||
1179 | wps_data_init(&wps_datas[i]); | ||
1180 | #ifdef HAVE_ALBUMART | ||
1181 | wps_datas[i].wps_uses_albumart = 0; | ||
1182 | #endif | ||
1183 | #ifdef HAVE_REMOTE_LCD | ||
1184 | wps_datas[i].remote_wps = (i != 0); | ||
1185 | #endif | ||
1186 | gui_wps[i].data = &wps_datas[i]; | ||
1187 | gui_wps[i].display = &screens[i]; | ||
1188 | /* Currently no seperate wps_state needed/possible | ||
1189 | so use the only available ( "global" ) one */ | ||
1190 | gui_wps[i].state = &wps_state; | ||
1191 | } | ||
1192 | #ifdef HAVE_LCD_BITMAP | ||
1193 | add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggle_handler); | ||
1194 | #endif | ||
1195 | #if LCD_DEPTH > 1 | ||
1196 | unload_wps_backdrop(); | ||
1197 | #endif | ||
1198 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
1199 | unload_remote_wps_backdrop(); | ||
1200 | #endif | ||
1201 | } | ||
1202 | |||
1203 | #ifdef HAVE_ALBUMART | ||
1204 | /* Returns true if at least one of the gui_wps screens has an album art | ||
1205 | tag in its wps structure */ | ||
1206 | bool gui_sync_wps_uses_albumart(void) | ||
1207 | { | ||
1208 | int i; | ||
1209 | FOR_NB_SCREENS(i) { | ||
1210 | struct gui_wps *gwps = &gui_wps[i]; | ||
1211 | if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE)) | ||
1212 | return true; | ||
1213 | } | ||
1214 | return false; | ||
1215 | } | ||
1216 | #endif | ||