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 /* currently only one wps_state is needed */
78 static struct wps_state wps_state
;
79 static 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 void wps_data_load(enum screen_type screen
, const char *buf
, bool is_file
)
95 skin_data_load(gui_wps
[screen
].data
, &screens
[screen
], buf
, is_file
);
96 #ifdef HAVE_REMOVE_LCD
97 gui_wps
[screen
].data
->remote_wps
= !(screen
== SCREEN_MAIN
);
101 void wps_data_init(enum screen_type screen
)
103 skin_data_init(gui_wps
[screen
].data
);
106 bool wps_fading_out
= false;
107 void fade(bool fade_in
, bool updatewps
)
109 int fp_global_vol
= global_settings
.volume
<< 8;
110 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
111 int fp_step
= (fp_global_vol
- fp_min_vol
) / 30;
113 wps_fading_out
= !fade_in
;
116 int fp_volume
= fp_min_vol
;
118 /* zero out the sound */
119 sound_set_volume(fp_min_vol
>> 8);
121 sleep(HZ
/10); /* let audio thread run */
124 while (fp_volume
< fp_global_vol
- fp_step
) {
125 fp_volume
+= fp_step
;
126 sound_set_volume(fp_volume
>> 8);
130 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
134 sound_set_volume(global_settings
.volume
);
138 int fp_volume
= fp_global_vol
;
140 while (fp_volume
> fp_min_vol
+ fp_step
) {
141 fp_volume
-= fp_step
;
142 sound_set_volume(fp_volume
>> 8);
146 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
151 wps_fading_out
= false;
152 #if CONFIG_CODEC != SWCODEC
154 /* let audio thread run and wait for the mas to run out of data */
155 while (!mp3_pause_done())
160 /* reset volume to what it was before the fade */
161 sound_set_volume(global_settings
.volume
);
164 bool is_wps_fading(void)
166 return wps_fading_out
;
169 bool update_onvol_change(struct gui_wps
* gwps
)
171 skin_update(gwps
, WPS_REFRESH_NON_STATIC
);
173 #ifdef HAVE_LCD_CHARCELLS
174 splashf(0, "Vol: %3d dB",
175 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
182 bool ffwd_rew(int button
)
184 unsigned int step
= 0; /* current ff/rewind step */
185 unsigned int max_step
= 0; /* maximum ff/rewind step */
186 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
187 int direction
= -1; /* forward=1 or backward=-1 */
191 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
193 if (button
== ACTION_NONE
)
195 status_set_ffmode(0);
202 case ACTION_WPS_SEEKFWD
:
204 case ACTION_WPS_SEEKBACK
:
205 if (wps_state
.ff_rewind
)
209 /* fast forwarding, calc max step relative to end */
210 max_step
= (wps_state
.id3
->length
-
211 (wps_state
.id3
->elapsed
+
213 FF_REWIND_MAX_PERCENT
/ 100;
217 /* rewinding, calc max step relative to start */
218 max_step
= (wps_state
.id3
->elapsed
+ ff_rewind_count
) *
219 FF_REWIND_MAX_PERCENT
/ 100;
222 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
227 ff_rewind_count
+= step
* direction
;
229 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
230 step
+= step
>> ff_rw_accel
;
234 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
235 wps_state
.id3
&& wps_state
.id3
->length
)
237 if (!wps_state
.paused
)
238 #if (CONFIG_CODEC == SWCODEC)
239 audio_pre_ff_rewind();
243 #if CONFIG_KEYPAD == PLAYER_PAD
245 gui_wps
[i
].display
->stop_scroll();
248 status_set_ffmode(STATUS_FASTFORWARD
);
250 status_set_ffmode(STATUS_FASTBACKWARD
);
252 wps_state
.ff_rewind
= true;
254 step
= 1000 * global_settings
.ff_rewind_min_step
;
261 if ((wps_state
.id3
->elapsed
+ ff_rewind_count
) >
262 wps_state
.id3
->length
)
263 ff_rewind_count
= wps_state
.id3
->length
-
264 wps_state
.id3
->elapsed
;
267 if ((int)(wps_state
.id3
->elapsed
+ ff_rewind_count
) < 0)
268 ff_rewind_count
= -wps_state
.id3
->elapsed
;
271 /* set the wps state ff_rewind_count so the progess info
273 wps_state
.ff_rewind_count
= (wps_state
.wps_time_countup
== false)?
274 ff_rewind_count
:-ff_rewind_count
;
277 skin_update(&gui_wps
[i
],
278 WPS_REFRESH_PLAYER_PROGRESS
|
279 WPS_REFRESH_DYNAMIC
);
284 case ACTION_WPS_STOPSEEK
:
285 wps_state
.id3
->elapsed
= wps_state
.id3
->elapsed
+ff_rewind_count
;
286 audio_ff_rewind(wps_state
.id3
->elapsed
);
287 wps_state
.ff_rewind_count
= 0;
288 wps_state
.ff_rewind
= false;
289 status_set_ffmode(0);
290 #if (CONFIG_CODEC != SWCODEC)
291 if (!wps_state
.paused
)
294 #ifdef HAVE_LCD_CHARCELLS
296 skin_update(&gui_wps
[i
], WPS_REFRESH_ALL
);
302 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
303 status_set_ffmode(0);
311 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
312 #ifdef HAVE_TOUCHSCREEN
313 if (button
== ACTION_TOUCHSCREEN
)
314 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
322 void display_keylock_text(bool locked
)
326 gui_wps
[i
].display
->stop_scroll();
328 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
334 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
335 static void gwps_caption_backlight(struct wps_state
*state
)
337 if (state
&& state
->id3
)
339 #ifdef HAVE_BACKLIGHT
340 if (global_settings
.caption_backlight
)
342 /* turn on backlight n seconds before track ends, and turn it off n
343 seconds into the new track. n == backlight_timeout, or 5s */
344 int n
= global_settings
.backlight_timeout
* 1000;
347 n
= 5000; /* use 5s if backlight is always on or off */
349 if (((state
->id3
->elapsed
< 1000) ||
350 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
351 (state
->paused
== false))
355 #ifdef HAVE_REMOTE_LCD
356 if (global_settings
.remote_caption_backlight
)
358 /* turn on remote backlight n seconds before track ends, and turn it
359 off n seconds into the new track. n == remote_backlight_timeout,
361 int n
= global_settings
.remote_backlight_timeout
* 1000;
364 n
= 5000; /* use 5s if backlight is always on or off */
366 if (((state
->id3
->elapsed
< 1000) ||
367 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
368 (state
->paused
== false))
369 remote_backlight_on();
377 static void change_dir(int direction
)
379 if (global_settings
.prevent_skip
)
384 else if (direction
> 0)
386 /* prevent the next dir to immediatly start being ffw'd */
387 action_wait_for_release();
390 static void prev_track(unsigned long skip_thresh
)
392 if (wps_state
.id3
->elapsed
< skip_thresh
)
399 if (wps_state
.id3
->cuesheet
)
401 curr_cuesheet_skip(wps_state
.id3
->cuesheet
, -1, wps_state
.id3
->elapsed
);
405 if (!wps_state
.paused
)
406 #if (CONFIG_CODEC == SWCODEC)
407 audio_pre_ff_rewind();
414 #if (CONFIG_CODEC != SWCODEC)
415 if (!wps_state
.paused
)
421 static void next_track(void)
423 /* take care of if we're playing a cuesheet */
424 if (wps_state
.id3
->cuesheet
)
426 if (curr_cuesheet_skip(wps_state
.id3
->cuesheet
, 1, wps_state
.id3
->elapsed
))
428 /* if the result was false, then we really want
429 to skip to the next track */
437 static void play_hop(int direction
)
439 unsigned long step
= ((unsigned long)global_settings
.skip_length
)*1000;
440 unsigned long elapsed
= wps_state
.id3
->elapsed
;
441 unsigned long remaining
= wps_state
.id3
->length
- elapsed
;
443 if (!global_settings
.prevent_skip
&&
445 (direction
> 0 && step
>= remaining
) ||
446 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
447 { /* Do normal track skipping */
450 else if (direction
< 0)
451 prev_track(DEFAULT_SKIP_TRESH
);
455 if (direction
== 1 && step
>= remaining
)
457 #if CONFIG_CODEC == SWCODEC
458 if(global_settings
.beep
)
459 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
463 else if ((direction
== -1 && elapsed
< step
))
469 elapsed
+= step
* direction
;
471 if((audio_status() & AUDIO_STATUS_PLAY
) && !wps_state
.paused
)
473 #if (CONFIG_CODEC == SWCODEC)
474 audio_pre_ff_rewind();
479 audio_ff_rewind(wps_state
.id3
->elapsed
= elapsed
);
480 #if (CONFIG_CODEC != SWCODEC)
481 if (!wps_state
.paused
)
486 static void gwps_fix_statusbars(void)
488 #ifdef HAVE_LCD_BITMAP
490 wpsbars
= VP_SB_HIDE_ALL
;
494 if (gui_wps
[i
].data
->wps_sb_tag
)
495 draw
= gui_wps
[i
].data
->show_sb_on_wps
;
496 else if (statusbar_position(i
) != STATUSBAR_OFF
)
499 wpsbars
|= (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
502 wpsbars
= VP_SB_ALLSCREENS
;
506 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
508 * If the user is unable to see the wps, because the display is deactivated,
509 * we suppress updates until the wps is activated again (the lcd driver will
510 * call this hook to issue an instant update)
512 static void wps_lcd_activation_hook(void)
514 wps_state
.do_full_update
= true;
515 /* force timeout in wps main loop, so that the update is instantly */
516 queue_post(&button_queue
, BUTTON_NONE
, 0);
520 static void gwps_leave_wps(void)
522 int i
, oldbars
= VP_SB_HIDE_ALL
;
525 gui_wps
[i
].display
->stop_scroll();
526 if (global_settings
.statusbar
)
527 oldbars
= VP_SB_ALLSCREENS
;
530 show_main_backdrop();
532 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
533 show_remote_main_backdrop();
535 viewportmanager_set_statusbar(oldbars
);
536 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
537 /* Play safe and unregister the hook */
538 lcd_activation_set_hook(NULL
);
542 void gwps_draw_statusbars(void)
544 viewportmanager_set_statusbar(wpsbars
);
546 #ifdef HAVE_TOUCHSCREEN
547 int wps_get_touchaction(struct wps_data
*data
)
551 int type
= action_get_touchscreen_press(&x
, &y
);
553 static int last_action
= ACTION_NONE
;
554 struct touchregion
*r
;
555 bool repeated
= (type
== BUTTON_REPEAT
);
556 bool released
= (type
== BUTTON_REL
);
557 for (i
=0; i
<data
->touchregion_count
; i
++)
559 r
= &data
->touchregion
[i
];
560 /* make sure this region's viewport is visible */
561 if (r
->wvp
->hidden_flags
&VP_DRAW_HIDDEN
)
563 /* reposition the touch inside the viewport */
564 vx
= x
- r
->wvp
->vp
.x
;
565 vy
= y
- r
->wvp
->vp
.y
;
566 /* check if it's inside this viewport */
567 if (vx
>= 0 && vx
< r
->wvp
->vp
.x
+ r
->wvp
->vp
.width
&&
568 vy
>= 0 && vy
< r
->wvp
->vp
.y
+ r
->wvp
->vp
.height
)
570 /* now see if the point is inside this region */
571 if (vx
>= r
->x
&& vx
< r
->x
+r
->width
&&
572 vy
>= r
->y
&& vy
< r
->y
+r
->height
)
574 if ((repeated
&& r
->repeat
) ||
575 (released
&& !r
->repeat
))
577 last_action
= r
->action
;
583 if ((last_action
== ACTION_WPS_SEEKBACK
|| last_action
== ACTION_WPS_SEEKFWD
))
584 return ACTION_WPS_STOPSEEK
;
585 last_action
= ACTION_TOUCHSCREEN
;
586 return ACTION_TOUCHSCREEN
;
589 /* The WPS can be left in two ways:
590 * a) call a function, which draws over the wps. In this case, the wps
591 * will be still active (i.e. the below function didn't return)
592 * b) return with a value evaluated by root_menu.c, in this case the wps
593 * is really left, and root_menu will handle the next screen
595 * In either way, call gwps_leave_wps(), in order to restore the correct
596 * "main screen" backdrops and statusbars
598 long gui_wps_show(void)
602 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
604 bool bookmark
= false;
607 long last_left
= 0, last_right
= 0;
609 #ifdef HAVE_LCD_CHARCELLS
610 status_set_audio(true);
611 status_set_param(false);
614 #ifdef AB_REPEAT_ENABLE
622 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
624 /* did someone else (i.e power thread) change audio pause mode? */
625 if (wps_state
.paused
!= audio_paused
) {
626 wps_state
.paused
= audio_paused
;
628 /* if another thread paused audio, we are probably in car mode,
629 about to shut down. lets save the settings. */
630 if (wps_state
.paused
) {
632 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
633 call_storage_idle_notifys(true);
638 #ifdef HAVE_LCD_BITMAP
639 /* when the peak meter is enabled we want to have a
640 few extra updates to make it look smooth. On the
641 other hand we don't want to waste energy if it
646 if(gui_wps
[i
].data
->peak_meter_enabled
)
651 long next_refresh
= current_tick
;
652 long next_big_refresh
= current_tick
+ HZ
/ 5;
653 button
= BUTTON_NONE
;
654 while (TIME_BEFORE(current_tick
, next_big_refresh
)) {
655 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_NOBLOCK
);
656 if (button
!= ACTION_NONE
) {
660 sleep(0); /* Sleep until end of current tick. */
662 if (TIME_AFTER(current_tick
, next_refresh
)) {
665 if(gui_wps
[i
].data
->peak_meter_enabled
)
666 skin_update(&gui_wps
[i
], WPS_REFRESH_PEAK_METER
);
667 next_refresh
+= HZ
/ PEAK_METER_FPS
;
674 /* The peak meter is disabled
675 -> no additional screen updates needed */
679 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,
680 restore
? HZ
/100 : HZ
/5);
683 /* Exit if audio has stopped playing. This happens e.g. at end of
684 playlist or if using the sleep timer. */
685 if (!(audio_status() & AUDIO_STATUS_PLAY
))
687 #ifdef HAVE_TOUCHSCREEN
688 if (button
== ACTION_TOUCHSCREEN
)
689 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
691 /* The iPods/X5/M5 use a single button for the A-B mode markers,
692 defined as ACTION_WPSAB_SINGLE in their config files. */
693 #ifdef ACTION_WPSAB_SINGLE
694 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
696 static int wps_ab_state
= 0;
697 if (button
== ACTION_WPSAB_SINGLE
)
699 switch (wps_ab_state
)
701 case 0: /* set the A spot */
702 button
= ACTION_WPS_ABSETA_PREVDIR
;
704 case 1: /* set the B spot */
705 button
= ACTION_WPS_ABSETB_NEXTDIR
;
708 button
= ACTION_WPS_ABRESET
;
711 wps_ab_state
= (wps_ab_state
+1) % 3;
717 case ACTION_WPS_CONTEXT
:
720 /* if music is stopped in the context menu we want to exit the wps */
721 if (onplay(wps_state
.id3
->path
,
722 FILE_ATTR_AUDIO
, CONTEXT_WPS
) == ONPLAY_MAINMENU
729 case ACTION_WPS_BROWSE
:
730 #ifdef HAVE_LCD_CHARCELLS
731 status_set_record(false);
732 status_set_audio(false);
735 return GO_TO_PREVIOUS_BROWSER
;
739 case ACTION_WPS_PLAY
:
740 if (global_settings
.party_mode
)
742 if ( wps_state
.paused
)
744 wps_state
.paused
= false;
745 if ( global_settings
.fade_on_stop
)
752 wps_state
.paused
= true;
753 if ( global_settings
.fade_on_stop
)
758 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
759 call_storage_idle_notifys(true); /* make sure resume info is saved */
764 case ACTION_WPS_VOLUP
:
767 gui_wps
[i
].data
->button_time_volume
= current_tick
;
768 global_settings
.volume
++;
773 if(update_onvol_change(&gui_wps
[i
]))
778 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
782 case ACTION_WPS_VOLDOWN
:
785 gui_wps
[i
].data
->button_time_volume
= current_tick
;
786 global_settings
.volume
--;
791 if(update_onvol_change(&gui_wps
[i
]))
796 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
801 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
802 case ACTION_WPS_SEEKFWD
:
803 if (global_settings
.party_mode
)
805 if (current_tick
-last_right
< HZ
)
807 if (wps_state
.id3
->cuesheet
)
817 ffwd_rew(ACTION_WPS_SEEKFWD
);
818 last_right
= last_left
= 0;
821 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
822 case ACTION_WPS_SEEKBACK
:
823 if (global_settings
.party_mode
)
825 if (current_tick
-last_left
< HZ
)
827 if (wps_state
.id3
->cuesheet
)
829 if (!wps_state
.paused
)
830 #if (CONFIG_CODEC == SWCODEC)
831 audio_pre_ff_rewind();
843 ffwd_rew(ACTION_WPS_SEEKBACK
);
844 last_left
= last_right
= 0;
848 case ACTION_WPS_SKIPPREV
:
849 if (global_settings
.party_mode
)
851 last_left
= current_tick
;
852 #ifdef AB_REPEAT_ENABLE
853 /* if we're in A/B repeat mode and the current position
854 is past the A marker, jump back to the A marker... */
855 if ( ab_repeat_mode_enabled() )
857 if ( ab_after_A_marker(wps_state
.id3
->elapsed
) )
859 ab_jump_to_A_marker();
861 #if (AB_REPEAT_ENABLE == 2)
868 /* ...otherwise, do it normally */
874 OR if skip length set, hop by predetermined amount. */
875 case ACTION_WPS_SKIPNEXT
:
876 if (global_settings
.party_mode
)
878 last_right
= current_tick
;
879 #ifdef AB_REPEAT_ENABLE
880 /* if we're in A/B repeat mode and the current position is
881 before the A marker, jump to the A marker... */
882 if ( ab_repeat_mode_enabled() )
884 if ( ab_before_A_marker(wps_state
.id3
->elapsed
) )
886 ab_jump_to_A_marker();
888 #if (AB_REPEAT_ENABLE == 2)
895 /* ...otherwise, do it normally */
899 /* next / prev directories */
900 /* and set A-B markers if in a-b mode */
901 case ACTION_WPS_ABSETB_NEXTDIR
:
902 if (global_settings
.party_mode
)
904 #if defined(AB_REPEAT_ENABLE)
905 if (ab_repeat_mode_enabled())
907 ab_set_B_marker(wps_state
.id3
->elapsed
);
908 ab_jump_to_A_marker();
916 case ACTION_WPS_ABSETA_PREVDIR
:
917 if (global_settings
.party_mode
)
919 #if defined(AB_REPEAT_ENABLE)
920 if (ab_repeat_mode_enabled())
921 ab_set_A_marker(wps_state
.id3
->elapsed
);
928 /* menu key functions */
929 case ACTION_WPS_MENU
:
935 #ifdef HAVE_QUICKSCREEN
936 case ACTION_WPS_QUICKSCREEN
:
939 if (quick_screen_quick(button
))
940 return SYS_USB_CONNECTED
;
944 #endif /* HAVE_QUICKSCREEN */
946 /* screen settings */
951 if (quick_screen_f3(BUTTON_F3
))
952 return SYS_USB_CONNECTED
;
956 #endif /* BUTTON_F3 */
959 #ifdef HAVE_PITCHSCREEN
960 case ACTION_WPS_PITCHSCREEN
:
963 if (1 == gui_syncpitchscreen_run())
964 return SYS_USB_CONNECTED
;
968 #endif /* HAVE_PITCHSCREEN */
970 #ifdef AB_REPEAT_ENABLE
971 /* reset A&B markers */
972 case ACTION_WPS_ABRESET
:
973 if (ab_repeat_mode_enabled())
979 #endif /* AB_REPEAT_ENABLE */
981 /* stop and exit wps */
982 case ACTION_WPS_STOP
:
983 if (global_settings
.party_mode
)
989 case ACTION_WPS_ID3SCREEN
:
996 #ifdef HAVE_TOUCHSCREEN
997 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
999 global_settings
.playlist_shuffle
=
1000 !global_settings
.playlist_shuffle
;
1001 #if CONFIG_CODEC == SWCODEC
1002 dsp_set_replaygain();
1004 if (global_settings
.playlist_shuffle
)
1005 playlist_randomise(NULL
, current_tick
, true);
1007 playlist_sort(NULL
, true);
1010 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1012 const struct settings_list
*rep_setting
=
1013 find_setting(&global_settings
.repeat_mode
, NULL
);
1014 option_select_next_val(rep_setting
, false, true);
1015 audio_flush_and_reload_tracks();
1018 #endif /* HAVE_TOUCHSCREEN */
1019 /* this case is used by the softlock feature
1020 * it requests a full update here */
1022 wps_state
.do_full_update
= true;
1024 case ACTION_NONE
: /* Timeout, do a partial update */
1026 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1028 #ifdef HAVE_RECORDING
1029 case ACTION_WPS_REC
:
1034 default_event_handler(SYS_POWEROFF
);
1036 case ACTION_WPS_VIEW_PLAYLIST
:
1038 if (playlist_viewer()) /* true if USB connected */
1039 return SYS_USB_CONNECTED
;
1043 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
1049 if (wps_state
.do_full_update
|| update
)
1051 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1052 gwps_caption_backlight(&wps_state
);
1056 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1058 #ifdef HAVE_REMOTE_LCD
1059 /* currently, all remotes are readable without backlight
1060 * so still update those */
1061 || (i
== SCREEN_REMOTE
)
1066 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
1069 wps_state
.do_full_update
= false;
1073 if (restore
&& wps_state
.id3
&&
1074 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1075 TIME_AFTER(current_tick
, restoretimer
)))
1078 restoretimer
= RESTORE_WPS_INSTANTLY
;
1079 gwps_fix_statusbars();
1080 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1081 lcd_activation_set_hook(wps_lcd_activation_hook
);
1085 screens
[i
].stop_scroll();
1086 gui_wps_display(&gui_wps
[i
]);
1091 #ifdef HAVE_LCD_CHARCELLS
1092 status_set_record(false);
1093 status_set_audio(false);
1095 if (global_settings
.fade_on_stop
)
1099 bookmark_autobookmark();
1101 #ifdef AB_REPEAT_ENABLE
1105 #ifdef HAVE_RECORDING
1106 if (button
== ACTION_WPS_REC
)
1107 return GO_TO_RECSCREEN
;
1109 if (global_settings
.browse_current
)
1110 return GO_TO_PREVIOUS_BROWSER
;
1111 return GO_TO_PREVIOUS
;
1114 if (button
&& !IS_SYSEVENT(button
) )
1117 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1120 /* this is called from the playback thread so NO DRAWING! */
1121 static void track_changed_callback(void *param
)
1123 wps_state
.id3
= (struct mp3entry
*)param
;
1124 wps_state
.nid3
= audio_next_track();
1125 if (wps_state
.id3
->cuesheet
)
1127 cue_find_current_track(wps_state
.id3
->cuesheet
, wps_state
.id3
->elapsed
);
1128 cue_spoof_id3(wps_state
.id3
->cuesheet
, wps_state
.id3
);
1130 wps_state
.do_full_update
= true;
1132 static void nextid3available_callback(void* param
)
1135 wps_state
.nid3
= audio_next_track();
1136 wps_state
.do_full_update
= true;
1140 static void wps_state_init(void)
1142 wps_state
.ff_rewind
= false;
1143 wps_state
.paused
= false;
1144 if(audio_status() & AUDIO_STATUS_PLAY
)
1146 wps_state
.id3
= audio_current_track();
1147 wps_state
.nid3
= audio_next_track();
1151 wps_state
.id3
= NULL
;
1152 wps_state
.nid3
= NULL
;
1154 /* We'll be updating due to restore initialized with true */
1155 wps_state
.do_full_update
= false;
1156 /* add the WPS track event callbacks */
1157 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1158 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1162 #ifdef HAVE_LCD_BITMAP
1163 static void statusbar_toggle_handler(void *data
)
1167 gwps_fix_statusbars();
1171 struct viewport
*vp
= &gui_wps
[i
].data
->viewports
[0].vp
;
1172 bool draw
= wpsbars
& (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
1176 vp
->height
= screens
[i
].lcdheight
;
1180 bool bar_at_top
= statusbar_position(i
) != STATUSBAR_BOTTOM
;
1181 vp
->y
= bar_at_top
?STATUSBAR_HEIGHT
:0;
1182 vp
->height
= screens
[i
].lcdheight
- STATUSBAR_HEIGHT
;
1188 void gui_sync_wps_init(void)
1193 skin_data_init(&wps_datas
[i
]);
1194 #ifdef HAVE_ALBUMART
1195 wps_datas
[i
].wps_uses_albumart
= 0;
1197 #ifdef HAVE_REMOTE_LCD
1198 wps_datas
[i
].remote_wps
= (i
!= 0);
1200 gui_wps
[i
].data
= &wps_datas
[i
];
1201 gui_wps
[i
].display
= &screens
[i
];
1202 /* Currently no seperate wps_state needed/possible
1203 so use the only available ( "global" ) one */
1204 gui_wps
[i
].state
= &wps_state
;
1206 #ifdef HAVE_LCD_BITMAP
1207 add_event(GUI_EVENT_STATUSBAR_TOGGLE
, false, statusbar_toggle_handler
);
1210 unload_wps_backdrop();
1212 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
1213 unload_remote_wps_backdrop();
1217 #ifdef HAVE_ALBUMART
1218 bool wps_uses_albumart(int *width
, int *height
)
1222 struct gui_wps
*gwps
= &gui_wps
[i
];
1223 if (gwps
->data
&& (gwps
->data
->wps_uses_albumart
!= WPS_ALBUMART_NONE
))
1226 *width
= gui_wps
[0].data
->albumart_max_width
;
1228 *height
= gui_wps
[0].data
->albumart_max_height
;
1237 #ifdef IPOD_ACCESSORY_PROTOCOL
1238 int wps_get_ff_rewind_count(void)
1240 return wps_state
.ff_rewind_count
;