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
], SKIN_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
], SKIN_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
, SKIN_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 static int skintouch_to_wps(struct wps_data
*data
)
230 struct touchregion
*region
;
231 int button
= skin_get_touchaction(data
, &offset
, ®ion
);
234 case ACTION_STD_PREV
:
235 return ACTION_WPS_SKIPPREV
;
236 case ACTION_STD_PREVREPEAT
:
237 return ACTION_WPS_SEEKBACK
;
238 case ACTION_STD_NEXT
:
239 return ACTION_WPS_SKIPNEXT
;
240 case ACTION_STD_NEXTREPEAT
:
241 return ACTION_WPS_SEEKFWD
;
242 case ACTION_STD_MENU
:
243 return ACTION_WPS_MENU
;
244 case ACTION_STD_CONTEXT
:
245 return ACTION_WPS_CONTEXT
;
246 case ACTION_STD_QUICKSCREEN
:
247 return ACTION_WPS_QUICKSCREEN
;
249 case ACTION_STD_HOTKEY
:
250 return ACTION_WPS_HOTKEY
;
252 case WPS_TOUCHREGION_SCROLLBAR
:
253 wps_state
.id3
->elapsed
= wps_state
.id3
->length
*offset
/100;
254 if (!wps_state
.paused
)
255 #if (CONFIG_CODEC == SWCODEC)
256 audio_pre_ff_rewind();
260 audio_ff_rewind(wps_state
.id3
->elapsed
);
261 #if (CONFIG_CODEC != SWCODEC)
262 if (!wps_state
.paused
)
265 return ACTION_TOUCHSCREEN
;
266 case WPS_TOUCHREGION_VOLUME
:
268 const int min_vol
= sound_min(SOUND_VOLUME
);
269 const int max_vol
= sound_max(SOUND_VOLUME
);
270 global_settings
.volume
= (offset
* (max_vol
- min_vol
)) / 100;
271 global_settings
.volume
+= min_vol
;
274 return ACTION_TOUCHSCREEN
;
275 case ACTION_SETTINGS_INC
:
276 case ACTION_SETTINGS_DEC
:
278 const struct settings_list
*setting
= region
->extradata
;
279 option_select_next_val(setting
, button
== ACTION_SETTINGS_DEC
, true);
281 return ACTION_REDRAW
;
285 #endif /* HAVE_TOUCHSCREEN */
287 bool ffwd_rew(int button
)
289 unsigned int step
= 0; /* current ff/rewind step */
290 unsigned int max_step
= 0; /* maximum ff/rewind step */
291 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
292 int direction
= -1; /* forward=1 or backward=-1 */
296 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
298 if (button
== ACTION_NONE
)
300 status_set_ffmode(0);
307 case ACTION_WPS_SEEKFWD
:
309 case ACTION_WPS_SEEKBACK
:
310 if (wps_state
.ff_rewind
)
314 /* fast forwarding, calc max step relative to end */
315 max_step
= (wps_state
.id3
->length
-
316 (wps_state
.id3
->elapsed
+
318 FF_REWIND_MAX_PERCENT
/ 100;
322 /* rewinding, calc max step relative to start */
323 max_step
= (wps_state
.id3
->elapsed
+ ff_rewind_count
) *
324 FF_REWIND_MAX_PERCENT
/ 100;
327 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
332 ff_rewind_count
+= step
* direction
;
334 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
335 step
+= step
>> ff_rw_accel
;
339 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
340 wps_state
.id3
&& wps_state
.id3
->length
)
342 if (!wps_state
.paused
)
343 #if (CONFIG_CODEC == SWCODEC)
344 audio_pre_ff_rewind();
348 #if CONFIG_KEYPAD == PLAYER_PAD
350 gui_wps
[i
].display
->stop_scroll();
353 status_set_ffmode(STATUS_FASTFORWARD
);
355 status_set_ffmode(STATUS_FASTBACKWARD
);
357 wps_state
.ff_rewind
= true;
359 step
= 1000 * global_settings
.ff_rewind_min_step
;
366 if ((wps_state
.id3
->elapsed
+ ff_rewind_count
) >
367 wps_state
.id3
->length
)
368 ff_rewind_count
= wps_state
.id3
->length
-
369 wps_state
.id3
->elapsed
;
372 if ((int)(wps_state
.id3
->elapsed
+ ff_rewind_count
) < 0)
373 ff_rewind_count
= -wps_state
.id3
->elapsed
;
376 /* set the wps state ff_rewind_count so the progess info
378 wps_state
.ff_rewind_count
= (wps_state
.wps_time_countup
== false)?
379 ff_rewind_count
:-ff_rewind_count
;
382 skin_update(&gui_wps
[i
],
383 SKIN_REFRESH_PLAYER_PROGRESS
|
384 SKIN_REFRESH_DYNAMIC
);
389 case ACTION_WPS_STOPSEEK
:
390 wps_state
.id3
->elapsed
= wps_state
.id3
->elapsed
+ff_rewind_count
;
391 audio_ff_rewind(wps_state
.id3
->elapsed
);
392 wps_state
.ff_rewind_count
= 0;
393 wps_state
.ff_rewind
= false;
394 status_set_ffmode(0);
395 #if (CONFIG_CODEC != SWCODEC)
396 if (!wps_state
.paused
)
399 #ifdef HAVE_LCD_CHARCELLS
401 skin_update(&gui_wps
[i
], SKIN_REFRESH_ALL
);
407 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
408 status_set_ffmode(0);
416 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
417 #ifdef HAVE_TOUCHSCREEN
418 if (button
== ACTION_TOUCHSCREEN
)
419 button
= skintouch_to_wps(gui_wps
[SCREEN_MAIN
].data
);
420 if (button
!= ACTION_WPS_SEEKFWD
&&
421 button
!= ACTION_WPS_SEEKBACK
)
422 button
= ACTION_WPS_STOPSEEK
;
430 void display_keylock_text(bool locked
)
434 gui_wps
[i
].display
->stop_scroll();
436 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
442 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
443 static void gwps_caption_backlight(struct wps_state
*state
)
445 if (state
&& state
->id3
)
447 #ifdef HAVE_BACKLIGHT
448 if (global_settings
.caption_backlight
)
450 /* turn on backlight n seconds before track ends, and turn it off n
451 seconds into the new track. n == backlight_timeout, or 5s */
452 int n
= global_settings
.backlight_timeout
* 1000;
455 n
= 5000; /* use 5s if backlight is always on or off */
457 if (((state
->id3
->elapsed
< 1000) ||
458 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
459 (state
->paused
== false))
463 #ifdef HAVE_REMOTE_LCD
464 if (global_settings
.remote_caption_backlight
)
466 /* turn on remote backlight n seconds before track ends, and turn it
467 off n seconds into the new track. n == remote_backlight_timeout,
469 int n
= global_settings
.remote_backlight_timeout
* 1000;
472 n
= 5000; /* use 5s if backlight is always on or off */
474 if (((state
->id3
->elapsed
< 1000) ||
475 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
476 (state
->paused
== false))
477 remote_backlight_on();
485 static void change_dir(int direction
)
487 if (global_settings
.prevent_skip
)
492 else if (direction
> 0)
494 /* prevent the next dir to immediatly start being ffw'd */
495 action_wait_for_release();
498 static void prev_track(unsigned long skip_thresh
)
500 if (wps_state
.id3
->elapsed
< skip_thresh
)
507 if (wps_state
.id3
->cuesheet
)
509 curr_cuesheet_skip(wps_state
.id3
->cuesheet
, -1, wps_state
.id3
->elapsed
);
513 if (!wps_state
.paused
)
514 #if (CONFIG_CODEC == SWCODEC)
515 audio_pre_ff_rewind();
522 #if (CONFIG_CODEC != SWCODEC)
523 if (!wps_state
.paused
)
529 static void next_track(void)
531 /* take care of if we're playing a cuesheet */
532 if (wps_state
.id3
->cuesheet
)
534 if (curr_cuesheet_skip(wps_state
.id3
->cuesheet
, 1, wps_state
.id3
->elapsed
))
536 /* if the result was false, then we really want
537 to skip to the next track */
545 static void play_hop(int direction
)
547 long step
= global_settings
.skip_length
*1000;
548 long elapsed
= wps_state
.id3
->elapsed
;
549 long remaining
= wps_state
.id3
->length
- elapsed
;
555 prev_track(DEFAULT_SKIP_TRESH
);
558 else if (remaining
< DEFAULT_SKIP_TRESH
*2)
564 elapsed
+= (remaining
- DEFAULT_SKIP_TRESH
*2);
566 else if (!global_settings
.prevent_skip
&&
568 (direction
> 0 && step
>= remaining
) ||
569 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
570 { /* Do normal track skipping */
573 else if (direction
< 0)
574 prev_track(DEFAULT_SKIP_TRESH
);
577 else if (direction
== 1 && step
>= remaining
)
579 #if CONFIG_CODEC == SWCODEC
580 if(global_settings
.beep
)
581 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
585 else if ((direction
== -1 && elapsed
< step
))
591 elapsed
+= step
* direction
;
593 if((audio_status() & AUDIO_STATUS_PLAY
) && !wps_state
.paused
)
595 #if (CONFIG_CODEC == SWCODEC)
596 audio_pre_ff_rewind();
601 audio_ff_rewind(wps_state
.id3
->elapsed
= elapsed
);
602 #if (CONFIG_CODEC != SWCODEC)
603 if (!wps_state
.paused
)
609 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
611 * If the user is unable to see the wps, because the display is deactivated,
612 * we suppress updates until the wps is activated again (the lcd driver will
613 * call this hook to issue an instant update)
615 static void wps_lcd_activation_hook(void *param
)
618 wps_sync_data
.do_full_update
= true;
619 /* force timeout in wps main loop, so that the update is instantly */
620 queue_post(&button_queue
, BUTTON_NONE
, 0);
624 static void gwps_leave_wps(void)
630 gui_wps
[i
].display
->stop_scroll();
631 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
632 gui_wps
[i
].display
->backdrop_show(sb_get_backdrop(i
));
634 viewportmanager_theme_undo(i
, skin_has_sbs(i
, gui_wps
[i
].data
));
638 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
639 /* Play safe and unregister the hook */
640 remove_event(LCD_EVENT_ACTIVATION
, wps_lcd_activation_hook
);
642 /* unhandle statusbar update delay */
643 sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY
);
644 #ifdef HAVE_TOUCHSCREEN
645 touchscreen_set_mode(global_settings
.touch_mode
);
650 * display the wps on entering or restoring */
651 static void gwps_enter_wps(void)
656 struct gui_wps
*gwps
= &gui_wps
[i
];
657 struct screen
*display
= gwps
->display
;
658 display
->stop_scroll();
659 viewportmanager_theme_enable(i
, skin_has_sbs(i
, gui_wps
[i
].data
), NULL
);
661 /* Update the values in the first (default) viewport - in case the user
662 has modified the statusbar or colour settings */
664 if (display
->depth
> 1)
666 struct skin_viewport
*svp
= find_viewport(VP_DEFAULT_LABEL
,
670 struct viewport
*vp
= &svp
->vp
;
671 vp
->fg_pattern
= display
->get_foreground();
672 vp
->bg_pattern
= display
->get_background();
676 /* make the backdrop actually take effect */
677 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
678 display
->backdrop_show(gwps
->data
->backdrop
);
680 display
->clear_display();
681 skin_update(gwps
, SKIN_REFRESH_ALL
);
684 #ifdef HAVE_TOUCHSCREEN
685 skin_disarm_touchregions(gui_wps
[SCREEN_MAIN
].data
);
686 if (!gui_wps
[SCREEN_MAIN
].data
->touchregions
)
687 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
689 /* force statusbar/skin update since we just cleared the whole screen */
690 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
693 /* The WPS can be left in two ways:
694 * a) call a function, which draws over the wps. In this case, the wps
695 * will be still active (i.e. the below function didn't return)
696 * b) return with a value evaluated by root_menu.c, in this case the wps
697 * is really left, and root_menu will handle the next screen
699 * In either way, call gwps_leave_wps(), in order to restore the correct
700 * "main screen" backdrops and statusbars
702 long gui_wps_show(void)
706 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
708 bool bookmark
= false;
710 bool vol_changed
= false;
712 long last_left
= 0, last_right
= 0;
714 #ifdef HAVE_LCD_CHARCELLS
715 status_set_audio(true);
716 status_set_param(false);
719 #ifdef AB_REPEAT_ENABLE
727 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
729 /* did someone else (i.e power thread) change audio pause mode? */
730 if (wps_state
.paused
!= audio_paused
) {
731 wps_state
.paused
= audio_paused
;
733 /* if another thread paused audio, we are probably in car mode,
734 about to shut down. lets save the settings. */
735 if (wps_state
.paused
) {
737 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
738 call_storage_idle_notifys(true);
742 button
= skin_wait_for_action(gui_wps
, CONTEXT_WPS
|ALLOW_SOFTLOCK
,
745 /* Exit if audio has stopped playing. This happens e.g. at end of
746 playlist or if using the sleep timer. */
747 if (!(audio_status() & AUDIO_STATUS_PLAY
))
749 #ifdef HAVE_TOUCHSCREEN
750 if (button
== ACTION_TOUCHSCREEN
)
751 button
= skintouch_to_wps(gui_wps
[SCREEN_MAIN
].data
);
753 /* The iPods/X5/M5 use a single button for the A-B mode markers,
754 defined as ACTION_WPSAB_SINGLE in their config files. */
755 #ifdef ACTION_WPSAB_SINGLE
756 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
758 static int wps_ab_state
= 0;
759 if (button
== ACTION_WPSAB_SINGLE
)
761 switch (wps_ab_state
)
763 case 0: /* set the A spot */
764 button
= ACTION_WPS_ABSETA_PREVDIR
;
766 case 1: /* set the B spot */
767 button
= ACTION_WPS_ABSETB_NEXTDIR
;
770 button
= ACTION_WPS_ABRESET
;
773 wps_ab_state
= (wps_ab_state
+1) % 3;
780 case ACTION_WPS_HOTKEY
:
781 if (!global_settings
.hotkey_wps
)
785 case ACTION_WPS_CONTEXT
:
787 bool hotkey
= button
== ACTION_WPS_HOTKEY
;
789 int retval
= onplay(wps_state
.id3
->path
,
790 FILE_ATTR_AUDIO
, CONTEXT_WPS
, hotkey
);
791 /* if music is stopped in the context menu we want to exit the wps */
792 if (retval
== ONPLAY_MAINMENU
795 else if (retval
== ONPLAY_PLAYLIST
)
796 return GO_TO_PLAYLIST_VIEWER
;
797 #ifdef HAVE_PICTUREFLOW_INTEGRATION
798 else if (retval
== ONPLAY_PICTUREFLOW
)
799 return GO_TO_PICTUREFLOW
;
805 case ACTION_WPS_BROWSE
:
806 #ifdef HAVE_LCD_CHARCELLS
807 status_set_record(false);
808 status_set_audio(false);
811 return GO_TO_PREVIOUS_BROWSER
;
815 case ACTION_WPS_PLAY
:
816 if (global_settings
.party_mode
)
818 if ( wps_state
.paused
)
820 wps_state
.paused
= false;
821 if ( global_settings
.fade_on_stop
)
828 wps_state
.paused
= true;
829 if ( global_settings
.fade_on_stop
)
834 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
835 call_storage_idle_notifys(true); /* make sure resume info is saved */
840 case ACTION_WPS_VOLUP
:
841 global_settings
.volume
++;
844 case ACTION_WPS_VOLDOWN
:
845 global_settings
.volume
--;
849 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
850 case ACTION_WPS_SEEKFWD
:
851 if (global_settings
.party_mode
)
853 if (current_tick
-last_right
< HZ
)
855 if (wps_state
.id3
->cuesheet
)
865 ffwd_rew(ACTION_WPS_SEEKFWD
);
866 last_right
= last_left
= 0;
869 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
870 case ACTION_WPS_SEEKBACK
:
871 if (global_settings
.party_mode
)
873 if (current_tick
-last_left
< HZ
)
875 if (wps_state
.id3
->cuesheet
)
877 if (!wps_state
.paused
)
878 #if (CONFIG_CODEC == SWCODEC)
879 audio_pre_ff_rewind();
891 ffwd_rew(ACTION_WPS_SEEKBACK
);
892 last_left
= last_right
= 0;
896 case ACTION_WPS_SKIPPREV
:
897 if (global_settings
.party_mode
)
899 last_left
= current_tick
;
900 #ifdef AB_REPEAT_ENABLE
901 /* if we're in A/B repeat mode and the current position
902 is past the A marker, jump back to the A marker... */
903 if ( ab_repeat_mode_enabled() )
905 if ( ab_after_A_marker(wps_state
.id3
->elapsed
) )
907 ab_jump_to_A_marker();
912 /* ...otherwise, do it normally */
918 OR if skip length set, hop by predetermined amount. */
919 case ACTION_WPS_SKIPNEXT
:
920 if (global_settings
.party_mode
)
922 last_right
= current_tick
;
923 #ifdef AB_REPEAT_ENABLE
924 /* if we're in A/B repeat mode and the current position is
925 before the A marker, jump to the A marker... */
926 if ( ab_repeat_mode_enabled() )
928 if ( ab_before_A_marker(wps_state
.id3
->elapsed
) )
930 ab_jump_to_A_marker();
935 /* ...otherwise, do it normally */
939 /* next / prev directories */
940 /* and set A-B markers if in a-b mode */
941 case ACTION_WPS_ABSETB_NEXTDIR
:
942 if (global_settings
.party_mode
)
944 #if defined(AB_REPEAT_ENABLE)
945 if (ab_repeat_mode_enabled())
947 ab_set_B_marker(wps_state
.id3
->elapsed
);
948 ab_jump_to_A_marker();
956 case ACTION_WPS_ABSETA_PREVDIR
:
957 if (global_settings
.party_mode
)
959 #if defined(AB_REPEAT_ENABLE)
960 if (ab_repeat_mode_enabled())
961 ab_set_A_marker(wps_state
.id3
->elapsed
);
968 /* menu key functions */
969 case ACTION_WPS_MENU
:
975 #ifdef HAVE_QUICKSCREEN
976 case ACTION_WPS_QUICKSCREEN
:
979 if (quick_screen_quick(button
))
984 #endif /* HAVE_QUICKSCREEN */
986 /* screen settings */
991 if (quick_screen_f3(BUTTON_F3
))
996 #endif /* BUTTON_F3 */
999 #ifdef HAVE_PITCHSCREEN
1000 case ACTION_WPS_PITCHSCREEN
:
1003 if (1 == gui_syncpitchscreen_run())
1008 #endif /* HAVE_PITCHSCREEN */
1010 #ifdef AB_REPEAT_ENABLE
1011 /* reset A&B markers */
1012 case ACTION_WPS_ABRESET
:
1013 if (ab_repeat_mode_enabled())
1019 #endif /* AB_REPEAT_ENABLE */
1021 /* stop and exit wps */
1022 case ACTION_WPS_STOP
:
1023 if (global_settings
.party_mode
)
1029 case ACTION_WPS_ID3SCREEN
:
1037 #ifdef HAVE_TOUCHSCREEN
1038 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
1040 global_settings
.playlist_shuffle
=
1041 !global_settings
.playlist_shuffle
;
1042 #if CONFIG_CODEC == SWCODEC
1043 dsp_set_replaygain();
1045 if (global_settings
.playlist_shuffle
)
1046 playlist_randomise(NULL
, current_tick
, true);
1048 playlist_sort(NULL
, true);
1051 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1053 const struct settings_list
*rep_setting
=
1054 find_setting(&global_settings
.repeat_mode
, NULL
);
1055 option_select_next_val(rep_setting
, false, true);
1056 audio_flush_and_reload_tracks();
1059 #endif /* HAVE_TOUCHSCREEN */
1060 /* this case is used by the softlock feature
1061 * it requests a full update here */
1063 wps_sync_data
.do_full_update
= true;
1065 case ACTION_NONE
: /* Timeout, do a partial update */
1067 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1069 #ifdef HAVE_RECORDING
1070 case ACTION_WPS_REC
:
1075 default_event_handler(SYS_POWEROFF
);
1077 case ACTION_WPS_VIEW_PLAYLIST
:
1079 return GO_TO_PLAYLIST_VIEWER
;
1082 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
1094 vol_changed
= false;
1098 if(update_onvol_change(&gui_wps
[i
]))
1103 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
1109 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1110 TIME_AFTER(current_tick
, restoretimer
)))
1113 restoretimer
= RESTORE_WPS_INSTANTLY
;
1114 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1115 add_event(LCD_EVENT_ACTIVATION
, false, wps_lcd_activation_hook
);
1117 /* we remove the update delay since it's not very usable in the wps,
1118 * e.g. during volume changing or ffwd/rewind */
1119 sb_skin_set_update_delay(0);
1120 wps_sync_data
.do_full_update
= update
= false;
1123 else if (wps_sync_data
.do_full_update
|| update
)
1125 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1126 gwps_caption_backlight(&wps_state
);
1128 bool full_update
= wps_sync_data
.do_full_update
;
1131 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1132 /* currently, all remotes are readable without backlight
1133 * so still update those */
1134 if (lcd_active() || (i
!= SCREEN_MAIN
))
1138 if (i
==SCREEN_MAIN
&& wps_sync_data
.do_full_update
)
1140 wps_sync_data
.do_full_update
= false;
1144 wps_sync_data
.do_full_update
= false;
1146 skin_update(&gui_wps
[i
], full_update
?
1147 SKIN_REFRESH_ALL
: SKIN_REFRESH_NON_STATIC
);
1154 #ifdef HAVE_LCD_CHARCELLS
1155 status_set_record(false);
1156 status_set_audio(false);
1158 if (global_settings
.fade_on_stop
)
1162 bookmark_autobookmark(true);
1164 #ifdef AB_REPEAT_ENABLE
1168 #ifdef HAVE_RECORDING
1169 if (button
== ACTION_WPS_REC
)
1170 return GO_TO_RECSCREEN
;
1172 if (global_settings
.browse_current
)
1173 return GO_TO_PREVIOUS_BROWSER
;
1174 return GO_TO_PREVIOUS
;
1177 if (button
&& !IS_SYSEVENT(button
) )
1180 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1183 /* this is called from the playback thread so NO DRAWING! */
1184 static void track_changed_callback(void *param
)
1186 wps_state
.id3
= (struct mp3entry
*)param
;
1187 wps_state
.nid3
= audio_next_track();
1188 if (wps_state
.id3
->cuesheet
)
1190 cue_find_current_track(wps_state
.id3
->cuesheet
, wps_state
.id3
->elapsed
);
1192 wps_sync_data
.do_full_update
= true;
1194 static void nextid3available_callback(void* param
)
1197 wps_state
.nid3
= audio_next_track();
1198 wps_sync_data
.do_full_update
= true;
1202 static void wps_state_init(void)
1204 wps_state
.ff_rewind
= false;
1205 wps_state
.paused
= false;
1206 if(audio_status() & AUDIO_STATUS_PLAY
)
1208 wps_state
.id3
= audio_current_track();
1209 wps_state
.nid3
= audio_next_track();
1213 wps_state
.id3
= NULL
;
1214 wps_state
.nid3
= NULL
;
1216 /* We'll be updating due to restore initialized with true */
1217 wps_sync_data
.do_full_update
= false;
1218 /* add the WPS track event callbacks */
1219 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1220 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1224 void gui_sync_wps_init(void)
1229 #ifdef HAVE_ALBUMART
1230 wps_datas
[i
].albumart
= NULL
;
1231 wps_datas
[i
].playback_aa_slot
= -1;
1233 gui_wps
[i
].data
= &wps_datas
[i
];
1234 gui_wps
[i
].display
= &screens
[i
];
1235 /* Currently no seperate wps_state needed/possible
1236 so use the only available ( "global" ) one */
1237 gui_wps
[i
].state
= &wps_state
;
1238 /* must point to the same struct for both screens */
1239 gui_wps
[i
].sync_data
= &wps_sync_data
;
1244 #ifdef IPOD_ACCESSORY_PROTOCOL
1245 bool is_wps_fading(void)
1247 return wps_state
.is_fading
;
1250 int wps_get_ff_rewind_count(void)
1252 return wps_state
.ff_rewind_count
;