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 "skin_engine/skin_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"
71 #define RESTORE_WPS_INSTANTLY 0l
72 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
74 #define DEFAULT_SKIP_TRESH 3000ul
77 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
78 /* 3% of 30min file == 54s step size */
79 #define MIN_FF_REWIND_STEP 500
82 /* currently only one wps_state is needed */
83 static struct wps_state wps_state
;
84 static struct gui_wps gui_wps
[NB_SCREENS
];
85 static struct wps_data wps_datas
[NB_SCREENS
];
87 /* initial setup of wps_data */
88 static void wps_state_init(void);
89 static void track_changed_callback(void *param
);
90 static void nextid3available_callback(void* param
);
93 void wps_data_load(enum screen_type screen
, const char *buf
, bool isfile
)
97 screens
[screen
].backdrop_unload(BACKDROP_SKIN_WPS
);
99 loaded_ok
= buf
&& skin_data_load(gui_wps
[screen
].data
,
100 &screens
[screen
], buf
, isfile
);
101 if (!loaded_ok
) /* load the hardcoded default */
103 char *skin_buf
[NB_SCREENS
] = {
104 #ifdef HAVE_LCD_BITMAP
105 "%s%?it<%?in<%in. |>%it|%fn>\n"
106 "%s%?ia<%ia|%?d2<%d2|(root)>>\n"
107 "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n\n"
108 "%al%pc/%pt%ar[%pp:%pe]\n"
109 "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
112 "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n"
115 #ifdef HAVE_REMOTE_LCD
116 "%s%?ia<%ia|%?d2<%d2|(root)>>\n"
117 "%s%?it<%?in<%in. |>%it|%fn>\n"
118 "%al%pc/%pt%ar[%pp:%pe]\n"
119 "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
123 skin_data_load(gui_wps
[screen
].data
, &screens
[screen
],
124 skin_buf
[screen
], false);
126 #ifdef HAVE_REMOVE_LCD
127 gui_wps
[screen
].data
->remote_wps
= !(screen
== SCREEN_MAIN
);
131 void wps_data_init(enum screen_type screen
)
133 skin_data_init(gui_wps
[screen
].data
);
137 static bool wps_fading_out
= false;
138 void fade(bool fade_in
, bool updatewps
)
140 int fp_global_vol
= global_settings
.volume
<< 8;
141 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
142 int fp_step
= (fp_global_vol
- fp_min_vol
) / 30;
144 wps_fading_out
= !fade_in
;
147 int fp_volume
= fp_min_vol
;
149 /* zero out the sound */
150 sound_set_volume(fp_min_vol
>> 8);
152 sleep(HZ
/10); /* let audio thread run */
155 while (fp_volume
< fp_global_vol
- fp_step
) {
156 fp_volume
+= fp_step
;
157 sound_set_volume(fp_volume
>> 8);
161 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
165 sound_set_volume(global_settings
.volume
);
169 int fp_volume
= fp_global_vol
;
171 while (fp_volume
> fp_min_vol
+ fp_step
) {
172 fp_volume
-= fp_step
;
173 sound_set_volume(fp_volume
>> 8);
177 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
182 wps_fading_out
= false;
183 #if CONFIG_CODEC != SWCODEC
185 /* let audio thread run and wait for the mas to run out of data */
186 while (!mp3_pause_done())
191 /* reset volume to what it was before the fade */
192 sound_set_volume(global_settings
.volume
);
195 bool is_wps_fading(void)
197 return wps_fading_out
;
200 static bool update_onvol_change(struct gui_wps
* gwps
)
202 skin_update(gwps
, WPS_REFRESH_NON_STATIC
);
204 #ifdef HAVE_LCD_CHARCELLS
205 splashf(0, "Vol: %3d dB",
206 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
213 bool ffwd_rew(int button
)
215 unsigned int step
= 0; /* current ff/rewind step */
216 unsigned int max_step
= 0; /* maximum ff/rewind step */
217 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
218 int direction
= -1; /* forward=1 or backward=-1 */
222 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
224 if (button
== ACTION_NONE
)
226 status_set_ffmode(0);
233 case ACTION_WPS_SEEKFWD
:
235 case ACTION_WPS_SEEKBACK
:
236 if (wps_state
.ff_rewind
)
240 /* fast forwarding, calc max step relative to end */
241 max_step
= (wps_state
.id3
->length
-
242 (wps_state
.id3
->elapsed
+
244 FF_REWIND_MAX_PERCENT
/ 100;
248 /* rewinding, calc max step relative to start */
249 max_step
= (wps_state
.id3
->elapsed
+ ff_rewind_count
) *
250 FF_REWIND_MAX_PERCENT
/ 100;
253 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
258 ff_rewind_count
+= step
* direction
;
260 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
261 step
+= step
>> ff_rw_accel
;
265 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
266 wps_state
.id3
&& wps_state
.id3
->length
)
268 if (!wps_state
.paused
)
269 #if (CONFIG_CODEC == SWCODEC)
270 audio_pre_ff_rewind();
274 #if CONFIG_KEYPAD == PLAYER_PAD
276 gui_wps
[i
].display
->stop_scroll();
279 status_set_ffmode(STATUS_FASTFORWARD
);
281 status_set_ffmode(STATUS_FASTBACKWARD
);
283 wps_state
.ff_rewind
= true;
285 step
= 1000 * global_settings
.ff_rewind_min_step
;
292 if ((wps_state
.id3
->elapsed
+ ff_rewind_count
) >
293 wps_state
.id3
->length
)
294 ff_rewind_count
= wps_state
.id3
->length
-
295 wps_state
.id3
->elapsed
;
298 if ((int)(wps_state
.id3
->elapsed
+ ff_rewind_count
) < 0)
299 ff_rewind_count
= -wps_state
.id3
->elapsed
;
302 /* set the wps state ff_rewind_count so the progess info
304 wps_state
.ff_rewind_count
= (wps_state
.wps_time_countup
== false)?
305 ff_rewind_count
:-ff_rewind_count
;
308 skin_update(&gui_wps
[i
],
309 WPS_REFRESH_PLAYER_PROGRESS
|
310 WPS_REFRESH_DYNAMIC
);
315 case ACTION_WPS_STOPSEEK
:
316 wps_state
.id3
->elapsed
= wps_state
.id3
->elapsed
+ff_rewind_count
;
317 audio_ff_rewind(wps_state
.id3
->elapsed
);
318 wps_state
.ff_rewind_count
= 0;
319 wps_state
.ff_rewind
= false;
320 status_set_ffmode(0);
321 #if (CONFIG_CODEC != SWCODEC)
322 if (!wps_state
.paused
)
325 #ifdef HAVE_LCD_CHARCELLS
327 skin_update(&gui_wps
[i
], WPS_REFRESH_ALL
);
333 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
334 status_set_ffmode(0);
342 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
343 #ifdef HAVE_TOUCHSCREEN
344 if (button
== ACTION_TOUCHSCREEN
)
345 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
353 void display_keylock_text(bool locked
)
357 gui_wps
[i
].display
->stop_scroll();
359 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
365 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
366 static void gwps_caption_backlight(struct wps_state
*state
)
368 if (state
&& state
->id3
)
370 #ifdef HAVE_BACKLIGHT
371 if (global_settings
.caption_backlight
)
373 /* turn on backlight n seconds before track ends, and turn it off n
374 seconds into the new track. n == backlight_timeout, or 5s */
375 int n
= global_settings
.backlight_timeout
* 1000;
378 n
= 5000; /* use 5s if backlight is always on or off */
380 if (((state
->id3
->elapsed
< 1000) ||
381 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
382 (state
->paused
== false))
386 #ifdef HAVE_REMOTE_LCD
387 if (global_settings
.remote_caption_backlight
)
389 /* turn on remote backlight n seconds before track ends, and turn it
390 off n seconds into the new track. n == remote_backlight_timeout,
392 int n
= global_settings
.remote_backlight_timeout
* 1000;
395 n
= 5000; /* use 5s if backlight is always on or off */
397 if (((state
->id3
->elapsed
< 1000) ||
398 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
399 (state
->paused
== false))
400 remote_backlight_on();
408 static void change_dir(int direction
)
410 if (global_settings
.prevent_skip
)
415 else if (direction
> 0)
417 /* prevent the next dir to immediatly start being ffw'd */
418 action_wait_for_release();
421 static void prev_track(unsigned long skip_thresh
)
423 if (wps_state
.id3
->elapsed
< skip_thresh
)
430 if (wps_state
.id3
->cuesheet
)
432 curr_cuesheet_skip(wps_state
.id3
->cuesheet
, -1, wps_state
.id3
->elapsed
);
436 if (!wps_state
.paused
)
437 #if (CONFIG_CODEC == SWCODEC)
438 audio_pre_ff_rewind();
445 #if (CONFIG_CODEC != SWCODEC)
446 if (!wps_state
.paused
)
452 static void next_track(void)
454 /* take care of if we're playing a cuesheet */
455 if (wps_state
.id3
->cuesheet
)
457 if (curr_cuesheet_skip(wps_state
.id3
->cuesheet
, 1, wps_state
.id3
->elapsed
))
459 /* if the result was false, then we really want
460 to skip to the next track */
468 static void play_hop(int direction
)
470 unsigned long step
= ((unsigned long)global_settings
.skip_length
)*1000;
471 unsigned long elapsed
= wps_state
.id3
->elapsed
;
472 unsigned long remaining
= wps_state
.id3
->length
- elapsed
;
474 if (!global_settings
.prevent_skip
&&
476 (direction
> 0 && step
>= remaining
) ||
477 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
478 { /* Do normal track skipping */
481 else if (direction
< 0)
482 prev_track(DEFAULT_SKIP_TRESH
);
486 if (direction
== 1 && step
>= remaining
)
488 #if CONFIG_CODEC == SWCODEC
489 if(global_settings
.beep
)
490 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
494 else if ((direction
== -1 && elapsed
< step
))
500 elapsed
+= step
* direction
;
502 if((audio_status() & AUDIO_STATUS_PLAY
) && !wps_state
.paused
)
504 #if (CONFIG_CODEC == SWCODEC)
505 audio_pre_ff_rewind();
510 audio_ff_rewind(wps_state
.id3
->elapsed
= elapsed
);
511 #if (CONFIG_CODEC != SWCODEC)
512 if (!wps_state
.paused
)
517 static void gwps_fix_statusbars(void)
519 #ifdef HAVE_LCD_BITMAP
521 wpsbars
= VP_SB_HIDE_ALL
;
525 if (gui_wps
[i
].data
->wps_sb_tag
)
526 draw
= gui_wps
[i
].data
->show_sb_on_wps
;
527 else if (statusbar_position(i
) != STATUSBAR_OFF
)
530 wpsbars
|= (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
533 wpsbars
= VP_SB_ALLSCREENS
;
537 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
539 * If the user is unable to see the wps, because the display is deactivated,
540 * we suppress updates until the wps is activated again (the lcd driver will
541 * call this hook to issue an instant update)
543 static void wps_lcd_activation_hook(void)
545 wps_state
.do_full_update
= true;
546 /* force timeout in wps main loop, so that the update is instantly */
547 queue_post(&button_queue
, BUTTON_NONE
, 0);
551 static void gwps_leave_wps(void)
553 int i
, oldbars
= VP_SB_HIDE_ALL
;
557 gui_wps
[i
].display
->stop_scroll();
558 gui_wps
[i
].display
->backdrop_show(BACKDROP_MAIN
);
560 if (global_settings
.statusbar
)
561 oldbars
= VP_SB_ALLSCREENS
;
563 viewportmanager_set_statusbar(oldbars
);
564 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
565 /* Play safe and unregister the hook */
566 lcd_activation_set_hook(NULL
);
568 send_event(GUI_EVENT_REFRESH
, NULL
);
571 void gwps_draw_statusbars(void)
573 viewportmanager_set_statusbar(wpsbars
);
575 #ifdef HAVE_TOUCHSCREEN
576 int wps_get_touchaction(struct wps_data
*data
)
580 int type
= action_get_touchscreen_press(&x
, &y
);
581 static int last_action
= ACTION_NONE
;
582 struct touchregion
*r
;
583 bool repeated
= (type
== BUTTON_REPEAT
);
584 bool released
= (type
== BUTTON_REL
);
585 struct skin_token_list
*regions
= data
->touchregions
;
588 r
= (struct touchregion
*)regions
->token
->value
.data
;
589 /* make sure this region's viewport is visible */
590 if (r
->wvp
->hidden_flags
&VP_DRAW_HIDDEN
)
592 regions
= regions
->next
;
595 /* reposition the touch inside the viewport */
596 vx
= x
- r
->wvp
->vp
.x
;
597 vy
= y
- r
->wvp
->vp
.y
;
598 /* check if it's inside this viewport */
599 if (vx
>= 0 && vx
< r
->wvp
->vp
.x
+ r
->wvp
->vp
.width
&&
600 vy
>= 0 && vy
< r
->wvp
->vp
.y
+ r
->wvp
->vp
.height
)
602 /* now see if the point is inside this region */
603 if (vx
>= r
->x
&& vx
< r
->x
+r
->width
&&
604 vy
>= r
->y
&& vy
< r
->y
+r
->height
)
606 /* reposition the touch within the area */
612 case WPS_TOUCHREGION_ACTION
:
613 if ((repeated
&& r
->repeat
) || (released
&& !r
->repeat
))
615 last_action
= r
->action
;
619 case WPS_TOUCHREGION_SCROLLBAR
:
620 if(r
->width
> r
->height
)
622 wps_state
.id3
->elapsed
= (vx
*
623 wps_state
.id3
->length
) / r
->width
;
626 wps_state
.id3
->elapsed
= (vy
*
627 wps_state
.id3
->length
) / r
->height
;
629 audio_ff_rewind(wps_state
.id3
->elapsed
);
631 case WPS_TOUCHREGION_VOLUME
:
633 const int min_vol
= sound_min(SOUND_VOLUME
);
634 const int max_vol
= sound_max(SOUND_VOLUME
);
635 if(r
->width
> r
->height
)
637 global_settings
.volume
= (vx
*
638 (max_vol
- min_vol
)) / r
->width
;
641 global_settings
.volume
= (vy
*
642 (max_vol
-min_vol
)) / r
->height
;
644 global_settings
.volume
+= min_vol
;
651 regions
= regions
->next
;
654 if ((last_action
== ACTION_WPS_SEEKBACK
|| last_action
== ACTION_WPS_SEEKFWD
))
655 return ACTION_WPS_STOPSEEK
;
656 last_action
= ACTION_TOUCHSCREEN
;
657 return ACTION_TOUCHSCREEN
;
660 /* The WPS can be left in two ways:
661 * a) call a function, which draws over the wps. In this case, the wps
662 * will be still active (i.e. the below function didn't return)
663 * b) return with a value evaluated by root_menu.c, in this case the wps
664 * is really left, and root_menu will handle the next screen
666 * In either way, call gwps_leave_wps(), in order to restore the correct
667 * "main screen" backdrops and statusbars
669 long gui_wps_show(void)
673 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
675 bool bookmark
= false;
678 long last_left
= 0, last_right
= 0;
680 #ifdef HAVE_LCD_CHARCELLS
681 status_set_audio(true);
682 status_set_param(false);
685 #ifdef AB_REPEAT_ENABLE
693 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
695 /* did someone else (i.e power thread) change audio pause mode? */
696 if (wps_state
.paused
!= audio_paused
) {
697 wps_state
.paused
= audio_paused
;
699 /* if another thread paused audio, we are probably in car mode,
700 about to shut down. lets save the settings. */
701 if (wps_state
.paused
) {
703 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
704 call_storage_idle_notifys(true);
709 #ifdef HAVE_LCD_BITMAP
710 /* when the peak meter is enabled we want to have a
711 few extra updates to make it look smooth. On the
712 other hand we don't want to waste energy if it
717 if(gui_wps
[i
].data
->peak_meter_enabled
)
722 long next_refresh
= current_tick
;
723 long next_big_refresh
= current_tick
+ HZ
/ 5;
724 button
= BUTTON_NONE
;
725 while (TIME_BEFORE(current_tick
, next_big_refresh
)) {
726 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_NOBLOCK
);
727 if (button
!= ACTION_NONE
) {
731 sleep(0); /* Sleep until end of current tick. */
733 if (TIME_AFTER(current_tick
, next_refresh
)) {
736 if(gui_wps
[i
].data
->peak_meter_enabled
)
737 skin_update(&gui_wps
[i
], WPS_REFRESH_PEAK_METER
);
738 next_refresh
+= HZ
/ PEAK_METER_FPS
;
745 /* The peak meter is disabled
746 -> no additional screen updates needed */
750 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,
751 restore
? HZ
/100 : HZ
/5);
754 /* Exit if audio has stopped playing. This happens e.g. at end of
755 playlist or if using the sleep timer. */
756 if (!(audio_status() & AUDIO_STATUS_PLAY
))
758 #ifdef HAVE_TOUCHSCREEN
759 if (button
== ACTION_TOUCHSCREEN
)
760 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
762 /* The iPods/X5/M5 use a single button for the A-B mode markers,
763 defined as ACTION_WPSAB_SINGLE in their config files. */
764 #ifdef ACTION_WPSAB_SINGLE
765 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
767 static int wps_ab_state
= 0;
768 if (button
== ACTION_WPSAB_SINGLE
)
770 switch (wps_ab_state
)
772 case 0: /* set the A spot */
773 button
= ACTION_WPS_ABSETA_PREVDIR
;
775 case 1: /* set the B spot */
776 button
= ACTION_WPS_ABSETB_NEXTDIR
;
779 button
= ACTION_WPS_ABRESET
;
782 wps_ab_state
= (wps_ab_state
+1) % 3;
788 case ACTION_WPS_CONTEXT
:
791 /* if music is stopped in the context menu we want to exit the wps */
792 if (onplay(wps_state
.id3
->path
,
793 FILE_ATTR_AUDIO
, CONTEXT_WPS
) == ONPLAY_MAINMENU
800 case ACTION_WPS_BROWSE
:
801 #ifdef HAVE_LCD_CHARCELLS
802 status_set_record(false);
803 status_set_audio(false);
806 return GO_TO_PREVIOUS_BROWSER
;
810 case ACTION_WPS_PLAY
:
811 if (global_settings
.party_mode
)
813 if ( wps_state
.paused
)
815 wps_state
.paused
= false;
816 if ( global_settings
.fade_on_stop
)
823 wps_state
.paused
= true;
824 if ( global_settings
.fade_on_stop
)
829 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
830 call_storage_idle_notifys(true); /* make sure resume info is saved */
835 case ACTION_WPS_VOLUP
:
838 gui_wps
[i
].data
->button_time_volume
= current_tick
;
839 global_settings
.volume
++;
844 if(update_onvol_change(&gui_wps
[i
]))
849 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
853 case ACTION_WPS_VOLDOWN
:
856 gui_wps
[i
].data
->button_time_volume
= current_tick
;
857 global_settings
.volume
--;
862 if(update_onvol_change(&gui_wps
[i
]))
867 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
872 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
873 case ACTION_WPS_SEEKFWD
:
874 if (global_settings
.party_mode
)
876 if (current_tick
-last_right
< HZ
)
878 if (wps_state
.id3
->cuesheet
)
888 ffwd_rew(ACTION_WPS_SEEKFWD
);
889 last_right
= last_left
= 0;
892 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
893 case ACTION_WPS_SEEKBACK
:
894 if (global_settings
.party_mode
)
896 if (current_tick
-last_left
< HZ
)
898 if (wps_state
.id3
->cuesheet
)
900 if (!wps_state
.paused
)
901 #if (CONFIG_CODEC == SWCODEC)
902 audio_pre_ff_rewind();
914 ffwd_rew(ACTION_WPS_SEEKBACK
);
915 last_left
= last_right
= 0;
919 case ACTION_WPS_SKIPPREV
:
920 if (global_settings
.party_mode
)
922 last_left
= current_tick
;
923 #ifdef AB_REPEAT_ENABLE
924 /* if we're in A/B repeat mode and the current position
925 is past the A marker, jump back to the A marker... */
926 if ( ab_repeat_mode_enabled() )
928 if ( ab_after_A_marker(wps_state
.id3
->elapsed
) )
930 ab_jump_to_A_marker();
932 #if (AB_REPEAT_ENABLE == 2)
939 /* ...otherwise, do it normally */
945 OR if skip length set, hop by predetermined amount. */
946 case ACTION_WPS_SKIPNEXT
:
947 if (global_settings
.party_mode
)
949 last_right
= current_tick
;
950 #ifdef AB_REPEAT_ENABLE
951 /* if we're in A/B repeat mode and the current position is
952 before the A marker, jump to the A marker... */
953 if ( ab_repeat_mode_enabled() )
955 if ( ab_before_A_marker(wps_state
.id3
->elapsed
) )
957 ab_jump_to_A_marker();
959 #if (AB_REPEAT_ENABLE == 2)
966 /* ...otherwise, do it normally */
970 /* next / prev directories */
971 /* and set A-B markers if in a-b mode */
972 case ACTION_WPS_ABSETB_NEXTDIR
:
973 if (global_settings
.party_mode
)
975 #if defined(AB_REPEAT_ENABLE)
976 if (ab_repeat_mode_enabled())
978 ab_set_B_marker(wps_state
.id3
->elapsed
);
979 ab_jump_to_A_marker();
987 case ACTION_WPS_ABSETA_PREVDIR
:
988 if (global_settings
.party_mode
)
990 #if defined(AB_REPEAT_ENABLE)
991 if (ab_repeat_mode_enabled())
992 ab_set_A_marker(wps_state
.id3
->elapsed
);
999 /* menu key functions */
1000 case ACTION_WPS_MENU
:
1006 #ifdef HAVE_QUICKSCREEN
1007 case ACTION_WPS_QUICKSCREEN
:
1010 if (quick_screen_quick(button
))
1011 return SYS_USB_CONNECTED
;
1015 #endif /* HAVE_QUICKSCREEN */
1017 /* screen settings */
1022 if (quick_screen_f3(BUTTON_F3
))
1023 return SYS_USB_CONNECTED
;
1027 #endif /* BUTTON_F3 */
1030 #ifdef HAVE_PITCHSCREEN
1031 case ACTION_WPS_PITCHSCREEN
:
1034 if (1 == gui_syncpitchscreen_run())
1035 return SYS_USB_CONNECTED
;
1039 #endif /* HAVE_PITCHSCREEN */
1041 #ifdef AB_REPEAT_ENABLE
1042 /* reset A&B markers */
1043 case ACTION_WPS_ABRESET
:
1044 if (ab_repeat_mode_enabled())
1050 #endif /* AB_REPEAT_ENABLE */
1052 /* stop and exit wps */
1053 case ACTION_WPS_STOP
:
1054 if (global_settings
.party_mode
)
1060 case ACTION_WPS_ID3SCREEN
:
1067 #ifdef HAVE_TOUCHSCREEN
1068 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
1070 global_settings
.playlist_shuffle
=
1071 !global_settings
.playlist_shuffle
;
1072 #if CONFIG_CODEC == SWCODEC
1073 dsp_set_replaygain();
1075 if (global_settings
.playlist_shuffle
)
1076 playlist_randomise(NULL
, current_tick
, true);
1078 playlist_sort(NULL
, true);
1081 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1083 const struct settings_list
*rep_setting
=
1084 find_setting(&global_settings
.repeat_mode
, NULL
);
1085 option_select_next_val(rep_setting
, false, true);
1086 audio_flush_and_reload_tracks();
1089 #endif /* HAVE_TOUCHSCREEN */
1090 /* this case is used by the softlock feature
1091 * it requests a full update here */
1093 wps_state
.do_full_update
= true;
1095 case ACTION_NONE
: /* Timeout, do a partial update */
1097 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1099 #ifdef HAVE_RECORDING
1100 case ACTION_WPS_REC
:
1105 default_event_handler(SYS_POWEROFF
);
1107 case ACTION_WPS_VIEW_PLAYLIST
:
1109 if (playlist_viewer()) /* true if USB connected */
1110 return SYS_USB_CONNECTED
;
1114 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
1120 if (wps_state
.do_full_update
|| update
)
1122 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1123 gwps_caption_backlight(&wps_state
);
1127 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1129 #ifdef HAVE_REMOTE_LCD
1130 /* currently, all remotes are readable without backlight
1131 * so still update those */
1132 || (i
== SCREEN_REMOTE
)
1137 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
1140 wps_state
.do_full_update
= false;
1144 if (restore
&& wps_state
.id3
&&
1145 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1146 TIME_AFTER(current_tick
, restoretimer
)))
1149 restoretimer
= RESTORE_WPS_INSTANTLY
;
1150 gwps_fix_statusbars();
1151 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1152 lcd_activation_set_hook(wps_lcd_activation_hook
);
1156 screens
[i
].stop_scroll();
1157 gui_wps_display(&gui_wps
[i
]);
1162 #ifdef HAVE_LCD_CHARCELLS
1163 status_set_record(false);
1164 status_set_audio(false);
1166 if (global_settings
.fade_on_stop
)
1170 bookmark_autobookmark();
1172 #ifdef AB_REPEAT_ENABLE
1176 #ifdef HAVE_RECORDING
1177 if (button
== ACTION_WPS_REC
)
1178 return GO_TO_RECSCREEN
;
1180 if (global_settings
.browse_current
)
1181 return GO_TO_PREVIOUS_BROWSER
;
1182 return GO_TO_PREVIOUS
;
1185 if (button
&& !IS_SYSEVENT(button
) )
1188 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1191 /* this is called from the playback thread so NO DRAWING! */
1192 static void track_changed_callback(void *param
)
1194 wps_state
.id3
= (struct mp3entry
*)param
;
1195 wps_state
.nid3
= audio_next_track();
1196 if (wps_state
.id3
->cuesheet
)
1198 cue_find_current_track(wps_state
.id3
->cuesheet
, wps_state
.id3
->elapsed
);
1199 cue_spoof_id3(wps_state
.id3
->cuesheet
, wps_state
.id3
);
1201 wps_state
.do_full_update
= true;
1203 static void nextid3available_callback(void* param
)
1206 wps_state
.nid3
= audio_next_track();
1207 wps_state
.do_full_update
= true;
1211 static void wps_state_init(void)
1213 wps_state
.ff_rewind
= false;
1214 wps_state
.paused
= false;
1215 if(audio_status() & AUDIO_STATUS_PLAY
)
1217 wps_state
.id3
= audio_current_track();
1218 wps_state
.nid3
= audio_next_track();
1222 wps_state
.id3
= NULL
;
1223 wps_state
.nid3
= NULL
;
1225 /* We'll be updating due to restore initialized with true */
1226 wps_state
.do_full_update
= false;
1227 /* add the WPS track event callbacks */
1228 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1229 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1233 #ifdef HAVE_LCD_BITMAP
1234 static void statusbar_toggle_handler(void *data
)
1238 gwps_fix_statusbars();
1242 struct viewport
*vp
= &gui_wps
[i
].data
->viewports
[0].vp
;
1243 bool draw
= wpsbars
& (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
1247 vp
->height
= screens
[i
].lcdheight
;
1251 bool bar_at_top
= statusbar_position(i
) != STATUSBAR_BOTTOM
;
1252 vp
->y
= bar_at_top
?STATUSBAR_HEIGHT
:0;
1253 vp
->height
= screens
[i
].lcdheight
- STATUSBAR_HEIGHT
;
1259 void gui_sync_wps_init(void)
1264 skin_data_init(&wps_datas
[i
]);
1265 #ifdef HAVE_ALBUMART
1266 wps_datas
[i
].wps_uses_albumart
= 0;
1268 #ifdef HAVE_REMOTE_LCD
1269 wps_datas
[i
].remote_wps
= (i
== SCREEN_REMOTE
);
1271 gui_wps
[i
].data
= &wps_datas
[i
];
1272 gui_wps
[i
].display
= &screens
[i
];
1273 /* Currently no seperate wps_state needed/possible
1274 so use the only available ( "global" ) one */
1275 gui_wps
[i
].state
= &wps_state
;
1276 gui_wps
[i
].display
->backdrop_unload(BACKDROP_SKIN_WPS
);
1278 #ifdef HAVE_LCD_BITMAP
1279 add_event(GUI_EVENT_STATUSBAR_TOGGLE
, false, statusbar_toggle_handler
);
1283 #ifdef HAVE_ALBUMART
1284 bool wps_uses_albumart(int *width
, int *height
)
1288 struct gui_wps
*gwps
= &gui_wps
[i
];
1289 if (gwps
->data
&& (gwps
->data
->wps_uses_albumart
!= WPS_ALBUMART_NONE
))
1292 *width
= gui_wps
[0].data
->albumart_max_width
;
1294 *height
= gui_wps
[0].data
->albumart_max_height
;
1303 #ifdef IPOD_ACCESSORY_PROTOCOL
1304 int wps_get_ff_rewind_count(void)
1306 return wps_state
.ff_rewind_count
;