summaryrefslogtreecommitdiff
path: root/apps/gui/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps.c')
-rw-r--r--apps/gui/wps.c271
1 files changed, 111 insertions, 160 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 1489ff0026..a5fe304d21 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -74,12 +74,6 @@
74 /* 3% of 30min file == 54s step size */ 74 /* 3% of 30min file == 54s step size */
75#define MIN_FF_REWIND_STEP 500 75#define MIN_FF_REWIND_STEP 500
76 76
77/* currently only one wps_state is needed, initialize to 0 */
78 struct wps_state wps_state = { .id3 = NULL };
79static struct gui_wps gui_wps[NB_SCREENS] = {{ .data = NULL }};
80static struct wps_data wps_datas[NB_SCREENS] = {{ .wps_loaded = 0 }};
81static struct wps_sync_data wps_sync_data = { .do_full_update = false };
82
83/* initial setup of wps_data */ 77/* initial setup of wps_data */
84static void wps_state_init(void); 78static void wps_state_init(void);
85static void track_changed_callback(void *param); 79static void track_changed_callback(void *param);
@@ -94,35 +88,9 @@ static void nextid3available_callback(void* param);
94#define DEFAULT_WPS(screen) (WPS_DEFAULTCFG) 88#define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
95#endif 89#endif
96 90
97void wps_data_load(enum screen_type screen, const char *buf, bool isfile) 91char* wps_default_skin(enum screen_type screen)
98{ 92{
99 bool loaded_ok; 93 static char *skin_buf[NB_SCREENS] = {
100
101#ifndef __PCTOOL__
102 /*
103 * Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this
104 * wants to be a virtual file. Feel free to modify dirbrowse()
105 * if you're feeling brave.
106 */
107
108 if (buf && ! strcmp(buf, DEFAULT_WPS(screen)) )
109 {
110#ifdef HAVE_REMOTE_LCD
111 if (screen == SCREEN_REMOTE)
112 global_settings.rwps_file[0] = '\0';
113 else
114#endif
115 global_settings.wps_file[0] = '\0';
116 buf = NULL;
117 }
118
119#endif /* __PCTOOL__ */
120
121 loaded_ok = buf && skin_data_load(screen, gui_wps[screen].data, buf, isfile);
122
123 if (!loaded_ok) /* load the hardcoded default */
124 {
125 char *skin_buf[NB_SCREENS] = {
126#ifdef HAVE_LCD_BITMAP 94#ifdef HAVE_LCD_BITMAP
127#if LCD_DEPTH > 1 95#if LCD_DEPTH > 1
128 "%X(d)\n" 96 "%X(d)\n"
@@ -148,8 +116,7 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile)
148 "%pb\n", 116 "%pb\n",
149#endif 117#endif
150 }; 118 };
151 skin_data_load(screen, gui_wps[screen].data, skin_buf[screen], false); 119 return skin_buf[screen];
152 }
153} 120}
154 121
155void fade(bool fade_in, bool updatewps) 122void fade(bool fade_in, bool updatewps)
@@ -158,7 +125,7 @@ void fade(bool fade_in, bool updatewps)
158 int fp_min_vol = sound_min(SOUND_VOLUME) << 8; 125 int fp_min_vol = sound_min(SOUND_VOLUME) << 8;
159 int fp_step = (fp_global_vol - fp_min_vol) / 30; 126 int fp_step = (fp_global_vol - fp_min_vol) / 30;
160 int i; 127 int i;
161 wps_state.is_fading = !fade_in; 128 skin_get_global_state()->is_fading = !fade_in;
162 if (fade_in) { 129 if (fade_in) {
163 /* fade in */ 130 /* fade in */
164 int fp_volume = fp_min_vol; 131 int fp_volume = fp_min_vol;
@@ -175,7 +142,7 @@ void fade(bool fade_in, bool updatewps)
175 if (updatewps) 142 if (updatewps)
176 { 143 {
177 FOR_NB_SCREENS(i) 144 FOR_NB_SCREENS(i)
178 skin_update(&gui_wps[i], SKIN_REFRESH_NON_STATIC); 145 skin_update(WPS, i, SKIN_REFRESH_NON_STATIC);
179 } 146 }
180 sleep(1); 147 sleep(1);
181 } 148 }
@@ -191,12 +158,12 @@ void fade(bool fade_in, bool updatewps)
191 if (updatewps) 158 if (updatewps)
192 { 159 {
193 FOR_NB_SCREENS(i) 160 FOR_NB_SCREENS(i)
194 skin_update(&gui_wps[i], SKIN_REFRESH_NON_STATIC); 161 skin_update(WPS, i, SKIN_REFRESH_NON_STATIC);
195 } 162 }
196 sleep(1); 163 sleep(1);
197 } 164 }
198 audio_pause(); 165 audio_pause();
199 wps_state.is_fading = false; 166 skin_get_global_state()->is_fading = false;
200#if CONFIG_CODEC != SWCODEC 167#if CONFIG_CODEC != SWCODEC
201#ifndef SIMULATOR 168#ifndef SIMULATOR
202 /* let audio thread run and wait for the mas to run out of data */ 169 /* let audio thread run and wait for the mas to run out of data */
@@ -210,9 +177,9 @@ void fade(bool fade_in, bool updatewps)
210 } 177 }
211} 178}
212 179
213static bool update_onvol_change(struct gui_wps * gwps) 180static bool update_onvol_change(enum screen_type screen)
214{ 181{
215 skin_update(gwps, SKIN_REFRESH_NON_STATIC); 182 skin_update(WPS, screen, SKIN_REFRESH_NON_STATIC);
216 183
217#ifdef HAVE_LCD_CHARCELLS 184#ifdef HAVE_LCD_CHARCELLS
218 splashf(0, "Vol: %3d dB", 185 splashf(0, "Vol: %3d dB",
@@ -250,16 +217,16 @@ static int skintouch_to_wps(struct wps_data *data)
250 return ACTION_WPS_HOTKEY; 217 return ACTION_WPS_HOTKEY;
251#endif 218#endif
252 case WPS_TOUCHREGION_SCROLLBAR: 219 case WPS_TOUCHREGION_SCROLLBAR:
253 wps_state.id3->elapsed = wps_state.id3->length*offset/100; 220 skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100;
254 if (!wps_state.paused) 221 if (!skin_get_global_state()->paused)
255#if (CONFIG_CODEC == SWCODEC) 222#if (CONFIG_CODEC == SWCODEC)
256 audio_pre_ff_rewind(); 223 audio_pre_ff_rewind();
257#else 224#else
258 audio_pause(); 225 audio_pause();
259#endif 226#endif
260 audio_ff_rewind(wps_state.id3->elapsed); 227 audio_ff_rewind(skin_get_global_state()->id3->elapsed);
261#if (CONFIG_CODEC != SWCODEC) 228#if (CONFIG_CODEC != SWCODEC)
262 if (!wps_state.paused) 229 if (!skin_get_global_state()->paused)
263 audio_resume(); 230 audio_resume();
264#endif 231#endif
265 return ACTION_TOUCHSCREEN; 232 return ACTION_TOUCHSCREEN;
@@ -307,20 +274,20 @@ bool ffwd_rew(int button)
307 case ACTION_WPS_SEEKFWD: 274 case ACTION_WPS_SEEKFWD:
308 direction = 1; 275 direction = 1;
309 case ACTION_WPS_SEEKBACK: 276 case ACTION_WPS_SEEKBACK:
310 if (wps_state.ff_rewind) 277 if (skin_get_global_state()->ff_rewind)
311 { 278 {
312 if (direction == 1) 279 if (direction == 1)
313 { 280 {
314 /* fast forwarding, calc max step relative to end */ 281 /* fast forwarding, calc max step relative to end */
315 max_step = (wps_state.id3->length - 282 max_step = (skin_get_global_state()->id3->length -
316 (wps_state.id3->elapsed + 283 (skin_get_global_state()->id3->elapsed +
317 ff_rewind_count)) * 284 ff_rewind_count)) *
318 FF_REWIND_MAX_PERCENT / 100; 285 FF_REWIND_MAX_PERCENT / 100;
319 } 286 }
320 else 287 else
321 { 288 {
322 /* rewinding, calc max step relative to start */ 289 /* rewinding, calc max step relative to start */
323 max_step = (wps_state.id3->elapsed + ff_rewind_count) * 290 max_step = (skin_get_global_state()->id3->elapsed + ff_rewind_count) *
324 FF_REWIND_MAX_PERCENT / 100; 291 FF_REWIND_MAX_PERCENT / 100;
325 } 292 }
326 293
@@ -337,9 +304,9 @@ bool ffwd_rew(int button)
337 else 304 else
338 { 305 {
339 if ( (audio_status() & AUDIO_STATUS_PLAY) && 306 if ( (audio_status() & AUDIO_STATUS_PLAY) &&
340 wps_state.id3 && wps_state.id3->length ) 307 skin_get_global_state()->id3 && skin_get_global_state()->id3->length )
341 { 308 {
342 if (!wps_state.paused) 309 if (!skin_get_global_state()->paused)
343#if (CONFIG_CODEC == SWCODEC) 310#if (CONFIG_CODEC == SWCODEC)
344 audio_pre_ff_rewind(); 311 audio_pre_ff_rewind();
345#else 312#else
@@ -347,14 +314,14 @@ bool ffwd_rew(int button)
347#endif 314#endif
348#if CONFIG_KEYPAD == PLAYER_PAD 315#if CONFIG_KEYPAD == PLAYER_PAD
349 FOR_NB_SCREENS(i) 316 FOR_NB_SCREENS(i)
350 gui_wps[i].display->stop_scroll(); 317 skin_get_gwps(WPS, i)->display->stop_scroll();
351#endif 318#endif
352 if (direction > 0) 319 if (direction > 0)
353 status_set_ffmode(STATUS_FASTFORWARD); 320 status_set_ffmode(STATUS_FASTFORWARD);
354 else 321 else
355 status_set_ffmode(STATUS_FASTBACKWARD); 322 status_set_ffmode(STATUS_FASTBACKWARD);
356 323
357 wps_state.ff_rewind = true; 324 skin_get_global_state()->ff_rewind = true;
358 325
359 step = 1000 * global_settings.ff_rewind_min_step; 326 step = 1000 * global_settings.ff_rewind_min_step;
360 } 327 }
@@ -363,23 +330,23 @@ bool ffwd_rew(int button)
363 } 330 }
364 331
365 if (direction > 0) { 332 if (direction > 0) {
366 if ((wps_state.id3->elapsed + ff_rewind_count) > 333 if ((skin_get_global_state()->id3->elapsed + ff_rewind_count) >
367 wps_state.id3->length) 334 skin_get_global_state()->id3->length)
368 ff_rewind_count = wps_state.id3->length - 335 ff_rewind_count = skin_get_global_state()->id3->length -
369 wps_state.id3->elapsed; 336 skin_get_global_state()->id3->elapsed;
370 } 337 }
371 else { 338 else {
372 if ((int)(wps_state.id3->elapsed + ff_rewind_count) < 0) 339 if ((int)(skin_get_global_state()->id3->elapsed + ff_rewind_count) < 0)
373 ff_rewind_count = -wps_state.id3->elapsed; 340 ff_rewind_count = -skin_get_global_state()->id3->elapsed;
374 } 341 }
375 342
376 /* set the wps state ff_rewind_count so the progess info 343 /* set the wps state ff_rewind_count so the progess info
377 displays corectly */ 344 displays corectly */
378 wps_state.ff_rewind_count = (wps_state.wps_time_countup == false)? 345 skin_get_global_state()->ff_rewind_count = (skin_get_global_state()->wps_time_countup == false)?
379 ff_rewind_count:-ff_rewind_count; 346 ff_rewind_count:-ff_rewind_count;
380 FOR_NB_SCREENS(i) 347 FOR_NB_SCREENS(i)
381 { 348 {
382 skin_update(&gui_wps[i], 349 skin_update(WPS, i,
383 SKIN_REFRESH_PLAYER_PROGRESS | 350 SKIN_REFRESH_PLAYER_PROGRESS |
384 SKIN_REFRESH_DYNAMIC); 351 SKIN_REFRESH_DYNAMIC);
385 } 352 }
@@ -387,18 +354,18 @@ bool ffwd_rew(int button)
387 break; 354 break;
388 355
389 case ACTION_WPS_STOPSEEK: 356 case ACTION_WPS_STOPSEEK:
390 wps_state.id3->elapsed = wps_state.id3->elapsed+ff_rewind_count; 357 skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->elapsed+ff_rewind_count;
391 audio_ff_rewind(wps_state.id3->elapsed); 358 audio_ff_rewind(skin_get_global_state()->id3->elapsed);
392 wps_state.ff_rewind_count = 0; 359 skin_get_global_state()->ff_rewind_count = 0;
393 wps_state.ff_rewind = false; 360 skin_get_global_state()->ff_rewind = false;
394 status_set_ffmode(0); 361 status_set_ffmode(0);
395#if (CONFIG_CODEC != SWCODEC) 362#if (CONFIG_CODEC != SWCODEC)
396 if (!wps_state.paused) 363 if (!skin_get_global_state()->paused)
397 audio_resume(); 364 audio_resume();
398#endif 365#endif
399#ifdef HAVE_LCD_CHARCELLS 366#ifdef HAVE_LCD_CHARCELLS
400 FOR_NB_SCREENS(i) 367 FOR_NB_SCREENS(i)
401 skin_update(&gui_wps[i], SKIN_REFRESH_ALL); 368 skin_update(WPS, i, SKIN_REFRESH_ALL);
402#endif 369#endif
403 exit = true; 370 exit = true;
404 break; 371 break;
@@ -416,7 +383,7 @@ bool ffwd_rew(int button)
416 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); 383 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK);
417#ifdef HAVE_TOUCHSCREEN 384#ifdef HAVE_TOUCHSCREEN
418 if (button == ACTION_TOUCHSCREEN) 385 if (button == ACTION_TOUCHSCREEN)
419 button = skintouch_to_wps(gui_wps[SCREEN_MAIN].data); 386 button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data);
420 if (button != ACTION_WPS_SEEKFWD && 387 if (button != ACTION_WPS_SEEKFWD &&
421 button != ACTION_WPS_SEEKBACK) 388 button != ACTION_WPS_SEEKBACK)
422 button = ACTION_WPS_STOPSEEK; 389 button = ACTION_WPS_STOPSEEK;
@@ -431,7 +398,7 @@ void display_keylock_text(bool locked)
431{ 398{
432 int i; 399 int i;
433 FOR_NB_SCREENS(i) 400 FOR_NB_SCREENS(i)
434 gui_wps[i].display->stop_scroll(); 401 skin_get_gwps(WPS, i)->display->stop_scroll();
435 402
436 splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF)); 403 splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF));
437} 404}
@@ -497,20 +464,21 @@ static void change_dir(int direction)
497 464
498static void prev_track(unsigned long skip_thresh) 465static void prev_track(unsigned long skip_thresh)
499{ 466{
500 if (wps_state.id3->elapsed < skip_thresh) 467 struct wps_state *state = skin_get_global_state();
468 if (state->id3->elapsed < skip_thresh)
501 { 469 {
502 audio_prev(); 470 audio_prev();
503 return; 471 return;
504 } 472 }
505 else 473 else
506 { 474 {
507 if (wps_state.id3->cuesheet) 475 if (state->id3->cuesheet)
508 { 476 {
509 curr_cuesheet_skip(wps_state.id3->cuesheet, -1, wps_state.id3->elapsed); 477 curr_cuesheet_skip(state->id3->cuesheet, -1, state->id3->elapsed);
510 return; 478 return;
511 } 479 }
512 480
513 if (!wps_state.paused) 481 if (!state->paused)
514#if (CONFIG_CODEC == SWCODEC) 482#if (CONFIG_CODEC == SWCODEC)
515 audio_pre_ff_rewind(); 483 audio_pre_ff_rewind();
516#else 484#else
@@ -520,7 +488,7 @@ static void prev_track(unsigned long skip_thresh)
520 audio_ff_rewind(0); 488 audio_ff_rewind(0);
521 489
522#if (CONFIG_CODEC != SWCODEC) 490#if (CONFIG_CODEC != SWCODEC)
523 if (!wps_state.paused) 491 if (!state->paused)
524 audio_resume(); 492 audio_resume();
525#endif 493#endif
526 } 494 }
@@ -528,10 +496,11 @@ static void prev_track(unsigned long skip_thresh)
528 496
529static void next_track(void) 497static void next_track(void)
530{ 498{
499 struct wps_state *state = skin_get_global_state();
531 /* take care of if we're playing a cuesheet */ 500 /* take care of if we're playing a cuesheet */
532 if (wps_state.id3->cuesheet) 501 if (state->id3->cuesheet)
533 { 502 {
534 if (curr_cuesheet_skip(wps_state.id3->cuesheet, 1, wps_state.id3->elapsed)) 503 if (curr_cuesheet_skip(state->id3->cuesheet, 1, state->id3->elapsed))
535 { 504 {
536 /* if the result was false, then we really want 505 /* if the result was false, then we really want
537 to skip to the next track */ 506 to skip to the next track */
@@ -544,9 +513,10 @@ static void next_track(void)
544 513
545static void play_hop(int direction) 514static void play_hop(int direction)
546{ 515{
516 struct wps_state *state = skin_get_global_state();
547 long step = global_settings.skip_length*1000; 517 long step = global_settings.skip_length*1000;
548 long elapsed = wps_state.id3->elapsed; 518 long elapsed = state->id3->elapsed;
549 long remaining = wps_state.id3->length - elapsed; 519 long remaining = state->id3->length - elapsed;
550 520
551 if (step < 0) 521 if (step < 0)
552 { 522 {
@@ -590,7 +560,7 @@ static void play_hop(int direction)
590 { 560 {
591 elapsed += step * direction; 561 elapsed += step * direction;
592 } 562 }
593 if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) 563 if((audio_status() & AUDIO_STATUS_PLAY) && !state->paused)
594 { 564 {
595#if (CONFIG_CODEC == SWCODEC) 565#if (CONFIG_CODEC == SWCODEC)
596 audio_pre_ff_rewind(); 566 audio_pre_ff_rewind();
@@ -598,9 +568,9 @@ static void play_hop(int direction)
598 audio_pause(); 568 audio_pause();
599#endif 569#endif
600 } 570 }
601 audio_ff_rewind(wps_state.id3->elapsed = elapsed); 571 audio_ff_rewind(state->id3->elapsed = elapsed);
602#if (CONFIG_CODEC != SWCODEC) 572#if (CONFIG_CODEC != SWCODEC)
603 if (!wps_state.paused) 573 if (!state->paused)
604 audio_resume(); 574 audio_resume();
605#endif 575#endif
606} 576}
@@ -615,7 +585,7 @@ static void play_hop(int direction)
615static void wps_lcd_activation_hook(void *param) 585static void wps_lcd_activation_hook(void *param)
616{ 586{
617 (void)param; 587 (void)param;
618 wps_sync_data.do_full_update = true; 588 skin_request_full_update(WPS);
619 /* force timeout in wps main loop, so that the update is instantly */ 589 /* force timeout in wps main loop, so that the update is instantly */
620 queue_post(&button_queue, BUTTON_NONE, 0); 590 queue_post(&button_queue, BUTTON_NONE, 0);
621} 591}
@@ -627,11 +597,11 @@ static void gwps_leave_wps(void)
627 597
628 FOR_NB_SCREENS(i) 598 FOR_NB_SCREENS(i)
629 { 599 {
630 gui_wps[i].display->stop_scroll(); 600 skin_get_gwps(WPS, i)->display->stop_scroll();
631#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 601#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
632 gui_wps[i].display->backdrop_show(sb_get_backdrop(i)); 602 skin_backdrop_show(sb_get_backdrop(i));
633#endif 603#endif
634 viewportmanager_theme_undo(i, skin_has_sbs(i, gui_wps[i].data)); 604 viewportmanager_theme_undo(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data));
635 605
636 } 606 }
637 607
@@ -651,12 +621,14 @@ static void gwps_leave_wps(void)
651static void gwps_enter_wps(void) 621static void gwps_enter_wps(void)
652{ 622{
653 int i; 623 int i;
624 struct gui_wps *gwps;
625 struct screen *display;
654 FOR_NB_SCREENS(i) 626 FOR_NB_SCREENS(i)
655 { 627 {
656 struct gui_wps *gwps = &gui_wps[i]; 628 gwps = skin_get_gwps(WPS, i);
657 struct screen *display = gwps->display; 629 display = gwps->display;
658 display->stop_scroll(); 630 display->stop_scroll();
659 viewportmanager_theme_enable(i, skin_has_sbs(i, gui_wps[i].data), NULL); 631 viewportmanager_theme_enable(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data), NULL);
660 632
661 /* Update the values in the first (default) viewport - in case the user 633 /* Update the values in the first (default) viewport - in case the user
662 has modified the statusbar or colour settings */ 634 has modified the statusbar or colour settings */
@@ -675,15 +647,16 @@ static void gwps_enter_wps(void)
675#endif 647#endif
676 /* make the backdrop actually take effect */ 648 /* make the backdrop actually take effect */
677#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 649#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
678 display->backdrop_show(gwps->data->backdrop); 650 skin_backdrop_show(gwps->data->backdrop_id);
679#endif 651#endif
680 display->clear_display(); 652 display->clear_display();
681 skin_update(gwps, SKIN_REFRESH_ALL); 653 skin_update(WPS, i, SKIN_REFRESH_ALL);
682 654
683 } 655 }
684#ifdef HAVE_TOUCHSCREEN 656#ifdef HAVE_TOUCHSCREEN
685 skin_disarm_touchregions(gui_wps[SCREEN_MAIN].data); 657 gwps = skin_get_gwps(WPS, SCREEN_MAIN);
686 if (!gui_wps[SCREEN_MAIN].data->touchregions) 658 skin_disarm_touchregions(gwps->data);
659 if (!gwps->data->touchregions)
687 touchscreen_set_mode(TOUCHSCREEN_BUTTON); 660 touchscreen_set_mode(TOUCHSCREEN_BUTTON);
688#endif 661#endif
689 /* force statusbar/skin update since we just cleared the whole screen */ 662 /* force statusbar/skin update since we just cleared the whole screen */
@@ -710,6 +683,7 @@ long gui_wps_show(void)
710 bool vol_changed = false; 683 bool vol_changed = false;
711 int i; 684 int i;
712 long last_left = 0, last_right = 0; 685 long last_left = 0, last_right = 0;
686 struct wps_state *state = skin_get_global_state();
713 687
714#ifdef HAVE_LCD_CHARCELLS 688#ifdef HAVE_LCD_CHARCELLS
715 status_set_audio(true); 689 status_set_audio(true);
@@ -727,19 +701,19 @@ long gui_wps_show(void)
727 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; 701 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
728 702
729 /* did someone else (i.e power thread) change audio pause mode? */ 703 /* did someone else (i.e power thread) change audio pause mode? */
730 if (wps_state.paused != audio_paused) { 704 if (state->paused != audio_paused) {
731 wps_state.paused = audio_paused; 705 state->paused = audio_paused;
732 706
733 /* if another thread paused audio, we are probably in car mode, 707 /* if another thread paused audio, we are probably in car mode,
734 about to shut down. lets save the settings. */ 708 about to shut down. lets save the settings. */
735 if (wps_state.paused) { 709 if (state->paused) {
736 settings_save(); 710 settings_save();
737#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) 711#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
738 call_storage_idle_notifys(true); 712 call_storage_idle_notifys(true);
739#endif 713#endif
740 } 714 }
741 } 715 }
742 button = skin_wait_for_action(gui_wps, CONTEXT_WPS|ALLOW_SOFTLOCK, 716 button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK,
743 restore ? 1 : HZ/5); 717 restore ? 1 : HZ/5);
744 718
745 /* Exit if audio has stopped playing. This happens e.g. at end of 719 /* Exit if audio has stopped playing. This happens e.g. at end of
@@ -748,7 +722,7 @@ long gui_wps_show(void)
748 exit = true; 722 exit = true;
749#ifdef HAVE_TOUCHSCREEN 723#ifdef HAVE_TOUCHSCREEN
750 if (button == ACTION_TOUCHSCREEN) 724 if (button == ACTION_TOUCHSCREEN)
751 button = skintouch_to_wps(gui_wps[SCREEN_MAIN].data); 725 button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data);
752#endif 726#endif
753/* The iPods/X5/M5 use a single button for the A-B mode markers, 727/* The iPods/X5/M5 use a single button for the A-B mode markers,
754 defined as ACTION_WPSAB_SINGLE in their config files. */ 728 defined as ACTION_WPSAB_SINGLE in their config files. */
@@ -786,7 +760,7 @@ long gui_wps_show(void)
786 { 760 {
787 bool hotkey = button == ACTION_WPS_HOTKEY; 761 bool hotkey = button == ACTION_WPS_HOTKEY;
788 gwps_leave_wps(); 762 gwps_leave_wps();
789 int retval = onplay(wps_state.id3->path, 763 int retval = onplay(state->id3->path,
790 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); 764 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey);
791 /* if music is stopped in the context menu we want to exit the wps */ 765 /* if music is stopped in the context menu we want to exit the wps */
792 if (retval == ONPLAY_MAINMENU 766 if (retval == ONPLAY_MAINMENU
@@ -815,9 +789,9 @@ long gui_wps_show(void)
815 case ACTION_WPS_PLAY: 789 case ACTION_WPS_PLAY:
816 if (global_settings.party_mode) 790 if (global_settings.party_mode)
817 break; 791 break;
818 if ( wps_state.paused ) 792 if ( state->paused )
819 { 793 {
820 wps_state.paused = false; 794 state->paused = false;
821 if ( global_settings.fade_on_stop ) 795 if ( global_settings.fade_on_stop )
822 fade(true, true); 796 fade(true, true);
823 else 797 else
@@ -825,7 +799,7 @@ long gui_wps_show(void)
825 } 799 }
826 else 800 else
827 { 801 {
828 wps_state.paused = true; 802 state->paused = true;
829 if ( global_settings.fade_on_stop ) 803 if ( global_settings.fade_on_stop )
830 fade(false, true); 804 fade(false, true);
831 else 805 else
@@ -852,7 +826,7 @@ long gui_wps_show(void)
852 break; 826 break;
853 if (current_tick -last_right < HZ) 827 if (current_tick -last_right < HZ)
854 { 828 {
855 if (wps_state.id3->cuesheet) 829 if (state->id3->cuesheet)
856 { 830 {
857 audio_next(); 831 audio_next();
858 } 832 }
@@ -872,9 +846,9 @@ long gui_wps_show(void)
872 break; 846 break;
873 if (current_tick -last_left < HZ) 847 if (current_tick -last_left < HZ)
874 { 848 {
875 if (wps_state.id3->cuesheet) 849 if (state->id3->cuesheet)
876 { 850 {
877 if (!wps_state.paused) 851 if (!state->paused)
878#if (CONFIG_CODEC == SWCODEC) 852#if (CONFIG_CODEC == SWCODEC)
879 audio_pre_ff_rewind(); 853 audio_pre_ff_rewind();
880#else 854#else
@@ -902,7 +876,7 @@ long gui_wps_show(void)
902 is past the A marker, jump back to the A marker... */ 876 is past the A marker, jump back to the A marker... */
903 if ( ab_repeat_mode_enabled() ) 877 if ( ab_repeat_mode_enabled() )
904 { 878 {
905 if ( ab_after_A_marker(wps_state.id3->elapsed) ) 879 if ( ab_after_A_marker(state->id3->elapsed) )
906 { 880 {
907 ab_jump_to_A_marker(); 881 ab_jump_to_A_marker();
908 break; 882 break;
@@ -925,7 +899,7 @@ long gui_wps_show(void)
925 before the A marker, jump to the A marker... */ 899 before the A marker, jump to the A marker... */
926 if ( ab_repeat_mode_enabled() ) 900 if ( ab_repeat_mode_enabled() )
927 { 901 {
928 if ( ab_before_A_marker(wps_state.id3->elapsed) ) 902 if ( ab_before_A_marker(state->id3->elapsed) )
929 { 903 {
930 ab_jump_to_A_marker(); 904 ab_jump_to_A_marker();
931 break; 905 break;
@@ -944,7 +918,7 @@ long gui_wps_show(void)
944#if defined(AB_REPEAT_ENABLE) 918#if defined(AB_REPEAT_ENABLE)
945 if (ab_repeat_mode_enabled()) 919 if (ab_repeat_mode_enabled())
946 { 920 {
947 ab_set_B_marker(wps_state.id3->elapsed); 921 ab_set_B_marker(state->id3->elapsed);
948 ab_jump_to_A_marker(); 922 ab_jump_to_A_marker();
949 } 923 }
950 else 924 else
@@ -958,7 +932,7 @@ long gui_wps_show(void)
958 break; 932 break;
959#if defined(AB_REPEAT_ENABLE) 933#if defined(AB_REPEAT_ENABLE)
960 if (ab_repeat_mode_enabled()) 934 if (ab_repeat_mode_enabled())
961 ab_set_A_marker(wps_state.id3->elapsed); 935 ab_set_A_marker(state->id3->elapsed);
962 else 936 else
963#endif 937#endif
964 { 938 {
@@ -1060,7 +1034,7 @@ long gui_wps_show(void)
1060 /* this case is used by the softlock feature 1034 /* this case is used by the softlock feature
1061 * it requests a full update here */ 1035 * it requests a full update here */
1062 case ACTION_REDRAW: 1036 case ACTION_REDRAW:
1063 wps_sync_data.do_full_update = true; 1037 skin_request_full_update(WPS);
1064 break; 1038 break;
1065 case ACTION_NONE: /* Timeout, do a partial update */ 1039 case ACTION_NONE: /* Timeout, do a partial update */
1066 update = true; 1040 update = true;
@@ -1095,7 +1069,7 @@ long gui_wps_show(void)
1095 setvol(); 1069 setvol();
1096 FOR_NB_SCREENS(i) 1070 FOR_NB_SCREENS(i)
1097 { 1071 {
1098 if(update_onvol_change(&gui_wps[i])) 1072 if(update_onvol_change(i))
1099 res = true; 1073 res = true;
1100 } 1074 }
1101 if (res) { 1075 if (res) {
@@ -1117,15 +1091,15 @@ long gui_wps_show(void)
1117 /* we remove the update delay since it's not very usable in the wps, 1091 /* we remove the update delay since it's not very usable in the wps,
1118 * e.g. during volume changing or ffwd/rewind */ 1092 * e.g. during volume changing or ffwd/rewind */
1119 sb_skin_set_update_delay(0); 1093 sb_skin_set_update_delay(0);
1120 wps_sync_data.do_full_update = update = false; 1094 skin_request_full_update(WPS);
1095 update = true;
1121 gwps_enter_wps(); 1096 gwps_enter_wps();
1122 } 1097 }
1123 else if (wps_sync_data.do_full_update || update) 1098 else
1124 { 1099 {
1125#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) 1100#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1126 gwps_caption_backlight(&wps_state); 1101 gwps_caption_backlight(state);
1127#endif 1102#endif
1128 bool full_update = wps_sync_data.do_full_update;
1129 FOR_NB_SCREENS(i) 1103 FOR_NB_SCREENS(i)
1130 { 1104 {
1131#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 1105#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
@@ -1134,17 +1108,12 @@ long gui_wps_show(void)
1134 if (lcd_active() || (i != SCREEN_MAIN)) 1108 if (lcd_active() || (i != SCREEN_MAIN))
1135#endif 1109#endif
1136 { 1110 {
1137#if NB_SCREENS > 1 1111 bool full_update = skin_do_full_update(WPS, i);
1138 if (i==SCREEN_MAIN && wps_sync_data.do_full_update) 1112 if (update || full_update)
1139 { 1113 {
1140 wps_sync_data.do_full_update = false; 1114 skin_update(WPS, i, full_update ?
1141 }
1142
1143#else
1144 wps_sync_data.do_full_update = false;
1145#endif
1146 skin_update(&gui_wps[i], full_update ?
1147 SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC); 1115 SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC);
1116 }
1148 } 1117 }
1149 } 1118 }
1150 update = false; 1119 update = false;
@@ -1183,72 +1152,54 @@ long gui_wps_show(void)
1183/* this is called from the playback thread so NO DRAWING! */ 1152/* this is called from the playback thread so NO DRAWING! */
1184static void track_changed_callback(void *param) 1153static void track_changed_callback(void *param)
1185{ 1154{
1186 wps_state.id3 = (struct mp3entry*)param; 1155 struct wps_state *state = skin_get_global_state();
1187 wps_state.nid3 = audio_next_track(); 1156 state->id3 = (struct mp3entry*)param;
1188 if (wps_state.id3->cuesheet) 1157 state->nid3 = audio_next_track();
1158 if (state->id3->cuesheet)
1189 { 1159 {
1190 cue_find_current_track(wps_state.id3->cuesheet, wps_state.id3->elapsed); 1160 cue_find_current_track(state->id3->cuesheet, state->id3->elapsed);
1191 } 1161 }
1192 wps_sync_data.do_full_update = true; 1162 skin_request_full_update(WPS);
1193} 1163}
1194static void nextid3available_callback(void* param) 1164static void nextid3available_callback(void* param)
1195{ 1165{
1196 (void)param; 1166 (void)param;
1197 wps_state.nid3 = audio_next_track(); 1167 skin_get_global_state()->nid3 = audio_next_track();
1198 wps_sync_data.do_full_update = true; 1168 skin_request_full_update(WPS);
1199} 1169}
1200 1170
1201 1171
1202static void wps_state_init(void) 1172static void wps_state_init(void)
1203{ 1173{
1204 wps_state.ff_rewind = false; 1174 struct wps_state *state = skin_get_global_state();
1205 wps_state.paused = false; 1175 state->ff_rewind = false;
1176 state->paused = false;
1206 if(audio_status() & AUDIO_STATUS_PLAY) 1177 if(audio_status() & AUDIO_STATUS_PLAY)
1207 { 1178 {
1208 wps_state.id3 = audio_current_track(); 1179 state->id3 = audio_current_track();
1209 wps_state.nid3 = audio_next_track(); 1180 state->nid3 = audio_next_track();
1210 } 1181 }
1211 else 1182 else
1212 { 1183 {
1213 wps_state.id3 = NULL; 1184 state->id3 = NULL;
1214 wps_state.nid3 = NULL; 1185 state->nid3 = NULL;
1215 } 1186 }
1216 /* We'll be updating due to restore initialized with true */ 1187 /* We'll be updating due to restore initialized with true */
1217 wps_sync_data.do_full_update = false; 1188 skin_request_full_update(WPS);
1218 /* add the WPS track event callbacks */ 1189 /* add the WPS track event callbacks */
1219 add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); 1190 add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback);
1220 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); 1191 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback);
1221} 1192}
1222 1193
1223 1194
1224void gui_sync_wps_init(void)
1225{
1226 int i;
1227 FOR_NB_SCREENS(i)
1228 {
1229#ifdef HAVE_ALBUMART
1230 wps_datas[i].albumart = NULL;
1231 wps_datas[i].playback_aa_slot = -1;
1232#endif
1233 gui_wps[i].data = &wps_datas[i];
1234 gui_wps[i].display = &screens[i];
1235 /* Currently no seperate wps_state needed/possible
1236 so use the only available ( "global" ) one */
1237 gui_wps[i].state = &wps_state;
1238 /* must point to the same struct for both screens */
1239 gui_wps[i].sync_data = &wps_sync_data;
1240 }
1241}
1242
1243
1244#ifdef IPOD_ACCESSORY_PROTOCOL 1195#ifdef IPOD_ACCESSORY_PROTOCOL
1245bool is_wps_fading(void) 1196bool is_wps_fading(void)
1246{ 1197{
1247 return wps_state.is_fading; 1198 return skin_get_global_state()->is_fading;
1248} 1199}
1249 1200
1250int wps_get_ff_rewind_count(void) 1201int wps_get_ff_rewind_count(void)
1251{ 1202{
1252 return wps_state.ff_rewind_count; 1203 return skin_get_global_state()->ff_rewind_count;
1253} 1204}
1254#endif 1205#endif