diff options
Diffstat (limited to 'apps/gui/music_screen.c')
-rw-r--r-- | apps/gui/music_screen.c | 1213 |
1 files changed, 1213 insertions, 0 deletions
diff --git a/apps/gui/music_screen.c b/apps/gui/music_screen.c new file mode 100644 index 0000000000..39d5e0e85b --- /dev/null +++ b/apps/gui/music_screen.c | |||
@@ -0,0 +1,1213 @@ | |||
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 "wps_engine/wps_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 "music_screen.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 | gui_wps_redraw(&gui_wps[i], 0, 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 | gui_wps_redraw(&gui_wps[i], 0, 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 | gui_wps_redraw(gwps, 0, 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 | FOR_NB_SCREENS(i) | ||
258 | gui_wps_redraw(&gui_wps[i], | ||
259 | (wps_state.wps_time_countup == false)? | ||
260 | ff_rewind_count:-ff_rewind_count, | ||
261 | WPS_REFRESH_PLAYER_PROGRESS | | ||
262 | WPS_REFRESH_DYNAMIC); | ||
263 | |||
264 | break; | ||
265 | |||
266 | case ACTION_WPS_STOPSEEK: | ||
267 | wps_state.id3->elapsed = wps_state.id3->elapsed+ff_rewind_count; | ||
268 | audio_ff_rewind(wps_state.id3->elapsed); | ||
269 | ff_rewind_count = 0; | ||
270 | wps_state.ff_rewind = false; | ||
271 | status_set_ffmode(0); | ||
272 | #if (CONFIG_CODEC != SWCODEC) | ||
273 | if (!wps_state.paused) | ||
274 | audio_resume(); | ||
275 | #endif | ||
276 | #ifdef HAVE_LCD_CHARCELLS | ||
277 | FOR_NB_SCREENS(i) | ||
278 | gui_wps_redraw(&gui_wps[i],0, WPS_REFRESH_ALL); | ||
279 | #endif | ||
280 | exit = true; | ||
281 | break; | ||
282 | |||
283 | default: | ||
284 | if(default_event_handler(button) == SYS_USB_CONNECTED) { | ||
285 | status_set_ffmode(0); | ||
286 | usb = true; | ||
287 | exit = true; | ||
288 | } | ||
289 | break; | ||
290 | } | ||
291 | if (!exit) | ||
292 | { | ||
293 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); | ||
294 | #ifdef HAVE_TOUCHSCREEN | ||
295 | if (button == ACTION_TOUCHSCREEN) | ||
296 | button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data); | ||
297 | #endif | ||
298 | } | ||
299 | } | ||
300 | return usb; | ||
301 | } | ||
302 | |||
303 | |||
304 | void display_keylock_text(bool locked) | ||
305 | { | ||
306 | int i; | ||
307 | FOR_NB_SCREENS(i) | ||
308 | gui_wps[i].display->stop_scroll(); | ||
309 | |||
310 | splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF)); | ||
311 | } | ||
312 | |||
313 | |||
314 | |||
315 | |||
316 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) | ||
317 | static void gwps_caption_backlight(struct wps_state *state) | ||
318 | { | ||
319 | if (state && state->id3) | ||
320 | { | ||
321 | #ifdef HAVE_BACKLIGHT | ||
322 | if (global_settings.caption_backlight) | ||
323 | { | ||
324 | /* turn on backlight n seconds before track ends, and turn it off n | ||
325 | seconds into the new track. n == backlight_timeout, or 5s */ | ||
326 | int n = global_settings.backlight_timeout * 1000; | ||
327 | |||
328 | if ( n < 1000 ) | ||
329 | n = 5000; /* use 5s if backlight is always on or off */ | ||
330 | |||
331 | if (((state->id3->elapsed < 1000) || | ||
332 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && | ||
333 | (state->paused == false)) | ||
334 | backlight_on(); | ||
335 | } | ||
336 | #endif | ||
337 | #ifdef HAVE_REMOTE_LCD | ||
338 | if (global_settings.remote_caption_backlight) | ||
339 | { | ||
340 | /* turn on remote backlight n seconds before track ends, and turn it | ||
341 | off n seconds into the new track. n == remote_backlight_timeout, | ||
342 | or 5s */ | ||
343 | int n = global_settings.remote_backlight_timeout * 1000; | ||
344 | |||
345 | if ( n < 1000 ) | ||
346 | n = 5000; /* use 5s if backlight is always on or off */ | ||
347 | |||
348 | if (((state->id3->elapsed < 1000) || | ||
349 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && | ||
350 | (state->paused == false)) | ||
351 | remote_backlight_on(); | ||
352 | } | ||
353 | #endif | ||
354 | } | ||
355 | } | ||
356 | #endif | ||
357 | |||
358 | |||
359 | static void change_dir(int direction) | ||
360 | { | ||
361 | if (global_settings.prevent_skip) | ||
362 | return; | ||
363 | |||
364 | if (direction < 0) | ||
365 | audio_prev_dir(); | ||
366 | else if (direction > 0) | ||
367 | audio_next_dir(); | ||
368 | /* prevent the next dir to immediatly start being ffw'd */ | ||
369 | action_wait_for_release(); | ||
370 | } | ||
371 | |||
372 | static void prev_track(unsigned long skip_thresh) | ||
373 | { | ||
374 | if (wps_state.id3->elapsed < skip_thresh) | ||
375 | { | ||
376 | audio_prev(); | ||
377 | return; | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | if (wps_state.id3->cuesheet) | ||
382 | { | ||
383 | curr_cuesheet_skip(wps_state.id3->cuesheet, -1, wps_state.id3->elapsed); | ||
384 | return; | ||
385 | } | ||
386 | |||
387 | if (!wps_state.paused) | ||
388 | #if (CONFIG_CODEC == SWCODEC) | ||
389 | audio_pre_ff_rewind(); | ||
390 | #else | ||
391 | audio_pause(); | ||
392 | #endif | ||
393 | |||
394 | audio_ff_rewind(0); | ||
395 | |||
396 | #if (CONFIG_CODEC != SWCODEC) | ||
397 | if (!wps_state.paused) | ||
398 | audio_resume(); | ||
399 | #endif | ||
400 | } | ||
401 | } | ||
402 | |||
403 | static void next_track(void) | ||
404 | { | ||
405 | /* take care of if we're playing a cuesheet */ | ||
406 | if (wps_state.id3->cuesheet) | ||
407 | { | ||
408 | if (curr_cuesheet_skip(wps_state.id3->cuesheet, 1, wps_state.id3->elapsed)) | ||
409 | { | ||
410 | /* if the result was false, then we really want | ||
411 | to skip to the next track */ | ||
412 | return; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | audio_next(); | ||
417 | } | ||
418 | |||
419 | static void play_hop(int direction) | ||
420 | { | ||
421 | unsigned long step = ((unsigned long)global_settings.skip_length)*1000; | ||
422 | unsigned long elapsed = wps_state.id3->elapsed; | ||
423 | unsigned long remaining = wps_state.id3->length - elapsed; | ||
424 | |||
425 | if (!global_settings.prevent_skip && | ||
426 | (!step || | ||
427 | (direction > 0 && step >= remaining) || | ||
428 | (direction < 0 && elapsed < DEFAULT_SKIP_TRESH))) | ||
429 | { /* Do normal track skipping */ | ||
430 | if (direction > 0) | ||
431 | next_track(); | ||
432 | else if (direction < 0) | ||
433 | prev_track(DEFAULT_SKIP_TRESH); | ||
434 | return; | ||
435 | } | ||
436 | |||
437 | if (direction == 1 && step >= remaining) | ||
438 | { | ||
439 | #if CONFIG_CODEC == SWCODEC | ||
440 | if(global_settings.beep) | ||
441 | pcmbuf_beep(1000, 150, 1500*global_settings.beep); | ||
442 | #endif | ||
443 | return; | ||
444 | } | ||
445 | else if ((direction == -1 && elapsed < step)) | ||
446 | { | ||
447 | elapsed = 0; | ||
448 | } | ||
449 | else | ||
450 | { | ||
451 | elapsed += step * direction; | ||
452 | } | ||
453 | if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) | ||
454 | { | ||
455 | #if (CONFIG_CODEC == SWCODEC) | ||
456 | audio_pre_ff_rewind(); | ||
457 | #else | ||
458 | audio_pause(); | ||
459 | #endif | ||
460 | } | ||
461 | audio_ff_rewind(wps_state.id3->elapsed = elapsed); | ||
462 | #if (CONFIG_CODEC != SWCODEC) | ||
463 | if (!wps_state.paused) | ||
464 | audio_resume(); | ||
465 | #endif | ||
466 | } | ||
467 | |||
468 | static void gwps_fix_statusbars(void) | ||
469 | { | ||
470 | #ifdef HAVE_LCD_BITMAP | ||
471 | int i; | ||
472 | wpsbars = VP_SB_HIDE_ALL; | ||
473 | FOR_NB_SCREENS(i) | ||
474 | { | ||
475 | bool draw = false; | ||
476 | if (gui_wps[i].data->wps_sb_tag) | ||
477 | draw = gui_wps[i].data->show_sb_on_wps; | ||
478 | else if (statusbar_position(i) != STATUSBAR_OFF) | ||
479 | draw = true; | ||
480 | if (draw) | ||
481 | wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); | ||
482 | } | ||
483 | #else | ||
484 | wpsbars = VP_SB_ALLSCREENS; | ||
485 | #endif | ||
486 | } | ||
487 | |||
488 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
489 | /* | ||
490 | * If the user is unable to see the wps, because the display is deactivated, | ||
491 | * we suppress updates until the wps is activated again (the lcd driver will | ||
492 | * call this hook to issue an instant update) | ||
493 | * */ | ||
494 | static void wps_lcd_activation_hook(void) | ||
495 | { | ||
496 | wps_state.do_full_update = true; | ||
497 | /* force timeout in wps main loop, so that the update is instantly */ | ||
498 | queue_post(&button_queue, BUTTON_NONE, 0); | ||
499 | } | ||
500 | #endif | ||
501 | |||
502 | static void gwps_leave_wps(void) | ||
503 | { | ||
504 | int i, oldbars = VP_SB_HIDE_ALL; | ||
505 | |||
506 | FOR_NB_SCREENS(i) | ||
507 | gui_wps[i].display->stop_scroll(); | ||
508 | if (global_settings.statusbar) | ||
509 | oldbars = VP_SB_ALLSCREENS; | ||
510 | |||
511 | #if LCD_DEPTH > 1 | ||
512 | show_main_backdrop(); | ||
513 | #endif | ||
514 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
515 | show_remote_main_backdrop(); | ||
516 | #endif | ||
517 | viewportmanager_set_statusbar(oldbars); | ||
518 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
519 | /* Play safe and unregister the hook */ | ||
520 | lcd_activation_set_hook(NULL); | ||
521 | #endif | ||
522 | } | ||
523 | |||
524 | void gwps_draw_statusbars(void) | ||
525 | { | ||
526 | viewportmanager_set_statusbar(wpsbars); | ||
527 | } | ||
528 | #ifdef HAVE_TOUCHSCREEN | ||
529 | int wps_get_touchaction(struct wps_data *data) | ||
530 | { | ||
531 | short x,y; | ||
532 | short vx, vy; | ||
533 | int type = action_get_touchscreen_press(&x, &y); | ||
534 | int i; | ||
535 | static int last_action = ACTION_NONE; | ||
536 | struct touchregion *r; | ||
537 | bool repeated = (type == BUTTON_REPEAT); | ||
538 | bool released = (type == BUTTON_REL); | ||
539 | for (i=0; i<data->touchregion_count; i++) | ||
540 | { | ||
541 | r = &data->touchregion[i]; | ||
542 | /* make sure this region's viewport is visible */ | ||
543 | if (r->wvp->hidden_flags&VP_DRAW_HIDDEN) | ||
544 | continue; | ||
545 | /* reposition the touch inside the viewport */ | ||
546 | vx = x - r->wvp->vp.x; | ||
547 | vy = y - r->wvp->vp.y; | ||
548 | /* check if it's inside this viewport */ | ||
549 | if (vx >= 0 && vx < r->wvp->vp.x + r->wvp->vp.width && | ||
550 | vy >= 0 && vy < r->wvp->vp.y + r->wvp->vp.height) | ||
551 | { | ||
552 | /* now see if the point is inside this region */ | ||
553 | if (vx >= r->x && vx < r->x+r->width && | ||
554 | vy >= r->y && vy < r->y+r->height) | ||
555 | { | ||
556 | if ((repeated && r->repeat) || | ||
557 | (released && !r->repeat)) | ||
558 | { | ||
559 | last_action = r->action; | ||
560 | return r->action; | ||
561 | } | ||
562 | } | ||
563 | } | ||
564 | } | ||
565 | if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) | ||
566 | return ACTION_WPS_STOPSEEK; | ||
567 | last_action = ACTION_TOUCHSCREEN; | ||
568 | return ACTION_TOUCHSCREEN; | ||
569 | } | ||
570 | #endif | ||
571 | /* The WPS can be left in two ways: | ||
572 | * a) call a function, which draws over the wps. In this case, the wps | ||
573 | * will be still active (i.e. the below function didn't return) | ||
574 | * b) return with a value evaluated by root_menu.c, in this case the wps | ||
575 | * is really left, and root_menu will handle the next screen | ||
576 | * | ||
577 | * In either way, call gwps_leave_wps(), in order to restore the correct | ||
578 | * "main screen" backdrops and statusbars | ||
579 | */ | ||
580 | long gui_wps_show(void) | ||
581 | { | ||
582 | long button = 0; | ||
583 | bool restore = true; | ||
584 | long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ | ||
585 | bool exit = false; | ||
586 | bool bookmark = false; | ||
587 | bool update = false; | ||
588 | int i; | ||
589 | long last_left = 0, last_right = 0; | ||
590 | |||
591 | #ifdef HAVE_LCD_CHARCELLS | ||
592 | status_set_audio(true); | ||
593 | status_set_param(false); | ||
594 | #endif | ||
595 | |||
596 | #ifdef AB_REPEAT_ENABLE | ||
597 | ab_repeat_init(); | ||
598 | ab_reset_markers(); | ||
599 | #endif | ||
600 | wps_state_init(); | ||
601 | |||
602 | while ( 1 ) | ||
603 | { | ||
604 | bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; | ||
605 | |||
606 | /* did someone else (i.e power thread) change audio pause mode? */ | ||
607 | if (wps_state.paused != audio_paused) { | ||
608 | wps_state.paused = audio_paused; | ||
609 | |||
610 | /* if another thread paused audio, we are probably in car mode, | ||
611 | about to shut down. lets save the settings. */ | ||
612 | if (wps_state.paused) { | ||
613 | settings_save(); | ||
614 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | ||
615 | call_storage_idle_notifys(true); | ||
616 | #endif | ||
617 | } | ||
618 | } | ||
619 | |||
620 | #ifdef HAVE_LCD_BITMAP | ||
621 | /* when the peak meter is enabled we want to have a | ||
622 | few extra updates to make it look smooth. On the | ||
623 | other hand we don't want to waste energy if it | ||
624 | isn't displayed */ | ||
625 | bool pm=false; | ||
626 | FOR_NB_SCREENS(i) | ||
627 | { | ||
628 | if(gui_wps[i].data->peak_meter_enabled) | ||
629 | pm = true; | ||
630 | } | ||
631 | |||
632 | if (pm) { | ||
633 | long next_refresh = current_tick; | ||
634 | long next_big_refresh = current_tick + HZ / 5; | ||
635 | button = BUTTON_NONE; | ||
636 | while (TIME_BEFORE(current_tick, next_big_refresh)) { | ||
637 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_NOBLOCK); | ||
638 | if (button != ACTION_NONE) { | ||
639 | break; | ||
640 | } | ||
641 | peak_meter_peek(); | ||
642 | sleep(0); /* Sleep until end of current tick. */ | ||
643 | |||
644 | if (TIME_AFTER(current_tick, next_refresh)) { | ||
645 | FOR_NB_SCREENS(i) | ||
646 | { | ||
647 | if(gui_wps[i].data->peak_meter_enabled) | ||
648 | gui_wps_redraw(&gui_wps[i], 0, | ||
649 | WPS_REFRESH_PEAK_METER); | ||
650 | next_refresh += HZ / PEAK_METER_FPS; | ||
651 | } | ||
652 | } | ||
653 | } | ||
654 | |||
655 | } | ||
656 | |||
657 | /* The peak meter is disabled | ||
658 | -> no additional screen updates needed */ | ||
659 | else | ||
660 | #endif | ||
661 | { | ||
662 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK, | ||
663 | restore ? HZ/100 : HZ/5); | ||
664 | } | ||
665 | |||
666 | /* Exit if audio has stopped playing. This happens e.g. at end of | ||
667 | playlist or if using the sleep timer. */ | ||
668 | if (!(audio_status() & AUDIO_STATUS_PLAY)) | ||
669 | exit = true; | ||
670 | #ifdef HAVE_TOUCHSCREEN | ||
671 | if (button == ACTION_TOUCHSCREEN) | ||
672 | button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data); | ||
673 | #endif | ||
674 | /* The iPods/X5/M5 use a single button for the A-B mode markers, | ||
675 | defined as ACTION_WPSAB_SINGLE in their config files. */ | ||
676 | #ifdef ACTION_WPSAB_SINGLE | ||
677 | if (!global_settings.party_mode && ab_repeat_mode_enabled()) | ||
678 | { | ||
679 | static int wps_ab_state = 0; | ||
680 | if (button == ACTION_WPSAB_SINGLE) | ||
681 | { | ||
682 | switch (wps_ab_state) | ||
683 | { | ||
684 | case 0: /* set the A spot */ | ||
685 | button = ACTION_WPS_ABSETA_PREVDIR; | ||
686 | break; | ||
687 | case 1: /* set the B spot */ | ||
688 | button = ACTION_WPS_ABSETB_NEXTDIR; | ||
689 | break; | ||
690 | case 2: | ||
691 | button = ACTION_WPS_ABRESET; | ||
692 | break; | ||
693 | } | ||
694 | wps_ab_state = (wps_ab_state+1) % 3; | ||
695 | } | ||
696 | } | ||
697 | #endif | ||
698 | switch(button) | ||
699 | { | ||
700 | case ACTION_WPS_CONTEXT: | ||
701 | { | ||
702 | gwps_leave_wps(); | ||
703 | /* if music is stopped in the context menu we want to exit the wps */ | ||
704 | if (onplay(wps_state.id3->path, | ||
705 | FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU | ||
706 | || !audio_status()) | ||
707 | return GO_TO_ROOT; | ||
708 | restore = true; | ||
709 | } | ||
710 | break; | ||
711 | |||
712 | case ACTION_WPS_BROWSE: | ||
713 | #ifdef HAVE_LCD_CHARCELLS | ||
714 | status_set_record(false); | ||
715 | status_set_audio(false); | ||
716 | #endif | ||
717 | gwps_leave_wps(); | ||
718 | return GO_TO_PREVIOUS_BROWSER; | ||
719 | break; | ||
720 | |||
721 | /* play/pause */ | ||
722 | case ACTION_WPS_PLAY: | ||
723 | if (global_settings.party_mode) | ||
724 | break; | ||
725 | if ( wps_state.paused ) | ||
726 | { | ||
727 | wps_state.paused = false; | ||
728 | if ( global_settings.fade_on_stop ) | ||
729 | fade(true, true); | ||
730 | else | ||
731 | audio_resume(); | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | wps_state.paused = true; | ||
736 | if ( global_settings.fade_on_stop ) | ||
737 | fade(false, true); | ||
738 | else | ||
739 | audio_pause(); | ||
740 | settings_save(); | ||
741 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | ||
742 | call_storage_idle_notifys(true); /* make sure resume info is saved */ | ||
743 | #endif | ||
744 | } | ||
745 | break; | ||
746 | |||
747 | case ACTION_WPS_VOLUP: | ||
748 | { | ||
749 | FOR_NB_SCREENS(i) | ||
750 | gui_wps[i].data->button_time_volume = current_tick; | ||
751 | global_settings.volume++; | ||
752 | bool res = false; | ||
753 | setvol(); | ||
754 | FOR_NB_SCREENS(i) | ||
755 | { | ||
756 | if(update_onvol_change(&gui_wps[i])) | ||
757 | res = true; | ||
758 | } | ||
759 | if (res) { | ||
760 | restore = true; | ||
761 | restoretimer = RESTORE_WPS_NEXT_SECOND; | ||
762 | } | ||
763 | } | ||
764 | break; | ||
765 | case ACTION_WPS_VOLDOWN: | ||
766 | { | ||
767 | FOR_NB_SCREENS(i) | ||
768 | gui_wps[i].data->button_time_volume = current_tick; | ||
769 | global_settings.volume--; | ||
770 | setvol(); | ||
771 | bool res = false; | ||
772 | FOR_NB_SCREENS(i) | ||
773 | { | ||
774 | if(update_onvol_change(&gui_wps[i])) | ||
775 | res = true; | ||
776 | } | ||
777 | if (res) { | ||
778 | restore = true; | ||
779 | restoretimer = RESTORE_WPS_NEXT_SECOND; | ||
780 | } | ||
781 | } | ||
782 | break; | ||
783 | /* fast forward | ||
784 | OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ | ||
785 | case ACTION_WPS_SEEKFWD: | ||
786 | if (global_settings.party_mode) | ||
787 | break; | ||
788 | if (current_tick -last_right < HZ) | ||
789 | { | ||
790 | if (wps_state.id3->cuesheet) | ||
791 | { | ||
792 | audio_next(); | ||
793 | } | ||
794 | else | ||
795 | { | ||
796 | change_dir(1); | ||
797 | } | ||
798 | } | ||
799 | else | ||
800 | ffwd_rew(ACTION_WPS_SEEKFWD); | ||
801 | last_right = last_left = 0; | ||
802 | break; | ||
803 | /* fast rewind | ||
804 | OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/ | ||
805 | case ACTION_WPS_SEEKBACK: | ||
806 | if (global_settings.party_mode) | ||
807 | break; | ||
808 | if (current_tick -last_left < HZ) | ||
809 | { | ||
810 | if (wps_state.id3->cuesheet) | ||
811 | { | ||
812 | if (!wps_state.paused) | ||
813 | #if (CONFIG_CODEC == SWCODEC) | ||
814 | audio_pre_ff_rewind(); | ||
815 | #else | ||
816 | audio_pause(); | ||
817 | #endif | ||
818 | audio_ff_rewind(0); | ||
819 | } | ||
820 | else | ||
821 | { | ||
822 | change_dir(-1); | ||
823 | } | ||
824 | } | ||
825 | else | ||
826 | ffwd_rew(ACTION_WPS_SEEKBACK); | ||
827 | last_left = last_right = 0; | ||
828 | break; | ||
829 | |||
830 | /* prev / restart */ | ||
831 | case ACTION_WPS_SKIPPREV: | ||
832 | if (global_settings.party_mode) | ||
833 | break; | ||
834 | last_left = current_tick; | ||
835 | #ifdef AB_REPEAT_ENABLE | ||
836 | /* if we're in A/B repeat mode and the current position | ||
837 | is past the A marker, jump back to the A marker... */ | ||
838 | if ( ab_repeat_mode_enabled() ) | ||
839 | { | ||
840 | if ( ab_after_A_marker(wps_state.id3->elapsed) ) | ||
841 | { | ||
842 | ab_jump_to_A_marker(); | ||
843 | break; | ||
844 | #if (AB_REPEAT_ENABLE == 2) | ||
845 | } else { | ||
846 | ab_reset_markers(); | ||
847 | #endif | ||
848 | } | ||
849 | } | ||
850 | else | ||
851 | /* ...otherwise, do it normally */ | ||
852 | #endif | ||
853 | play_hop(-1); | ||
854 | break; | ||
855 | |||
856 | /* next | ||
857 | OR if skip length set, hop by predetermined amount. */ | ||
858 | case ACTION_WPS_SKIPNEXT: | ||
859 | if (global_settings.party_mode) | ||
860 | break; | ||
861 | last_right = current_tick; | ||
862 | #ifdef AB_REPEAT_ENABLE | ||
863 | /* if we're in A/B repeat mode and the current position is | ||
864 | before the A marker, jump to the A marker... */ | ||
865 | if ( ab_repeat_mode_enabled() ) | ||
866 | { | ||
867 | if ( ab_before_A_marker(wps_state.id3->elapsed) ) | ||
868 | { | ||
869 | ab_jump_to_A_marker(); | ||
870 | break; | ||
871 | #if (AB_REPEAT_ENABLE == 2) | ||
872 | } else { | ||
873 | ab_reset_markers(); | ||
874 | #endif | ||
875 | } | ||
876 | } | ||
877 | else | ||
878 | /* ...otherwise, do it normally */ | ||
879 | #endif | ||
880 | play_hop(1); | ||
881 | break; | ||
882 | /* next / prev directories */ | ||
883 | /* and set A-B markers if in a-b mode */ | ||
884 | case ACTION_WPS_ABSETB_NEXTDIR: | ||
885 | if (global_settings.party_mode) | ||
886 | break; | ||
887 | #if defined(AB_REPEAT_ENABLE) | ||
888 | if (ab_repeat_mode_enabled()) | ||
889 | { | ||
890 | ab_set_B_marker(wps_state.id3->elapsed); | ||
891 | ab_jump_to_A_marker(); | ||
892 | } | ||
893 | else | ||
894 | #endif | ||
895 | { | ||
896 | change_dir(1); | ||
897 | } | ||
898 | break; | ||
899 | case ACTION_WPS_ABSETA_PREVDIR: | ||
900 | if (global_settings.party_mode) | ||
901 | break; | ||
902 | #if defined(AB_REPEAT_ENABLE) | ||
903 | if (ab_repeat_mode_enabled()) | ||
904 | ab_set_A_marker(wps_state.id3->elapsed); | ||
905 | else | ||
906 | #endif | ||
907 | { | ||
908 | change_dir(-1); | ||
909 | } | ||
910 | break; | ||
911 | /* menu key functions */ | ||
912 | case ACTION_WPS_MENU: | ||
913 | gwps_leave_wps(); | ||
914 | return GO_TO_ROOT; | ||
915 | break; | ||
916 | |||
917 | |||
918 | #ifdef HAVE_QUICKSCREEN | ||
919 | case ACTION_WPS_QUICKSCREEN: | ||
920 | { | ||
921 | gwps_leave_wps(); | ||
922 | if (quick_screen_quick(button)) | ||
923 | return SYS_USB_CONNECTED; | ||
924 | restore = true; | ||
925 | } | ||
926 | break; | ||
927 | #endif /* HAVE_QUICKSCREEN */ | ||
928 | |||
929 | /* screen settings */ | ||
930 | #ifdef BUTTON_F3 | ||
931 | case ACTION_F3: | ||
932 | { | ||
933 | gwps_leave_wps(); | ||
934 | if (quick_screen_f3(BUTTON_F3)) | ||
935 | return SYS_USB_CONNECTED; | ||
936 | restore = true; | ||
937 | } | ||
938 | break; | ||
939 | #endif /* BUTTON_F3 */ | ||
940 | |||
941 | /* pitch screen */ | ||
942 | #ifdef HAVE_PITCHSCREEN | ||
943 | case ACTION_WPS_PITCHSCREEN: | ||
944 | { | ||
945 | gwps_leave_wps(); | ||
946 | if (1 == gui_syncpitchscreen_run()) | ||
947 | return SYS_USB_CONNECTED; | ||
948 | restore = true; | ||
949 | } | ||
950 | break; | ||
951 | #endif /* HAVE_PITCHSCREEN */ | ||
952 | |||
953 | #ifdef AB_REPEAT_ENABLE | ||
954 | /* reset A&B markers */ | ||
955 | case ACTION_WPS_ABRESET: | ||
956 | if (ab_repeat_mode_enabled()) | ||
957 | { | ||
958 | ab_reset_markers(); | ||
959 | update = true; | ||
960 | } | ||
961 | break; | ||
962 | #endif /* AB_REPEAT_ENABLE */ | ||
963 | |||
964 | /* stop and exit wps */ | ||
965 | case ACTION_WPS_STOP: | ||
966 | if (global_settings.party_mode) | ||
967 | break; | ||
968 | bookmark = true; | ||
969 | exit = true; | ||
970 | break; | ||
971 | |||
972 | case ACTION_WPS_ID3SCREEN: | ||
973 | { | ||
974 | gwps_leave_wps(); | ||
975 | browse_id3(); | ||
976 | restore = true; | ||
977 | } | ||
978 | break; | ||
979 | #ifdef HAVE_TOUCHSCREEN | ||
980 | case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ | ||
981 | { | ||
982 | global_settings.playlist_shuffle = | ||
983 | !global_settings.playlist_shuffle; | ||
984 | #if CONFIG_CODEC == SWCODEC | ||
985 | dsp_set_replaygain(); | ||
986 | #endif | ||
987 | if (global_settings.playlist_shuffle) | ||
988 | playlist_randomise(NULL, current_tick, true); | ||
989 | else | ||
990 | playlist_sort(NULL, true); | ||
991 | } | ||
992 | break; | ||
993 | case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ | ||
994 | { | ||
995 | const struct settings_list *rep_setting = | ||
996 | find_setting(&global_settings.repeat_mode, NULL); | ||
997 | option_select_next_val(rep_setting, false, true); | ||
998 | audio_flush_and_reload_tracks(); | ||
999 | } | ||
1000 | break; | ||
1001 | #endif /* HAVE_TOUCHSCREEN */ | ||
1002 | /* this case is used by the softlock feature | ||
1003 | * it requests a full update here */ | ||
1004 | case ACTION_REDRAW: | ||
1005 | wps_state.do_full_update = true; | ||
1006 | break; | ||
1007 | case ACTION_NONE: /* Timeout, do a partial update */ | ||
1008 | update = true; | ||
1009 | ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ | ||
1010 | break; | ||
1011 | #ifdef HAVE_RECORDING | ||
1012 | case ACTION_WPS_REC: | ||
1013 | exit = true; | ||
1014 | break; | ||
1015 | #endif | ||
1016 | case SYS_POWEROFF: | ||
1017 | default_event_handler(SYS_POWEROFF); | ||
1018 | break; | ||
1019 | case ACTION_WPS_VIEW_PLAYLIST: | ||
1020 | gwps_leave_wps(); | ||
1021 | if (playlist_viewer()) /* true if USB connected */ | ||
1022 | return SYS_USB_CONNECTED; | ||
1023 | restore = true; | ||
1024 | break; | ||
1025 | default: | ||
1026 | if(default_event_handler(button) == SYS_USB_CONNECTED) | ||
1027 | return GO_TO_ROOT; | ||
1028 | update = true; | ||
1029 | break; | ||
1030 | } | ||
1031 | |||
1032 | if (wps_state.do_full_update || update) | ||
1033 | { | ||
1034 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) | ||
1035 | gwps_caption_backlight(&wps_state); | ||
1036 | #endif | ||
1037 | FOR_NB_SCREENS(i) | ||
1038 | { | ||
1039 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
1040 | if (lcd_active() | ||
1041 | #ifdef HAVE_REMOTE_LCD | ||
1042 | /* currently, all remotes are readable without backlight | ||
1043 | * so still update those */ | ||
1044 | || (i == SCREEN_REMOTE) | ||
1045 | #endif | ||
1046 | ) | ||
1047 | #endif | ||
1048 | { | ||
1049 | gui_wps_update(&gui_wps[i]); | ||
1050 | } | ||
1051 | } | ||
1052 | wps_state.do_full_update = false; | ||
1053 | update = false; | ||
1054 | } | ||
1055 | |||
1056 | if (restore && wps_state.id3 && | ||
1057 | ((restoretimer == RESTORE_WPS_INSTANTLY) || | ||
1058 | TIME_AFTER(current_tick, restoretimer))) | ||
1059 | { | ||
1060 | restore = false; | ||
1061 | restoretimer = RESTORE_WPS_INSTANTLY; | ||
1062 | gwps_fix_statusbars(); | ||
1063 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
1064 | lcd_activation_set_hook(wps_lcd_activation_hook); | ||
1065 | #endif | ||
1066 | FOR_NB_SCREENS(i) | ||
1067 | { | ||
1068 | screens[i].stop_scroll(); | ||
1069 | gui_wps_display(&gui_wps[i]); | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | if (exit) { | ||
1074 | #ifdef HAVE_LCD_CHARCELLS | ||
1075 | status_set_record(false); | ||
1076 | status_set_audio(false); | ||
1077 | #endif | ||
1078 | if (global_settings.fade_on_stop) | ||
1079 | fade(false, true); | ||
1080 | |||
1081 | if (bookmark) | ||
1082 | bookmark_autobookmark(); | ||
1083 | audio_stop(); | ||
1084 | #ifdef AB_REPEAT_ENABLE | ||
1085 | ab_reset_markers(); | ||
1086 | #endif | ||
1087 | gwps_leave_wps(); | ||
1088 | #ifdef HAVE_RECORDING | ||
1089 | if (button == ACTION_WPS_REC) | ||
1090 | return GO_TO_RECSCREEN; | ||
1091 | #endif | ||
1092 | if (global_settings.browse_current) | ||
1093 | return GO_TO_PREVIOUS_BROWSER; | ||
1094 | return GO_TO_PREVIOUS; | ||
1095 | } | ||
1096 | |||
1097 | if (button && !IS_SYSEVENT(button) ) | ||
1098 | storage_spin(); | ||
1099 | } | ||
1100 | return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ | ||
1101 | } | ||
1102 | |||
1103 | /* this is called from the playback thread so NO DRAWING! */ | ||
1104 | static void track_changed_callback(void *param) | ||
1105 | { | ||
1106 | wps_state.id3 = (struct mp3entry*)param; | ||
1107 | wps_state.nid3 = audio_next_track(); | ||
1108 | if (wps_state.id3->cuesheet) | ||
1109 | { | ||
1110 | cue_find_current_track(wps_state.id3->cuesheet, wps_state.id3->elapsed); | ||
1111 | cue_spoof_id3(wps_state.id3->cuesheet, wps_state.id3); | ||
1112 | } | ||
1113 | wps_state.do_full_update = true; | ||
1114 | } | ||
1115 | static void nextid3available_callback(void* param) | ||
1116 | { | ||
1117 | (void)param; | ||
1118 | wps_state.nid3 = audio_next_track(); | ||
1119 | wps_state.do_full_update = true; | ||
1120 | } | ||
1121 | |||
1122 | |||
1123 | static void wps_state_init(void) | ||
1124 | { | ||
1125 | wps_state.ff_rewind = false; | ||
1126 | wps_state.paused = false; | ||
1127 | if(audio_status() & AUDIO_STATUS_PLAY) | ||
1128 | { | ||
1129 | wps_state.id3 = audio_current_track(); | ||
1130 | wps_state.nid3 = audio_next_track(); | ||
1131 | } | ||
1132 | else | ||
1133 | { | ||
1134 | wps_state.id3 = NULL; | ||
1135 | wps_state.nid3 = NULL; | ||
1136 | } | ||
1137 | /* We'll be updating due to restore initialized with true */ | ||
1138 | wps_state.do_full_update = false; | ||
1139 | /* add the WPS track event callbacks */ | ||
1140 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); | ||
1141 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); | ||
1142 | } | ||
1143 | |||
1144 | |||
1145 | #ifdef HAVE_LCD_BITMAP | ||
1146 | static void statusbar_toggle_handler(void *data) | ||
1147 | { | ||
1148 | (void)data; | ||
1149 | int i; | ||
1150 | gwps_fix_statusbars(); | ||
1151 | |||
1152 | FOR_NB_SCREENS(i) | ||
1153 | { | ||
1154 | struct viewport *vp = &gui_wps[i].data->viewports[0].vp; | ||
1155 | bool draw = wpsbars & (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); | ||
1156 | if (!draw) | ||
1157 | { | ||
1158 | vp->y = 0; | ||
1159 | vp->height = screens[i].lcdheight; | ||
1160 | } | ||
1161 | else | ||
1162 | { | ||
1163 | bool bar_at_top = statusbar_position(i) != STATUSBAR_BOTTOM; | ||
1164 | vp->y = bar_at_top?STATUSBAR_HEIGHT:0; | ||
1165 | vp->height = screens[i].lcdheight - STATUSBAR_HEIGHT; | ||
1166 | } | ||
1167 | } | ||
1168 | } | ||
1169 | #endif | ||
1170 | |||
1171 | void gui_sync_wps_init(void) | ||
1172 | { | ||
1173 | int i; | ||
1174 | FOR_NB_SCREENS(i) | ||
1175 | { | ||
1176 | wps_data_init(&wps_datas[i]); | ||
1177 | #ifdef HAVE_ALBUMART | ||
1178 | wps_datas[i].wps_uses_albumart = 0; | ||
1179 | #endif | ||
1180 | #ifdef HAVE_REMOTE_LCD | ||
1181 | wps_datas[i].remote_wps = (i != 0); | ||
1182 | #endif | ||
1183 | gui_wps[i].data = &wps_datas[i]; | ||
1184 | gui_wps[i].display = &screens[i]; | ||
1185 | /* Currently no seperate wps_state needed/possible | ||
1186 | so use the only available ( "global" ) one */ | ||
1187 | gui_wps[i].state = &wps_state; | ||
1188 | } | ||
1189 | #ifdef HAVE_LCD_BITMAP | ||
1190 | add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggle_handler); | ||
1191 | #endif | ||
1192 | #if LCD_DEPTH > 1 | ||
1193 | unload_wps_backdrop(); | ||
1194 | #endif | ||
1195 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
1196 | unload_remote_wps_backdrop(); | ||
1197 | #endif | ||
1198 | } | ||
1199 | |||
1200 | #ifdef HAVE_ALBUMART | ||
1201 | /* Returns true if at least one of the gui_wps screens has an album art | ||
1202 | tag in its wps structure */ | ||
1203 | bool gui_sync_wps_uses_albumart(void) | ||
1204 | { | ||
1205 | int i; | ||
1206 | FOR_NB_SCREENS(i) { | ||
1207 | struct gui_wps *gwps = &gui_wps[i]; | ||
1208 | if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE)) | ||
1209 | return true; | ||
1210 | } | ||
1211 | return false; | ||
1212 | } | ||
1213 | #endif | ||