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"
35 #include "skin_engine/skin_engine.h"
36 #include "mp3_playback.h"
43 #ifdef HAVE_LCD_BITMAP
45 #include "peakmeter.h"
56 #include "ata_idle_notify.h"
57 #include "root_menu.h"
59 #include "quickscreen.h"
60 #include "pitchscreen.h"
61 #include "appevents.h"
64 #include "option_select.h"
66 #include "playlist_viewer.h"
68 #include "statusbar-skinned.h"
70 #define RESTORE_WPS_INSTANTLY 0l
71 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
73 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
74 /* 3% of 30min file == 54s step size */
75 #define MIN_FF_REWIND_STEP 500
77 /* currently only one wps_state is needed, initialize to 0 */
78 struct wps_state wps_state
= { .id3
= NULL
};
79 static struct gui_wps gui_wps
[NB_SCREENS
] = {{ .data
= NULL
}};
80 static struct wps_data wps_datas
[NB_SCREENS
] = {{ .wps_loaded
= 0 }};
81 static struct wps_sync_data wps_sync_data
= { .do_full_update
= false };
83 /* initial setup of wps_data */
84 static void wps_state_init(void);
85 static void track_changed_callback(void *param
);
86 static void nextid3available_callback(void* param
);
88 #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
89 #ifdef HAVE_REMOTE_LCD
90 #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
91 #define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \
92 WPS_DEFAULTCFG:RWPS_DEFAULTCFG)
94 #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
97 void wps_data_load(enum screen_type screen
, const char *buf
, bool isfile
)
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.
108 if (buf
&& ! strcmp(buf
, DEFAULT_WPS(screen
)) )
110 #ifdef HAVE_REMOTE_LCD
111 if (screen
== SCREEN_REMOTE
)
112 global_settings
.rwps_file
[0] = '\0';
115 global_settings
.wps_file
[0] = '\0';
119 #endif /* __PCTOOL__ */
121 loaded_ok
= buf
&& skin_data_load(screen
, gui_wps
[screen
].data
, buf
, isfile
);
123 if (!loaded_ok
) /* load the hardcoded default */
125 char *skin_buf
[NB_SCREENS
] = {
126 #ifdef HAVE_LCD_BITMAP
130 "%s%?it<%?in<%in. |>%it|%fn>\n"
131 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
132 "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
133 "%al%pc/%pt%ar[%pp:%pe]\n"
134 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
137 "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
140 #ifdef HAVE_REMOTE_LCD
141 #if LCD_REMOTE_DEPTH > 1
144 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
145 "%s%?it<%?in<%in. |>%it|%fn>\n"
146 "%al%pc/%pt%ar[%pp:%pe]\n"
147 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
151 skin_data_load(screen
, gui_wps
[screen
].data
, skin_buf
[screen
], false);
155 void fade(bool fade_in
, bool updatewps
)
157 int fp_global_vol
= global_settings
.volume
<< 8;
158 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
159 int fp_step
= (fp_global_vol
- fp_min_vol
) / 30;
161 wps_state
.is_fading
= !fade_in
;
164 int fp_volume
= fp_min_vol
;
166 /* zero out the sound */
167 sound_set_volume(fp_min_vol
>> 8);
169 sleep(HZ
/10); /* let audio thread run */
172 while (fp_volume
< fp_global_vol
- fp_step
) {
173 fp_volume
+= fp_step
;
174 sound_set_volume(fp_volume
>> 8);
178 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
182 sound_set_volume(global_settings
.volume
);
186 int fp_volume
= fp_global_vol
;
188 while (fp_volume
> fp_min_vol
+ fp_step
) {
189 fp_volume
-= fp_step
;
190 sound_set_volume(fp_volume
>> 8);
194 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
199 wps_state
.is_fading
= false;
200 #if CONFIG_CODEC != SWCODEC
202 /* let audio thread run and wait for the mas to run out of data */
203 while (!mp3_pause_done())
208 /* reset volume to what it was before the fade */
209 sound_set_volume(global_settings
.volume
);
213 static bool update_onvol_change(struct gui_wps
* gwps
)
215 skin_update(gwps
, WPS_REFRESH_NON_STATIC
);
217 #ifdef HAVE_LCD_CHARCELLS
218 splashf(0, "Vol: %3d dB",
219 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
226 #ifdef HAVE_TOUCHSCREEN
227 int skintouch_to_wps(struct wps_data
*data
)
230 int button
= skin_get_touchaction(data
, &offset
);
233 case ACTION_STD_PREV
:
234 return ACTION_WPS_SKIPPREV
;
235 case ACTION_STD_PREVREPEAT
:
236 return ACTION_WPS_SEEKBACK
;
237 case ACTION_STD_NEXT
:
238 return ACTION_WPS_SKIPNEXT
;
239 case ACTION_STD_NEXTREPEAT
:
240 return ACTION_WPS_SEEKFWD
;
241 case ACTION_STD_MENU
:
242 return ACTION_WPS_MENU
;
243 case ACTION_STD_CONTEXT
:
244 return ACTION_WPS_CONTEXT
;
245 case ACTION_STD_QUICKSCREEN
:
246 return ACTION_WPS_QUICKSCREEN
;
248 case ACTION_STD_HOTKEY
:
249 return ACTION_WPS_HOTKEY
;
251 case WPS_TOUCHREGION_SCROLLBAR
:
252 wps_state
.id3
->elapsed
= wps_state
.id3
->length
*offset
/100;
253 if (!wps_state
.paused
)
254 #if (CONFIG_CODEC == SWCODEC)
255 audio_pre_ff_rewind();
259 audio_ff_rewind(wps_state
.id3
->elapsed
);
260 #if (CONFIG_CODEC != SWCODEC)
261 if (!wps_state
.paused
)
264 return ACTION_TOUCHSCREEN
;
265 case WPS_TOUCHREGION_VOLUME
:
267 const int min_vol
= sound_min(SOUND_VOLUME
);
268 const int max_vol
= sound_max(SOUND_VOLUME
);
269 global_settings
.volume
= (offset
* (max_vol
- min_vol
)) / 100;
270 global_settings
.volume
+= min_vol
;
273 return ACTION_TOUCHSCREEN
;
279 bool ffwd_rew(int button
)
281 unsigned int step
= 0; /* current ff/rewind step */
282 unsigned int max_step
= 0; /* maximum ff/rewind step */
283 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
284 int direction
= -1; /* forward=1 or backward=-1 */
288 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
290 if (button
== ACTION_NONE
)
292 status_set_ffmode(0);
299 case ACTION_WPS_SEEKFWD
:
301 case ACTION_WPS_SEEKBACK
:
302 if (wps_state
.ff_rewind
)
306 /* fast forwarding, calc max step relative to end */
307 max_step
= (wps_state
.id3
->length
-
308 (wps_state
.id3
->elapsed
+
310 FF_REWIND_MAX_PERCENT
/ 100;
314 /* rewinding, calc max step relative to start */
315 max_step
= (wps_state
.id3
->elapsed
+ ff_rewind_count
) *
316 FF_REWIND_MAX_PERCENT
/ 100;
319 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
324 ff_rewind_count
+= step
* direction
;
326 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
327 step
+= step
>> ff_rw_accel
;
331 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
332 wps_state
.id3
&& wps_state
.id3
->length
)
334 if (!wps_state
.paused
)
335 #if (CONFIG_CODEC == SWCODEC)
336 audio_pre_ff_rewind();
340 #if CONFIG_KEYPAD == PLAYER_PAD
342 gui_wps
[i
].display
->stop_scroll();
345 status_set_ffmode(STATUS_FASTFORWARD
);
347 status_set_ffmode(STATUS_FASTBACKWARD
);
349 wps_state
.ff_rewind
= true;
351 step
= 1000 * global_settings
.ff_rewind_min_step
;
358 if ((wps_state
.id3
->elapsed
+ ff_rewind_count
) >
359 wps_state
.id3
->length
)
360 ff_rewind_count
= wps_state
.id3
->length
-
361 wps_state
.id3
->elapsed
;
364 if ((int)(wps_state
.id3
->elapsed
+ ff_rewind_count
) < 0)
365 ff_rewind_count
= -wps_state
.id3
->elapsed
;
368 /* set the wps state ff_rewind_count so the progess info
370 wps_state
.ff_rewind_count
= (wps_state
.wps_time_countup
== false)?
371 ff_rewind_count
:-ff_rewind_count
;
374 skin_update(&gui_wps
[i
],
375 WPS_REFRESH_PLAYER_PROGRESS
|
376 WPS_REFRESH_DYNAMIC
);
381 case ACTION_WPS_STOPSEEK
:
382 wps_state
.id3
->elapsed
= wps_state
.id3
->elapsed
+ff_rewind_count
;
383 audio_ff_rewind(wps_state
.id3
->elapsed
);
384 wps_state
.ff_rewind_count
= 0;
385 wps_state
.ff_rewind
= false;
386 status_set_ffmode(0);
387 #if (CONFIG_CODEC != SWCODEC)
388 if (!wps_state
.paused
)
391 #ifdef HAVE_LCD_CHARCELLS
393 skin_update(&gui_wps
[i
], WPS_REFRESH_ALL
);
399 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
400 status_set_ffmode(0);
408 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
409 #ifdef HAVE_TOUCHSCREEN
410 if (button
== ACTION_TOUCHSCREEN
)
411 button
= skintouch_to_wps(gui_wps
[SCREEN_MAIN
].data
);
412 if (button
!= ACTION_WPS_SEEKFWD
&&
413 button
!= ACTION_WPS_SEEKBACK
)
414 button
= ACTION_WPS_STOPSEEK
;
422 void display_keylock_text(bool locked
)
426 gui_wps
[i
].display
->stop_scroll();
428 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
434 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
435 static void gwps_caption_backlight(struct wps_state
*state
)
437 if (state
&& state
->id3
)
439 #ifdef HAVE_BACKLIGHT
440 if (global_settings
.caption_backlight
)
442 /* turn on backlight n seconds before track ends, and turn it off n
443 seconds into the new track. n == backlight_timeout, or 5s */
444 int n
= global_settings
.backlight_timeout
* 1000;
447 n
= 5000; /* use 5s if backlight is always on or off */
449 if (((state
->id3
->elapsed
< 1000) ||
450 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
451 (state
->paused
== false))
455 #ifdef HAVE_REMOTE_LCD
456 if (global_settings
.remote_caption_backlight
)
458 /* turn on remote backlight n seconds before track ends, and turn it
459 off n seconds into the new track. n == remote_backlight_timeout,
461 int n
= global_settings
.remote_backlight_timeout
* 1000;
464 n
= 5000; /* use 5s if backlight is always on or off */
466 if (((state
->id3
->elapsed
< 1000) ||
467 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
468 (state
->paused
== false))
469 remote_backlight_on();
477 static void change_dir(int direction
)
479 if (global_settings
.prevent_skip
)
484 else if (direction
> 0)
486 /* prevent the next dir to immediatly start being ffw'd */
487 action_wait_for_release();
490 static void prev_track(unsigned long skip_thresh
)
492 if (wps_state
.id3
->elapsed
< skip_thresh
)
499 if (wps_state
.id3
->cuesheet
)
501 curr_cuesheet_skip(wps_state
.id3
->cuesheet
, -1, wps_state
.id3
->elapsed
);
505 if (!wps_state
.paused
)
506 #if (CONFIG_CODEC == SWCODEC)
507 audio_pre_ff_rewind();
514 #if (CONFIG_CODEC != SWCODEC)
515 if (!wps_state
.paused
)
521 static void next_track(void)
523 /* take care of if we're playing a cuesheet */
524 if (wps_state
.id3
->cuesheet
)
526 if (curr_cuesheet_skip(wps_state
.id3
->cuesheet
, 1, wps_state
.id3
->elapsed
))
528 /* if the result was false, then we really want
529 to skip to the next track */
537 static void play_hop(int direction
)
539 long step
= global_settings
.skip_length
*1000;
540 long elapsed
= wps_state
.id3
->elapsed
;
541 long remaining
= wps_state
.id3
->length
- elapsed
;
547 prev_track(DEFAULT_SKIP_TRESH
);
550 else if (remaining
< DEFAULT_SKIP_TRESH
*2)
556 elapsed
+= (remaining
- DEFAULT_SKIP_TRESH
*2);
558 else if (!global_settings
.prevent_skip
&&
560 (direction
> 0 && step
>= remaining
) ||
561 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
562 { /* Do normal track skipping */
565 else if (direction
< 0)
566 prev_track(DEFAULT_SKIP_TRESH
);
569 else if (direction
== 1 && step
>= remaining
)
571 #if CONFIG_CODEC == SWCODEC
572 if(global_settings
.beep
)
573 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
577 else if ((direction
== -1 && elapsed
< step
))
583 elapsed
+= step
* direction
;
585 if((audio_status() & AUDIO_STATUS_PLAY
) && !wps_state
.paused
)
587 #if (CONFIG_CODEC == SWCODEC)
588 audio_pre_ff_rewind();
593 audio_ff_rewind(wps_state
.id3
->elapsed
= elapsed
);
594 #if (CONFIG_CODEC != SWCODEC)
595 if (!wps_state
.paused
)
601 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
603 * If the user is unable to see the wps, because the display is deactivated,
604 * we suppress updates until the wps is activated again (the lcd driver will
605 * call this hook to issue an instant update)
607 static void wps_lcd_activation_hook(void *param
)
610 wps_sync_data
.do_full_update
= true;
611 /* force timeout in wps main loop, so that the update is instantly */
612 queue_post(&button_queue
, BUTTON_NONE
, 0);
616 static void gwps_leave_wps(void)
622 gui_wps
[i
].display
->stop_scroll();
623 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
624 gui_wps
[i
].display
->backdrop_show(sb_get_backdrop(i
));
626 viewportmanager_theme_undo(i
, skin_has_sbs(i
, gui_wps
[i
].data
));
630 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
631 /* Play safe and unregister the hook */
632 remove_event(LCD_EVENT_ACTIVATION
, wps_lcd_activation_hook
);
634 /* unhandle statusbar update delay */
635 sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY
);
639 * display the wps on entering or restoring */
640 static void gwps_enter_wps(void)
645 struct gui_wps
*gwps
= &gui_wps
[i
];
646 struct screen
*display
= gwps
->display
;
647 display
->stop_scroll();
648 viewportmanager_theme_enable(i
, skin_has_sbs(i
, gui_wps
[i
].data
), NULL
);
650 /* Update the values in the first (default) viewport - in case the user
651 has modified the statusbar or colour settings */
653 if (display
->depth
> 1)
655 struct viewport
*vp
= &find_viewport(VP_DEFAULT_LABEL
, gwps
->data
)->vp
;
656 vp
->fg_pattern
= display
->get_foreground();
657 vp
->bg_pattern
= display
->get_background();
660 /* make the backdrop actually take effect */
661 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
662 display
->backdrop_show(gwps
->data
->backdrop
);
664 display
->clear_display();
665 skin_update(gwps
, WPS_REFRESH_ALL
);
667 #ifdef HAVE_TOUCHSCREEN
668 skin_disarm_touchregions(gui_wps
[i
].data
);
671 /* force statusbar/skin update since we just cleared the whole screen */
672 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
675 /* The WPS can be left in two ways:
676 * a) call a function, which draws over the wps. In this case, the wps
677 * will be still active (i.e. the below function didn't return)
678 * b) return with a value evaluated by root_menu.c, in this case the wps
679 * is really left, and root_menu will handle the next screen
681 * In either way, call gwps_leave_wps(), in order to restore the correct
682 * "main screen" backdrops and statusbars
684 long gui_wps_show(void)
688 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
690 bool bookmark
= false;
692 bool vol_changed
= false;
694 long last_left
= 0, last_right
= 0;
696 #ifdef HAVE_LCD_CHARCELLS
697 status_set_audio(true);
698 status_set_param(false);
701 #ifdef AB_REPEAT_ENABLE
709 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
711 /* did someone else (i.e power thread) change audio pause mode? */
712 if (wps_state
.paused
!= audio_paused
) {
713 wps_state
.paused
= audio_paused
;
715 /* if another thread paused audio, we are probably in car mode,
716 about to shut down. lets save the settings. */
717 if (wps_state
.paused
) {
719 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
720 call_storage_idle_notifys(true);
724 button
= skin_wait_for_action(gui_wps
, CONTEXT_WPS
|ALLOW_SOFTLOCK
,
727 /* Exit if audio has stopped playing. This happens e.g. at end of
728 playlist or if using the sleep timer. */
729 if (!(audio_status() & AUDIO_STATUS_PLAY
))
731 #ifdef HAVE_TOUCHSCREEN
732 if (button
== ACTION_TOUCHSCREEN
)
733 button
= skintouch_to_wps(gui_wps
[SCREEN_MAIN
].data
);
735 /* The iPods/X5/M5 use a single button for the A-B mode markers,
736 defined as ACTION_WPSAB_SINGLE in their config files. */
737 #ifdef ACTION_WPSAB_SINGLE
738 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
740 static int wps_ab_state
= 0;
741 if (button
== ACTION_WPSAB_SINGLE
)
743 switch (wps_ab_state
)
745 case 0: /* set the A spot */
746 button
= ACTION_WPS_ABSETA_PREVDIR
;
748 case 1: /* set the B spot */
749 button
= ACTION_WPS_ABSETB_NEXTDIR
;
752 button
= ACTION_WPS_ABRESET
;
755 wps_ab_state
= (wps_ab_state
+1) % 3;
762 case ACTION_WPS_HOTKEY
:
763 if (!global_settings
.hotkey_wps
)
767 case ACTION_WPS_CONTEXT
:
769 bool hotkey
= button
== ACTION_WPS_HOTKEY
;
771 int retval
= onplay(wps_state
.id3
->path
,
772 FILE_ATTR_AUDIO
, CONTEXT_WPS
, hotkey
);
773 /* if music is stopped in the context menu we want to exit the wps */
774 if (retval
== ONPLAY_MAINMENU
777 else if (retval
== ONPLAY_PLAYLIST
)
778 return GO_TO_PLAYLIST_VIEWER
;
779 #ifdef HAVE_PICTUREFLOW_INTEGRATION
780 else if (retval
== ONPLAY_PICTUREFLOW
)
781 return GO_TO_PICTUREFLOW
;
787 case ACTION_WPS_BROWSE
:
788 #ifdef HAVE_LCD_CHARCELLS
789 status_set_record(false);
790 status_set_audio(false);
793 return GO_TO_PREVIOUS_BROWSER
;
797 case ACTION_WPS_PLAY
:
798 if (global_settings
.party_mode
)
800 if ( wps_state
.paused
)
802 wps_state
.paused
= false;
803 if ( global_settings
.fade_on_stop
)
810 wps_state
.paused
= true;
811 if ( global_settings
.fade_on_stop
)
816 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
817 call_storage_idle_notifys(true); /* make sure resume info is saved */
822 case ACTION_WPS_VOLUP
:
823 global_settings
.volume
++;
826 case ACTION_WPS_VOLDOWN
:
827 global_settings
.volume
--;
831 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
832 case ACTION_WPS_SEEKFWD
:
833 if (global_settings
.party_mode
)
835 if (current_tick
-last_right
< HZ
)
837 if (wps_state
.id3
->cuesheet
)
847 ffwd_rew(ACTION_WPS_SEEKFWD
);
848 last_right
= last_left
= 0;
851 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
852 case ACTION_WPS_SEEKBACK
:
853 if (global_settings
.party_mode
)
855 if (current_tick
-last_left
< HZ
)
857 if (wps_state
.id3
->cuesheet
)
859 if (!wps_state
.paused
)
860 #if (CONFIG_CODEC == SWCODEC)
861 audio_pre_ff_rewind();
873 ffwd_rew(ACTION_WPS_SEEKBACK
);
874 last_left
= last_right
= 0;
878 case ACTION_WPS_SKIPPREV
:
879 if (global_settings
.party_mode
)
881 last_left
= current_tick
;
882 #ifdef AB_REPEAT_ENABLE
883 /* if we're in A/B repeat mode and the current position
884 is past the A marker, jump back to the A marker... */
885 if ( ab_repeat_mode_enabled() )
887 if ( ab_after_A_marker(wps_state
.id3
->elapsed
) )
889 ab_jump_to_A_marker();
894 /* ...otherwise, do it normally */
900 OR if skip length set, hop by predetermined amount. */
901 case ACTION_WPS_SKIPNEXT
:
902 if (global_settings
.party_mode
)
904 last_right
= current_tick
;
905 #ifdef AB_REPEAT_ENABLE
906 /* if we're in A/B repeat mode and the current position is
907 before the A marker, jump to the A marker... */
908 if ( ab_repeat_mode_enabled() )
910 if ( ab_before_A_marker(wps_state
.id3
->elapsed
) )
912 ab_jump_to_A_marker();
917 /* ...otherwise, do it normally */
921 /* next / prev directories */
922 /* and set A-B markers if in a-b mode */
923 case ACTION_WPS_ABSETB_NEXTDIR
:
924 if (global_settings
.party_mode
)
926 #if defined(AB_REPEAT_ENABLE)
927 if (ab_repeat_mode_enabled())
929 ab_set_B_marker(wps_state
.id3
->elapsed
);
930 ab_jump_to_A_marker();
938 case ACTION_WPS_ABSETA_PREVDIR
:
939 if (global_settings
.party_mode
)
941 #if defined(AB_REPEAT_ENABLE)
942 if (ab_repeat_mode_enabled())
943 ab_set_A_marker(wps_state
.id3
->elapsed
);
950 /* menu key functions */
951 case ACTION_WPS_MENU
:
957 #ifdef HAVE_QUICKSCREEN
958 case ACTION_WPS_QUICKSCREEN
:
961 if (quick_screen_quick(button
))
966 #endif /* HAVE_QUICKSCREEN */
968 /* screen settings */
973 if (quick_screen_f3(BUTTON_F3
))
978 #endif /* BUTTON_F3 */
981 #ifdef HAVE_PITCHSCREEN
982 case ACTION_WPS_PITCHSCREEN
:
985 if (1 == gui_syncpitchscreen_run())
990 #endif /* HAVE_PITCHSCREEN */
992 #ifdef AB_REPEAT_ENABLE
993 /* reset A&B markers */
994 case ACTION_WPS_ABRESET
:
995 if (ab_repeat_mode_enabled())
1001 #endif /* AB_REPEAT_ENABLE */
1003 /* stop and exit wps */
1004 case ACTION_WPS_STOP
:
1005 if (global_settings
.party_mode
)
1011 case ACTION_WPS_ID3SCREEN
:
1019 #ifdef HAVE_TOUCHSCREEN
1020 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
1022 global_settings
.playlist_shuffle
=
1023 !global_settings
.playlist_shuffle
;
1024 #if CONFIG_CODEC == SWCODEC
1025 dsp_set_replaygain();
1027 if (global_settings
.playlist_shuffle
)
1028 playlist_randomise(NULL
, current_tick
, true);
1030 playlist_sort(NULL
, true);
1033 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1035 const struct settings_list
*rep_setting
=
1036 find_setting(&global_settings
.repeat_mode
, NULL
);
1037 option_select_next_val(rep_setting
, false, true);
1038 audio_flush_and_reload_tracks();
1041 #endif /* HAVE_TOUCHSCREEN */
1042 /* this case is used by the softlock feature
1043 * it requests a full update here */
1045 wps_sync_data
.do_full_update
= true;
1047 case ACTION_NONE
: /* Timeout, do a partial update */
1049 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1051 #ifdef HAVE_RECORDING
1052 case ACTION_WPS_REC
:
1057 default_event_handler(SYS_POWEROFF
);
1059 case ACTION_WPS_VIEW_PLAYLIST
:
1061 return GO_TO_PLAYLIST_VIEWER
;
1064 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
1076 vol_changed
= false;
1080 if(update_onvol_change(&gui_wps
[i
]))
1085 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
1091 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1092 TIME_AFTER(current_tick
, restoretimer
)))
1095 restoretimer
= RESTORE_WPS_INSTANTLY
;
1096 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1097 add_event(LCD_EVENT_ACTIVATION
, false, wps_lcd_activation_hook
);
1099 /* we remove the update delay since it's not very usable in the wps,
1100 * e.g. during volume changing or ffwd/rewind */
1101 sb_skin_set_update_delay(0);
1102 wps_sync_data
.do_full_update
= update
= false;
1105 else if (wps_sync_data
.do_full_update
|| update
)
1107 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1108 gwps_caption_backlight(&wps_state
);
1112 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1113 /* currently, all remotes are readable without backlight
1114 * so still update those */
1115 if (lcd_active() || (i
!= SCREEN_MAIN
))
1118 skin_update(&gui_wps
[i
], wps_sync_data
.do_full_update
?
1119 WPS_REFRESH_ALL
: WPS_REFRESH_NON_STATIC
);
1122 wps_sync_data
.do_full_update
= false;
1127 #ifdef HAVE_LCD_CHARCELLS
1128 status_set_record(false);
1129 status_set_audio(false);
1131 if (global_settings
.fade_on_stop
)
1135 bookmark_autobookmark(true);
1137 #ifdef AB_REPEAT_ENABLE
1141 #ifdef HAVE_RECORDING
1142 if (button
== ACTION_WPS_REC
)
1143 return GO_TO_RECSCREEN
;
1145 if (global_settings
.browse_current
)
1146 return GO_TO_PREVIOUS_BROWSER
;
1147 return GO_TO_PREVIOUS
;
1150 if (button
&& !IS_SYSEVENT(button
) )
1153 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1156 /* this is called from the playback thread so NO DRAWING! */
1157 static void track_changed_callback(void *param
)
1159 wps_state
.id3
= (struct mp3entry
*)param
;
1160 wps_state
.nid3
= audio_next_track();
1161 if (wps_state
.id3
->cuesheet
)
1163 cue_find_current_track(wps_state
.id3
->cuesheet
, wps_state
.id3
->elapsed
);
1165 wps_sync_data
.do_full_update
= true;
1167 static void nextid3available_callback(void* param
)
1170 wps_state
.nid3
= audio_next_track();
1171 wps_sync_data
.do_full_update
= true;
1175 static void wps_state_init(void)
1177 wps_state
.ff_rewind
= false;
1178 wps_state
.paused
= false;
1179 if(audio_status() & AUDIO_STATUS_PLAY
)
1181 wps_state
.id3
= audio_current_track();
1182 wps_state
.nid3
= audio_next_track();
1186 wps_state
.id3
= NULL
;
1187 wps_state
.nid3
= NULL
;
1189 /* We'll be updating due to restore initialized with true */
1190 wps_sync_data
.do_full_update
= false;
1191 /* add the WPS track event callbacks */
1192 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1193 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1197 void gui_sync_wps_init(void)
1202 #ifdef HAVE_ALBUMART
1203 wps_datas
[i
].albumart
= NULL
;
1204 wps_datas
[i
].playback_aa_slot
= -1;
1206 gui_wps
[i
].data
= &wps_datas
[i
];
1207 gui_wps
[i
].display
= &screens
[i
];
1208 /* Currently no seperate wps_state needed/possible
1209 so use the only available ( "global" ) one */
1210 gui_wps
[i
].state
= &wps_state
;
1211 /* must point to the same struct for both screens */
1212 gui_wps
[i
].sync_data
= &wps_sync_data
;
1217 #ifdef IPOD_ACCESSORY_PROTOCOL
1218 bool is_wps_fading(void)
1220 return wps_state
.is_fading
;
1223 int wps_get_ff_rewind_count(void)
1225 return wps_state
.ff_rewind_count
;