1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Jerome Kuptz
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
30 #include "backlight.h"
33 #include "filetypes.h"
37 #include "wps_engine/wps_engine.h"
38 #include "mp3_playback.h"
45 #ifdef HAVE_LCD_BITMAP
47 #include "peakmeter.h"
58 #include "ata_idle_notify.h"
59 #include "root_menu.h"
61 #include "quickscreen.h"
62 #include "pitchscreen.h"
63 #include "appevents.h"
66 #include "option_select.h"
68 #include "playlist_viewer.h"
69 #include "music_screen.h"
71 #define RESTORE_WPS_INSTANTLY 0l
72 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
74 #define DEFAULT_SKIP_TRESH 3000ul
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
];
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
);
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
93 bool wps_fading_out
= false;
94 void fade(bool fade_in
, bool updatewps
)
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;
100 wps_fading_out
= !fade_in
;
103 int fp_volume
= fp_min_vol
;
105 /* zero out the sound */
106 sound_set_volume(fp_min_vol
>> 8);
108 sleep(HZ
/10); /* let audio thread run */
111 while (fp_volume
< fp_global_vol
- fp_step
) {
112 fp_volume
+= fp_step
;
113 sound_set_volume(fp_volume
>> 8);
117 gui_wps_redraw(&gui_wps
[i
], 0, WPS_REFRESH_NON_STATIC
);
121 sound_set_volume(global_settings
.volume
);
125 int fp_volume
= fp_global_vol
;
127 while (fp_volume
> fp_min_vol
+ fp_step
) {
128 fp_volume
-= fp_step
;
129 sound_set_volume(fp_volume
>> 8);
133 gui_wps_redraw(&gui_wps
[i
], 0, WPS_REFRESH_NON_STATIC
);
138 wps_fading_out
= false;
139 #if CONFIG_CODEC != SWCODEC
141 /* let audio thread run and wait for the mas to run out of data */
142 while (!mp3_pause_done())
147 /* reset volume to what it was before the fade */
148 sound_set_volume(global_settings
.volume
);
151 bool is_wps_fading(void)
153 return wps_fading_out
;
156 bool update_onvol_change(struct gui_wps
* gwps
)
158 gui_wps_redraw(gwps
, 0, WPS_REFRESH_NON_STATIC
);
160 #ifdef HAVE_LCD_CHARCELLS
161 splashf(0, "Vol: %3d dB",
162 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
168 bool ffwd_rew(int button
)
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 */
177 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
179 if (button
== ACTION_NONE
)
181 status_set_ffmode(0);
188 case ACTION_WPS_SEEKFWD
:
190 case ACTION_WPS_SEEKBACK
:
191 if (wps_state
.ff_rewind
)
195 /* fast forwarding, calc max step relative to end */
196 max_step
= (wps_state
.id3
->length
-
197 (wps_state
.id3
->elapsed
+
199 FF_REWIND_MAX_PERCENT
/ 100;
203 /* rewinding, calc max step relative to start */
204 max_step
= (wps_state
.id3
->elapsed
+ ff_rewind_count
) *
205 FF_REWIND_MAX_PERCENT
/ 100;
208 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
213 ff_rewind_count
+= step
* direction
;
215 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
216 step
+= step
>> ff_rw_accel
;
220 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
221 wps_state
.id3
&& wps_state
.id3
->length
)
223 if (!wps_state
.paused
)
224 #if (CONFIG_CODEC == SWCODEC)
225 audio_pre_ff_rewind();
229 #if CONFIG_KEYPAD == PLAYER_PAD
231 gui_wps
[i
].display
->stop_scroll();
234 status_set_ffmode(STATUS_FASTFORWARD
);
236 status_set_ffmode(STATUS_FASTBACKWARD
);
238 wps_state
.ff_rewind
= true;
240 step
= 1000 * global_settings
.ff_rewind_min_step
;
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
;
253 if ((int)(wps_state
.id3
->elapsed
+ ff_rewind_count
) < 0)
254 ff_rewind_count
= -wps_state
.id3
->elapsed
;
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
);
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
);
270 wps_state
.ff_rewind
= false;
271 status_set_ffmode(0);
272 #if (CONFIG_CODEC != SWCODEC)
273 if (!wps_state
.paused
)
276 #ifdef HAVE_LCD_CHARCELLS
278 gui_wps_redraw(&gui_wps
[i
],0, WPS_REFRESH_ALL
);
284 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
285 status_set_ffmode(0);
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
);
304 void display_keylock_text(bool locked
)
308 gui_wps
[i
].display
->stop_scroll();
310 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
316 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
317 static void gwps_caption_backlight(struct wps_state
*state
)
319 if (state
&& state
->id3
)
321 #ifdef HAVE_BACKLIGHT
322 if (global_settings
.caption_backlight
)
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;
329 n
= 5000; /* use 5s if backlight is always on or off */
331 if (((state
->id3
->elapsed
< 1000) ||
332 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
333 (state
->paused
== false))
337 #ifdef HAVE_REMOTE_LCD
338 if (global_settings
.remote_caption_backlight
)
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,
343 int n
= global_settings
.remote_backlight_timeout
* 1000;
346 n
= 5000; /* use 5s if backlight is always on or off */
348 if (((state
->id3
->elapsed
< 1000) ||
349 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
350 (state
->paused
== false))
351 remote_backlight_on();
359 static void change_dir(int direction
)
361 if (global_settings
.prevent_skip
)
366 else if (direction
> 0)
368 /* prevent the next dir to immediatly start being ffw'd */
369 action_wait_for_release();
372 static void prev_track(unsigned long skip_thresh
)
374 if (wps_state
.id3
->elapsed
< skip_thresh
)
381 if (wps_state
.id3
->cuesheet
)
383 curr_cuesheet_skip(wps_state
.id3
->cuesheet
, -1, wps_state
.id3
->elapsed
);
387 if (!wps_state
.paused
)
388 #if (CONFIG_CODEC == SWCODEC)
389 audio_pre_ff_rewind();
396 #if (CONFIG_CODEC != SWCODEC)
397 if (!wps_state
.paused
)
403 static void next_track(void)
405 /* take care of if we're playing a cuesheet */
406 if (wps_state
.id3
->cuesheet
)
408 if (curr_cuesheet_skip(wps_state
.id3
->cuesheet
, 1, wps_state
.id3
->elapsed
))
410 /* if the result was false, then we really want
411 to skip to the next track */
419 static void play_hop(int direction
)
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
;
425 if (!global_settings
.prevent_skip
&&
427 (direction
> 0 && step
>= remaining
) ||
428 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
429 { /* Do normal track skipping */
432 else if (direction
< 0)
433 prev_track(DEFAULT_SKIP_TRESH
);
437 if (direction
== 1 && step
>= remaining
)
439 #if CONFIG_CODEC == SWCODEC
440 if(global_settings
.beep
)
441 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
445 else if ((direction
== -1 && elapsed
< step
))
451 elapsed
+= step
* direction
;
453 if((audio_status() & AUDIO_STATUS_PLAY
) && !wps_state
.paused
)
455 #if (CONFIG_CODEC == SWCODEC)
456 audio_pre_ff_rewind();
461 audio_ff_rewind(wps_state
.id3
->elapsed
= elapsed
);
462 #if (CONFIG_CODEC != SWCODEC)
463 if (!wps_state
.paused
)
468 static void gwps_fix_statusbars(void)
470 #ifdef HAVE_LCD_BITMAP
472 wpsbars
= VP_SB_HIDE_ALL
;
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
)
481 wpsbars
|= (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
484 wpsbars
= VP_SB_ALLSCREENS
;
488 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
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)
494 static void wps_lcd_activation_hook(void)
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);
502 static void gwps_leave_wps(void)
504 int i
, oldbars
= VP_SB_HIDE_ALL
;
507 gui_wps
[i
].display
->stop_scroll();
508 if (global_settings
.statusbar
)
509 oldbars
= VP_SB_ALLSCREENS
;
512 show_main_backdrop();
514 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
515 show_remote_main_backdrop();
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
);
524 void gwps_draw_statusbars(void)
526 viewportmanager_set_statusbar(wpsbars
);
528 #ifdef HAVE_TOUCHSCREEN
529 int wps_get_touchaction(struct wps_data
*data
)
533 int type
= action_get_touchscreen_press(&x
, &y
);
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
++)
541 r
= &data
->touchregion
[i
];
542 /* make sure this region's viewport is visible */
543 if (r
->wvp
->hidden_flags
&VP_DRAW_HIDDEN
)
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
)
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
)
556 /* reposition the touch within the area */
562 case WPS_TOUCHREGION_ACTION
:
563 if ((repeated
&& r
->repeat
) || (released
&& !r
->repeat
))
565 last_action
= r
->action
;
569 case WPS_TOUCHREGION_SCROLLBAR
:
570 if(r
->width
> r
->height
)
572 wps_state
.id3
->elapsed
= (vx
*
573 wps_state
.id3
->length
) / r
->width
;
576 wps_state
.id3
->elapsed
= (vy
*
577 wps_state
.id3
->length
) / r
->height
;
579 audio_ff_rewind(wps_state
.id3
->elapsed
);
581 case WPS_TOUCHREGION_VOLUME
:
583 const int min_vol
= sound_min(SOUND_VOLUME
);
584 const int max_vol
= sound_max(SOUND_VOLUME
);
585 if(r
->width
> r
->height
)
587 global_settings
.volume
= (vx
*
588 (max_vol
- min_vol
)) / r
->width
;
591 global_settings
.volume
= (vy
*
592 (max_vol
-min_vol
)) / r
->height
;
594 global_settings
.volume
+= min_vol
;
602 if ((last_action
== ACTION_WPS_SEEKBACK
|| last_action
== ACTION_WPS_SEEKFWD
))
603 return ACTION_WPS_STOPSEEK
;
604 last_action
= ACTION_TOUCHSCREEN
;
605 return ACTION_TOUCHSCREEN
;
608 /* The WPS can be left in two ways:
609 * a) call a function, which draws over the wps. In this case, the wps
610 * will be still active (i.e. the below function didn't return)
611 * b) return with a value evaluated by root_menu.c, in this case the wps
612 * is really left, and root_menu will handle the next screen
614 * In either way, call gwps_leave_wps(), in order to restore the correct
615 * "main screen" backdrops and statusbars
617 long gui_wps_show(void)
621 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
623 bool bookmark
= false;
626 long last_left
= 0, last_right
= 0;
628 #ifdef HAVE_LCD_CHARCELLS
629 status_set_audio(true);
630 status_set_param(false);
633 #ifdef AB_REPEAT_ENABLE
641 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
643 /* did someone else (i.e power thread) change audio pause mode? */
644 if (wps_state
.paused
!= audio_paused
) {
645 wps_state
.paused
= audio_paused
;
647 /* if another thread paused audio, we are probably in car mode,
648 about to shut down. lets save the settings. */
649 if (wps_state
.paused
) {
651 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
652 call_storage_idle_notifys(true);
657 #ifdef HAVE_LCD_BITMAP
658 /* when the peak meter is enabled we want to have a
659 few extra updates to make it look smooth. On the
660 other hand we don't want to waste energy if it
665 if(gui_wps
[i
].data
->peak_meter_enabled
)
670 long next_refresh
= current_tick
;
671 long next_big_refresh
= current_tick
+ HZ
/ 5;
672 button
= BUTTON_NONE
;
673 while (TIME_BEFORE(current_tick
, next_big_refresh
)) {
674 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_NOBLOCK
);
675 if (button
!= ACTION_NONE
) {
679 sleep(0); /* Sleep until end of current tick. */
681 if (TIME_AFTER(current_tick
, next_refresh
)) {
684 if(gui_wps
[i
].data
->peak_meter_enabled
)
685 gui_wps_redraw(&gui_wps
[i
], 0,
686 WPS_REFRESH_PEAK_METER
);
687 next_refresh
+= HZ
/ PEAK_METER_FPS
;
694 /* The peak meter is disabled
695 -> no additional screen updates needed */
699 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,
700 restore
? HZ
/100 : HZ
/5);
703 /* Exit if audio has stopped playing. This happens e.g. at end of
704 playlist or if using the sleep timer. */
705 if (!(audio_status() & AUDIO_STATUS_PLAY
))
707 #ifdef HAVE_TOUCHSCREEN
708 if (button
== ACTION_TOUCHSCREEN
)
709 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
711 /* The iPods/X5/M5 use a single button for the A-B mode markers,
712 defined as ACTION_WPSAB_SINGLE in their config files. */
713 #ifdef ACTION_WPSAB_SINGLE
714 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
716 static int wps_ab_state
= 0;
717 if (button
== ACTION_WPSAB_SINGLE
)
719 switch (wps_ab_state
)
721 case 0: /* set the A spot */
722 button
= ACTION_WPS_ABSETA_PREVDIR
;
724 case 1: /* set the B spot */
725 button
= ACTION_WPS_ABSETB_NEXTDIR
;
728 button
= ACTION_WPS_ABRESET
;
731 wps_ab_state
= (wps_ab_state
+1) % 3;
737 case ACTION_WPS_CONTEXT
:
740 /* if music is stopped in the context menu we want to exit the wps */
741 if (onplay(wps_state
.id3
->path
,
742 FILE_ATTR_AUDIO
, CONTEXT_WPS
) == ONPLAY_MAINMENU
749 case ACTION_WPS_BROWSE
:
750 #ifdef HAVE_LCD_CHARCELLS
751 status_set_record(false);
752 status_set_audio(false);
755 return GO_TO_PREVIOUS_BROWSER
;
759 case ACTION_WPS_PLAY
:
760 if (global_settings
.party_mode
)
762 if ( wps_state
.paused
)
764 wps_state
.paused
= false;
765 if ( global_settings
.fade_on_stop
)
772 wps_state
.paused
= true;
773 if ( global_settings
.fade_on_stop
)
778 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
779 call_storage_idle_notifys(true); /* make sure resume info is saved */
784 case ACTION_WPS_VOLUP
:
787 gui_wps
[i
].data
->button_time_volume
= current_tick
;
788 global_settings
.volume
++;
793 if(update_onvol_change(&gui_wps
[i
]))
798 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
802 case ACTION_WPS_VOLDOWN
:
805 gui_wps
[i
].data
->button_time_volume
= current_tick
;
806 global_settings
.volume
--;
811 if(update_onvol_change(&gui_wps
[i
]))
816 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
821 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
822 case ACTION_WPS_SEEKFWD
:
823 if (global_settings
.party_mode
)
825 if (current_tick
-last_right
< HZ
)
827 if (wps_state
.id3
->cuesheet
)
837 ffwd_rew(ACTION_WPS_SEEKFWD
);
838 last_right
= last_left
= 0;
841 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
842 case ACTION_WPS_SEEKBACK
:
843 if (global_settings
.party_mode
)
845 if (current_tick
-last_left
< HZ
)
847 if (wps_state
.id3
->cuesheet
)
849 if (!wps_state
.paused
)
850 #if (CONFIG_CODEC == SWCODEC)
851 audio_pre_ff_rewind();
863 ffwd_rew(ACTION_WPS_SEEKBACK
);
864 last_left
= last_right
= 0;
868 case ACTION_WPS_SKIPPREV
:
869 if (global_settings
.party_mode
)
871 last_left
= current_tick
;
872 #ifdef AB_REPEAT_ENABLE
873 /* if we're in A/B repeat mode and the current position
874 is past the A marker, jump back to the A marker... */
875 if ( ab_repeat_mode_enabled() )
877 if ( ab_after_A_marker(wps_state
.id3
->elapsed
) )
879 ab_jump_to_A_marker();
881 #if (AB_REPEAT_ENABLE == 2)
888 /* ...otherwise, do it normally */
894 OR if skip length set, hop by predetermined amount. */
895 case ACTION_WPS_SKIPNEXT
:
896 if (global_settings
.party_mode
)
898 last_right
= current_tick
;
899 #ifdef AB_REPEAT_ENABLE
900 /* if we're in A/B repeat mode and the current position is
901 before the A marker, jump to the A marker... */
902 if ( ab_repeat_mode_enabled() )
904 if ( ab_before_A_marker(wps_state
.id3
->elapsed
) )
906 ab_jump_to_A_marker();
908 #if (AB_REPEAT_ENABLE == 2)
915 /* ...otherwise, do it normally */
919 /* next / prev directories */
920 /* and set A-B markers if in a-b mode */
921 case ACTION_WPS_ABSETB_NEXTDIR
:
922 if (global_settings
.party_mode
)
924 #if defined(AB_REPEAT_ENABLE)
925 if (ab_repeat_mode_enabled())
927 ab_set_B_marker(wps_state
.id3
->elapsed
);
928 ab_jump_to_A_marker();
936 case ACTION_WPS_ABSETA_PREVDIR
:
937 if (global_settings
.party_mode
)
939 #if defined(AB_REPEAT_ENABLE)
940 if (ab_repeat_mode_enabled())
941 ab_set_A_marker(wps_state
.id3
->elapsed
);
948 /* menu key functions */
949 case ACTION_WPS_MENU
:
955 #ifdef HAVE_QUICKSCREEN
956 case ACTION_WPS_QUICKSCREEN
:
959 if (quick_screen_quick(button
))
960 return SYS_USB_CONNECTED
;
964 #endif /* HAVE_QUICKSCREEN */
966 /* screen settings */
971 if (quick_screen_f3(BUTTON_F3
))
972 return SYS_USB_CONNECTED
;
976 #endif /* BUTTON_F3 */
979 #ifdef HAVE_PITCHSCREEN
980 case ACTION_WPS_PITCHSCREEN
:
983 if (1 == gui_syncpitchscreen_run())
984 return SYS_USB_CONNECTED
;
988 #endif /* HAVE_PITCHSCREEN */
990 #ifdef AB_REPEAT_ENABLE
991 /* reset A&B markers */
992 case ACTION_WPS_ABRESET
:
993 if (ab_repeat_mode_enabled())
999 #endif /* AB_REPEAT_ENABLE */
1001 /* stop and exit wps */
1002 case ACTION_WPS_STOP
:
1003 if (global_settings
.party_mode
)
1009 case ACTION_WPS_ID3SCREEN
:
1016 #ifdef HAVE_TOUCHSCREEN
1017 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
1019 global_settings
.playlist_shuffle
=
1020 !global_settings
.playlist_shuffle
;
1021 #if CONFIG_CODEC == SWCODEC
1022 dsp_set_replaygain();
1024 if (global_settings
.playlist_shuffle
)
1025 playlist_randomise(NULL
, current_tick
, true);
1027 playlist_sort(NULL
, true);
1030 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1032 const struct settings_list
*rep_setting
=
1033 find_setting(&global_settings
.repeat_mode
, NULL
);
1034 option_select_next_val(rep_setting
, false, true);
1035 audio_flush_and_reload_tracks();
1038 #endif /* HAVE_TOUCHSCREEN */
1039 /* this case is used by the softlock feature
1040 * it requests a full update here */
1042 wps_state
.do_full_update
= true;
1044 case ACTION_NONE
: /* Timeout, do a partial update */
1046 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1048 #ifdef HAVE_RECORDING
1049 case ACTION_WPS_REC
:
1054 default_event_handler(SYS_POWEROFF
);
1056 case ACTION_WPS_VIEW_PLAYLIST
:
1058 if (playlist_viewer()) /* true if USB connected */
1059 return SYS_USB_CONNECTED
;
1063 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
1069 if (wps_state
.do_full_update
|| update
)
1071 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1072 gwps_caption_backlight(&wps_state
);
1076 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1078 #ifdef HAVE_REMOTE_LCD
1079 /* currently, all remotes are readable without backlight
1080 * so still update those */
1081 || (i
== SCREEN_REMOTE
)
1086 gui_wps_update(&gui_wps
[i
]);
1089 wps_state
.do_full_update
= false;
1093 if (restore
&& wps_state
.id3
&&
1094 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1095 TIME_AFTER(current_tick
, restoretimer
)))
1098 restoretimer
= RESTORE_WPS_INSTANTLY
;
1099 gwps_fix_statusbars();
1100 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1101 lcd_activation_set_hook(wps_lcd_activation_hook
);
1105 screens
[i
].stop_scroll();
1106 gui_wps_display(&gui_wps
[i
]);
1111 #ifdef HAVE_LCD_CHARCELLS
1112 status_set_record(false);
1113 status_set_audio(false);
1115 if (global_settings
.fade_on_stop
)
1119 bookmark_autobookmark();
1121 #ifdef AB_REPEAT_ENABLE
1125 #ifdef HAVE_RECORDING
1126 if (button
== ACTION_WPS_REC
)
1127 return GO_TO_RECSCREEN
;
1129 if (global_settings
.browse_current
)
1130 return GO_TO_PREVIOUS_BROWSER
;
1131 return GO_TO_PREVIOUS
;
1134 if (button
&& !IS_SYSEVENT(button
) )
1137 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1140 /* this is called from the playback thread so NO DRAWING! */
1141 static void track_changed_callback(void *param
)
1143 wps_state
.id3
= (struct mp3entry
*)param
;
1144 wps_state
.nid3
= audio_next_track();
1145 if (wps_state
.id3
->cuesheet
)
1147 cue_find_current_track(wps_state
.id3
->cuesheet
, wps_state
.id3
->elapsed
);
1148 cue_spoof_id3(wps_state
.id3
->cuesheet
, wps_state
.id3
);
1150 wps_state
.do_full_update
= true;
1152 static void nextid3available_callback(void* param
)
1155 wps_state
.nid3
= audio_next_track();
1156 wps_state
.do_full_update
= true;
1160 static void wps_state_init(void)
1162 wps_state
.ff_rewind
= false;
1163 wps_state
.paused
= false;
1164 if(audio_status() & AUDIO_STATUS_PLAY
)
1166 wps_state
.id3
= audio_current_track();
1167 wps_state
.nid3
= audio_next_track();
1171 wps_state
.id3
= NULL
;
1172 wps_state
.nid3
= NULL
;
1174 /* We'll be updating due to restore initialized with true */
1175 wps_state
.do_full_update
= false;
1176 /* add the WPS track event callbacks */
1177 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1178 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1182 #ifdef HAVE_LCD_BITMAP
1183 static void statusbar_toggle_handler(void *data
)
1187 gwps_fix_statusbars();
1191 struct viewport
*vp
= &gui_wps
[i
].data
->viewports
[0].vp
;
1192 bool draw
= wpsbars
& (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
1196 vp
->height
= screens
[i
].lcdheight
;
1200 bool bar_at_top
= statusbar_position(i
) != STATUSBAR_BOTTOM
;
1201 vp
->y
= bar_at_top
?STATUSBAR_HEIGHT
:0;
1202 vp
->height
= screens
[i
].lcdheight
- STATUSBAR_HEIGHT
;
1208 void gui_sync_wps_init(void)
1213 wps_data_init(&wps_datas
[i
]);
1214 #ifdef HAVE_ALBUMART
1215 wps_datas
[i
].wps_uses_albumart
= 0;
1217 #ifdef HAVE_REMOTE_LCD
1218 wps_datas
[i
].remote_wps
= (i
!= 0);
1220 gui_wps
[i
].data
= &wps_datas
[i
];
1221 gui_wps
[i
].display
= &screens
[i
];
1222 /* Currently no seperate wps_state needed/possible
1223 so use the only available ( "global" ) one */
1224 gui_wps
[i
].state
= &wps_state
;
1226 #ifdef HAVE_LCD_BITMAP
1227 add_event(GUI_EVENT_STATUSBAR_TOGGLE
, false, statusbar_toggle_handler
);
1230 unload_wps_backdrop();
1232 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
1233 unload_remote_wps_backdrop();
1237 #ifdef HAVE_ALBUMART
1238 /* Returns true if at least one of the gui_wps screens has an album art
1239 tag in its wps structure */
1240 bool gui_sync_wps_uses_albumart(void)
1244 struct gui_wps
*gwps
= &gui_wps
[i
];
1245 if (gwps
->data
&& (gwps
->data
->wps_uses_albumart
!= WPS_ALBUMART_NONE
))