summaryrefslogtreecommitdiff
path: root/apps/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/wps.c')
-rw-r--r--apps/wps.c882
1 files changed, 0 insertions, 882 deletions
diff --git a/apps/wps.c b/apps/wps.c
deleted file mode 100644
index 573444fdc4..0000000000
--- a/apps/wps.c
+++ /dev/null
@@ -1,882 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Jerome Kuptz
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include <stdio.h>
20#include <string.h>
21#include <stdlib.h>
22
23#include "system.h"
24#include "file.h"
25#include "lcd.h"
26#include "font.h"
27#include "backlight.h"
28#include "button.h"
29#include "kernel.h"
30#include "tree.h"
31#include "debug.h"
32#include "sprintf.h"
33#include "settings.h"
34#include "wps.h"
35#include "wps-display.h"
36#include "audio.h"
37#include "mp3_playback.h"
38#include "usb.h"
39#include "status.h"
40#include "main_menu.h"
41#include "ata.h"
42#include "screens.h"
43#include "playlist.h"
44#ifdef HAVE_LCD_BITMAP
45#include "icons.h"
46#include "peakmeter.h"
47#endif
48#include "action.h"
49#include "lang.h"
50#include "bookmark.h"
51#include "misc.h"
52#include "sound.h"
53#include "onplay.h"
54#include "abrepeat.h"
55#include "playback.h"
56#include "splash.h"
57
58#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
59 /* 3% of 30min file == 54s step size */
60#define MIN_FF_REWIND_STEP 500
61
62bool keys_locked = false;
63static bool ff_rewind = false;
64static bool paused = false;
65static struct mp3entry* id3 = NULL;
66static struct mp3entry* nid3 = NULL;
67static char current_track_path[MAX_PATH+1];
68
69/* set volume
70 return true if screen restore is needed
71 return false otherwise
72*/
73static bool setvol(void)
74{
75 if (global_settings.volume < sound_min(SOUND_VOLUME))
76 global_settings.volume = sound_min(SOUND_VOLUME);
77 if (global_settings.volume > sound_max(SOUND_VOLUME))
78 global_settings.volume = sound_max(SOUND_VOLUME);
79 sound_set_volume(global_settings.volume);
80 status_draw(false);
81 wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
82 settings_save();
83#ifdef HAVE_LCD_CHARCELLS
84 gui_syncsplash(0, false, "Vol: %d %% ",
85 sound_val2phys(SOUND_VOLUME, global_settings.volume));
86 return true;
87#endif
88 return false;
89}
90
91static bool ffwd_rew(int button)
92{
93 static const int ff_rew_steps[] = {
94 1000, 2000, 3000, 4000,
95 5000, 6000, 8000, 10000,
96 15000, 20000, 25000, 30000,
97 45000, 60000
98 };
99
100 unsigned int step = 0; /* current ff/rewind step */
101 unsigned int max_step = 0; /* maximum ff/rewind step */
102 int ff_rewind_count = 0; /* current ff/rewind count (in ticks) */
103 int direction = -1; /* forward=1 or backward=-1 */
104 long accel_tick = 0; /* next time at which to bump the step size */
105 bool exit = false;
106 bool usb = false;
107
108 while (!exit) {
109 switch ( button ) {
110 case WPS_FFWD:
111#ifdef WPS_RC_FFWD
112 case WPS_RC_FFWD:
113#endif
114 direction = 1;
115 case WPS_REW:
116#ifdef WPS_RC_REW
117 case WPS_RC_REW:
118#endif
119 if (ff_rewind)
120 {
121 if (direction == 1)
122 {
123 /* fast forwarding, calc max step relative to end */
124 max_step =
125 (id3->length - (id3->elapsed + ff_rewind_count)) *
126 FF_REWIND_MAX_PERCENT / 100;
127 }
128 else
129 {
130 /* rewinding, calc max step relative to start */
131 max_step = (id3->elapsed + ff_rewind_count) *
132 FF_REWIND_MAX_PERCENT / 100;
133 }
134
135 max_step = MAX(max_step, MIN_FF_REWIND_STEP);
136
137 if (step > max_step)
138 step = max_step;
139
140 ff_rewind_count += step * direction;
141
142 if (global_settings.ff_rewind_accel != 0 &&
143 current_tick >= accel_tick)
144 {
145 step *= 2;
146 accel_tick = current_tick +
147 global_settings.ff_rewind_accel*HZ;
148 }
149 }
150 else
151 {
152 if ( (audio_status() & AUDIO_STATUS_PLAY) &&
153 id3 && id3->length )
154 {
155 if (!paused)
156 audio_pause();
157#if CONFIG_KEYPAD == PLAYER_PAD
158 lcd_stop_scroll();
159#endif
160 if (direction > 0)
161 status_set_ffmode(STATUS_FASTFORWARD);
162 else
163 status_set_ffmode(STATUS_FASTBACKWARD);
164
165 ff_rewind = true;
166
167 step = ff_rew_steps[global_settings.ff_rewind_min_step];
168
169 accel_tick = current_tick +
170 global_settings.ff_rewind_accel*HZ;
171 }
172 else
173 break;
174 }
175
176 if (direction > 0) {
177 if ((id3->elapsed + ff_rewind_count) > id3->length)
178 ff_rewind_count = id3->length - id3->elapsed;
179 }
180 else {
181 if ((int)(id3->elapsed + ff_rewind_count) < 0)
182 ff_rewind_count = -id3->elapsed;
183 }
184
185 if(wps_time_countup == false)
186 wps_refresh(id3, nid3, -ff_rewind_count,
187 WPS_REFRESH_PLAYER_PROGRESS |
188 WPS_REFRESH_DYNAMIC);
189 else
190 wps_refresh(id3, nid3, ff_rewind_count,
191 WPS_REFRESH_PLAYER_PROGRESS |
192 WPS_REFRESH_DYNAMIC);
193
194 break;
195
196 case WPS_PREV:
197 case WPS_NEXT:
198#ifdef WPS_RC_PREV
199 case WPS_RC_PREV:
200 case WPS_RC_NEXT:
201#endif
202 audio_ff_rewind(id3->elapsed+ff_rewind_count);
203 ff_rewind_count = 0;
204 ff_rewind = false;
205 status_set_ffmode(0);
206 if (!paused)
207 audio_resume();
208#ifdef HAVE_LCD_CHARCELLS
209 wps_display(id3, nid3);
210#endif
211 exit = true;
212 break;
213
214 default:
215 if(default_event_handler(button) == SYS_USB_CONNECTED) {
216 status_set_ffmode(0);
217 usb = true;
218 exit = true;
219 }
220 break;
221 }
222 if (!exit)
223 button = button_get(true);
224 }
225
226 /* let audio thread update id3->elapsed before calling wps_refresh */
227 yield();
228 wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
229 return usb;
230}
231
232static bool update(void)
233{
234 bool track_changed = audio_has_changed_track();
235 bool retcode = false;
236
237 nid3 = audio_next_track();
238 if (track_changed)
239 {
240 lcd_stop_scroll();
241 id3 = audio_current_track();
242 if (wps_display(id3, nid3))
243 retcode = true;
244 else
245 wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
246
247 if (id3)
248 memcpy(current_track_path, id3->path, sizeof(current_track_path));
249 }
250
251 if (id3)
252 wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
253
254 status_draw(false);
255
256 return retcode;
257}
258
259static void fade(bool fade_in)
260{
261 unsigned fp_global_vol = global_settings.volume << 8;
262 unsigned fp_step = fp_global_vol / 30;
263
264 if (fade_in) {
265 /* fade in */
266 unsigned fp_volume = 0;
267
268 /* zero out the sound */
269 sound_set_volume(0);
270
271 sleep(HZ/10); /* let audio thread run */
272 audio_resume();
273
274 while (fp_volume < fp_global_vol) {
275 fp_volume += fp_step;
276 sleep(1);
277 sound_set_volume(fp_volume >> 8);
278 }
279 sound_set_volume(global_settings.volume);
280 }
281 else {
282 /* fade out */
283 unsigned fp_volume = fp_global_vol;
284
285 while (fp_volume > fp_step) {
286 fp_volume -= fp_step;
287 sleep(1);
288 sound_set_volume(fp_volume >> 8);
289 }
290 audio_pause();
291#ifndef SIMULATOR
292 /* let audio thread run and wait for the mas to run out of data */
293 while (!mp3_pause_done())
294#endif
295 sleep(HZ/10);
296
297 /* reset volume to what it was before the fade */
298 sound_set_volume(global_settings.volume);
299 }
300}
301
302
303#ifdef WPS_KEYLOCK
304static void display_keylock_text(bool locked)
305{
306 char* s;
307 lcd_stop_scroll();
308#ifdef HAVE_LCD_CHARCELLS
309 if(locked)
310 s = str(LANG_KEYLOCK_ON_PLAYER);
311 else
312 s = str(LANG_KEYLOCK_OFF_PLAYER);
313#else
314 if(locked)
315 s = str(LANG_KEYLOCK_ON_RECORDER);
316 else
317 s = str(LANG_KEYLOCK_OFF_RECORDER);
318#endif
319 gui_syncsplash(HZ, true, s);
320}
321
322static void waitfor_nokey(void)
323{
324 /* wait until all keys are released */
325 while (button_get(false) != BUTTON_NONE)
326 yield();
327}
328#endif
329
330/* demonstrates showing different formats from playtune */
331long wps_show(void)
332{
333 long button = 0, lastbutton = 0;
334 bool ignore_keyup = true;
335 bool restore = false;
336 long restoretimer = 0; /* timer to delay screen redraw temporarily */
337 bool exit = false;
338 bool update_track = false;
339 unsigned long right_lastclick = 0;
340 unsigned long left_lastclick = 0;
341
342 id3 = nid3 = NULL;
343 current_track_path[0] = '\0';
344
345#ifdef HAVE_LCD_CHARCELLS
346 status_set_audio(true);
347 status_set_param(false);
348#else
349 if(global_settings.statusbar)
350 lcd_setmargins(0, STATUSBAR_HEIGHT);
351 else
352 lcd_setmargins(0, 0);
353#endif
354
355#ifdef AB_REPEAT_ENABLE
356 ab_repeat_init();
357 ab_reset_markers();
358#endif
359
360 ff_rewind = false;
361
362 if(audio_status() & AUDIO_STATUS_PLAY)
363 {
364 id3 = audio_current_track();
365 nid3 = audio_next_track();
366 if (id3) {
367 if (wps_display(id3, nid3))
368 return 0;
369 wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
370
371 memcpy(current_track_path, id3->path, sizeof(current_track_path));
372 }
373
374 restore = true;
375 }
376
377 while ( 1 )
378 {
379 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
380
381 /* did someone else (i.e power thread) change audio pause mode? */
382 if (paused != audio_paused) {
383 paused = audio_paused;
384
385 /* if another thread paused audio, we are probably in car mode,
386 about to shut down. lets save the settings. */
387 if (paused) {
388 settings_save();
389#if !defined(HAVE_RTC) && !defined(HAVE_SW_POWEROFF)
390 ata_flush();
391#endif
392 }
393 }
394
395#ifdef HAVE_LCD_BITMAP
396 /* when the peak meter is enabled we want to have a
397 few extra updates to make it look smooth. On the
398 other hand we don't want to waste energy if it
399 isn't displayed */
400 if (peak_meter_enabled) {
401 long next_refresh = current_tick;
402 long next_big_refresh = current_tick + HZ / 5;
403 button = BUTTON_NONE;
404 while (TIME_BEFORE(current_tick, next_big_refresh)) {
405 button = button_get(false);
406 if (button != BUTTON_NONE) {
407 break;
408 }
409 peak_meter_peek();
410 sleep(0); /* Sleep until end of current tick. */
411
412 if (TIME_AFTER(current_tick, next_refresh)) {
413 wps_refresh(id3, nid3, 0, WPS_REFRESH_PEAK_METER);
414 next_refresh += HZ / PEAK_METER_FPS;
415 }
416 }
417
418 }
419
420 /* The peak meter is disabled
421 -> no additional screen updates needed */
422 else {
423 button = button_get_w_tmo(HZ/5);
424 }
425#else
426 button = button_get_w_tmo(HZ/5);
427#endif
428
429 /* discard first event if it's a button release */
430 if (button && ignore_keyup)
431 {
432 ignore_keyup = false;
433 /* Negative events are system events */
434 if (button >= 0 && button & BUTTON_REL )
435 continue;
436 }
437
438#ifdef WPS_KEYLOCK
439 /* ignore non-remote buttons when keys are locked */
440 if (keys_locked &&
441 ! ((button < 0) ||
442 (button == BUTTON_NONE) ||
443 ((button & WPS_KEYLOCK) == WPS_KEYLOCK) ||
444 (button & BUTTON_REMOTE)
445 ))
446 {
447 if (!(button & BUTTON_REL))
448 display_keylock_text(true);
449 restore = true;
450 button = BUTTON_NONE;
451 }
452#endif
453
454 /* Exit if audio has stopped playing. This can happen if using the
455 sleep timer with the charger plugged or if starting a recording
456 from F1 */
457 if (!audio_status())
458 exit = true;
459
460 switch(button)
461 {
462#ifdef WPS_CONTEXT
463 case WPS_CONTEXT:
464 onplay(id3->path, TREE_ATTR_MPA, CONTEXT_WPS);
465 restore = true;
466 break;
467#endif
468
469#ifdef WPS_RC_BROWSE
470 case WPS_RC_BROWSE:
471#endif
472 case WPS_BROWSE:
473#ifdef WPS_BROWSE_PRE
474 if ((lastbutton != WPS_BROWSE_PRE)
475#ifdef WPS_RC_BROWSE_PRE
476 && (lastbutton != WPS_RC_BROWSE_PRE)
477#endif
478 )
479 break;
480#endif
481#ifdef HAVE_LCD_CHARCELLS
482 status_set_record(false);
483 status_set_audio(false);
484#endif
485 lcd_stop_scroll();
486
487 /* set dir browser to current playing song */
488 if (global_settings.browse_current &&
489 current_track_path[0] != '\0')
490 set_current_file(current_track_path);
491
492 return 0;
493 break;
494
495 /* play/pause */
496 case WPS_PAUSE:
497#ifdef WPS_PAUSE_PRE
498 if (lastbutton != WPS_PAUSE_PRE)
499 break;
500#endif
501#ifdef WPS_RC_PAUSE
502 case WPS_RC_PAUSE:
503#ifdef WPS_RC_PAUSE_PRE
504 if ((button == WPS_RC_PAUSE) && (lastbutton != WPS_RC_PAUSE_PRE))
505 break;
506#endif
507#endif
508 if ( paused )
509 {
510 paused = false;
511 if ( global_settings.fade_on_stop )
512 fade(1);
513 else
514 audio_resume();
515 }
516 else
517 {
518 paused = true;
519 if ( global_settings.fade_on_stop )
520 fade(0);
521 else
522 audio_pause();
523 settings_save();
524#if !defined(HAVE_RTC) && !defined(HAVE_SW_POWEROFF)
525 ata_flush(); /* make sure resume info is saved */
526#endif
527 }
528 break;
529
530 /* volume up */
531 case WPS_INCVOL:
532 case WPS_INCVOL | BUTTON_REPEAT:
533#ifdef WPS_RC_INCVOL
534 case WPS_RC_INCVOL:
535 case WPS_RC_INCVOL | BUTTON_REPEAT:
536#endif
537 global_settings.volume++;
538 if (setvol()) {
539 restore = true;
540 restoretimer = current_tick + HZ;
541 }
542 break;
543
544 /* volume down */
545 case WPS_DECVOL:
546 case WPS_DECVOL | BUTTON_REPEAT:
547#ifdef WPS_RC_DECVOL
548 case WPS_RC_DECVOL:
549 case WPS_RC_DECVOL | BUTTON_REPEAT:
550#endif
551 global_settings.volume--;
552 if (setvol()) {
553 restore = true;
554 restoretimer = current_tick + HZ;
555 }
556 break;
557
558 /* fast forward / rewind */
559#ifdef WPS_RC_FFWD
560 case WPS_RC_FFWD:
561#endif
562 case WPS_FFWD:
563#ifdef WPS_NEXT_DIR
564 if (current_tick - right_lastclick < HZ)
565 {
566 audio_next_dir();
567 right_lastclick = 0;
568 break;
569 }
570#endif
571#ifdef WPS_RC_REW
572 case WPS_RC_REW:
573#endif
574 case WPS_REW:
575#ifdef WPS_PREV_DIR
576 if (current_tick - left_lastclick < HZ)
577 {
578 audio_prev_dir();
579 left_lastclick = 0;
580 break;
581 }
582#endif
583 ffwd_rew(button);
584 break;
585
586 /* prev / restart */
587 case WPS_PREV:
588#ifdef WPS_PREV_PRE
589 if (lastbutton != WPS_PREV_PRE)
590 break;
591#endif
592#ifdef WPS_RC_PREV
593 case WPS_RC_PREV:
594#ifdef WPS_RC_PREV_PRE
595 if ((button == WPS_RC_PREV) && (lastbutton != WPS_RC_PREV_PRE))
596 break;
597#endif
598#endif
599 left_lastclick = current_tick;
600 update_track = true;
601
602#ifdef AB_REPEAT_ENABLE
603 /* if we're in A/B repeat mode and the current position
604 is past the A marker, jump back to the A marker... */
605 if ( ab_repeat_mode_enabled() && ab_after_A_marker(id3->elapsed) )
606 {
607 ab_jump_to_A_marker();
608 break;
609 }
610 /* ...otherwise, do it normally */
611#endif
612
613 if (!id3 || (id3->elapsed < 3*1000)) {
614 audio_prev();
615 }
616 else {
617 if (!paused)
618 audio_pause();
619
620 audio_ff_rewind(0);
621
622 if (!paused)
623 audio_resume();
624 }
625 break;
626
627#ifdef WPS_NEXT_DIR
628#ifdef WPS_RC_NEXT_DIR
629 case WPS_RC_NEXT_DIR:
630#endif
631 case WPS_NEXT_DIR:
632 audio_next_dir();
633 break;
634#endif
635#ifdef WPS_PREV_DIR
636#ifdef WPS_RC_PREV_DIR
637 case WPS_RC_PREV_DIR:
638#endif
639 case WPS_PREV_DIR:
640 audio_prev_dir();
641 break;
642#endif
643
644 /* next */
645 case WPS_NEXT:
646#ifdef WPS_NEXT_PRE
647 if (lastbutton != WPS_NEXT_PRE)
648 break;
649#endif
650#ifdef WPS_RC_NEXT
651 case WPS_RC_NEXT:
652#ifdef WPS_RC_NEXT_PRE
653 if ((button == WPS_RC_NEXT) && (lastbutton != WPS_RC_NEXT_PRE))
654 break;
655#endif
656#endif
657 right_lastclick = current_tick;
658 update_track = true;
659
660#ifdef AB_REPEAT_ENABLE
661 /* if we're in A/B repeat mode and the current position is
662 before the A marker, jump to the A marker... */
663 if ( ab_repeat_mode_enabled() && ab_before_A_marker(id3->elapsed) )
664 {
665 ab_jump_to_A_marker();
666 break;
667 }
668 /* ...otherwise, do it normally */
669#endif
670
671 audio_next();
672 break;
673
674#ifdef WPS_MENU
675 /* menu key functions */
676 case WPS_MENU:
677#ifdef WPS_MENU_PRE
678 if (lastbutton != WPS_MENU_PRE)
679 break;
680#endif
681#ifdef WPS_RC_MENU
682 case WPS_RC_MENU:
683#ifdef WPS_RC_MENU_PRE
684 if ((button == WPS_RC_MENU) && (lastbutton != WPS_RC_MENU_PRE))
685 break;
686#endif
687#endif
688 lcd_stop_scroll();
689
690 if (main_menu())
691 return true;
692#ifdef HAVE_LCD_BITMAP
693 if (global_settings.statusbar)
694 lcd_setmargins(0, STATUSBAR_HEIGHT);
695 else
696 lcd_setmargins(0, 0);
697#endif
698 restore = true;
699 break;
700#endif /* WPS_MENU */
701
702#ifdef WPS_KEYLOCK
703 /* key lock */
704 case WPS_KEYLOCK:
705 case WPS_KEYLOCK | BUTTON_REPEAT:
706 keys_locked = !keys_locked;
707 display_keylock_text(keys_locked);
708 restore = true;
709 waitfor_nokey();
710 break;
711#endif
712
713#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD)
714 /* play settings */
715 case WPS_QUICK:
716 if (quick_screen(CONTEXT_WPS, WPS_QUICK))
717 return SYS_USB_CONNECTED;
718 restore = true;
719 lastbutton = 0;
720 break;
721
722 /* screen settings */
723#ifdef BUTTON_F3
724 case BUTTON_F3:
725 if (quick_screen(CONTEXT_WPS, BUTTON_F3))
726 return SYS_USB_CONNECTED;
727 restore = true;
728 break;
729#endif
730
731 /* pitch screen */
732#if CONFIG_KEYPAD == RECORDER_PAD
733 case BUTTON_ON | BUTTON_UP:
734 case BUTTON_ON | BUTTON_DOWN:
735 if (2 == pitch_screen())
736 return SYS_USB_CONNECTED;
737 restore = true;
738 break;
739#endif
740#endif
741
742#ifdef AB_REPEAT_ENABLE
743
744#ifdef WPS_AB_SET_A_MARKER
745 /* set A marker for A-B repeat */
746 case WPS_AB_SET_A_MARKER:
747 if (ab_repeat_mode_enabled())
748 ab_set_A_marker(id3->elapsed);
749 break;
750#endif
751
752#ifdef WPS_AB_SET_B_MARKER
753 /* set B marker for A-B repeat and jump to A */
754 case WPS_AB_SET_B_MARKER:
755 if (ab_repeat_mode_enabled())
756 {
757 ab_set_B_marker(id3->elapsed);
758 ab_jump_to_A_marker();
759 update_track = true;
760 }
761 break;
762#endif
763
764#ifdef WPS_AB_RESET_AB_MARKERS
765 /* reset A&B markers */
766 case WPS_AB_RESET_AB_MARKERS:
767 if (ab_repeat_mode_enabled())
768 {
769 ab_reset_markers();
770 update_track = true;
771 }
772 break;
773#endif
774
775#endif /* AB_REPEAT_ENABLE */
776
777 /* stop and exit wps */
778#ifdef WPS_EXIT
779 case WPS_EXIT:
780# ifdef WPS_EXIT_PRE
781 if (lastbutton != WPS_EXIT_PRE)
782 break;
783# endif
784 exit = true;
785
786# ifdef WPS_RC_EXIT
787 case WPS_RC_EXIT:
788# ifdef WPS_RC_EXIT_PRE
789 if (lastbutton != WPS_RC_EXIT_PRE)
790 break;
791# endif
792 exit = true;
793# endif
794 break;
795#endif
796
797#ifdef WPS_ID3
798 case WPS_ID3:
799 browse_id3();
800 restore = true;
801 break;
802#endif
803
804 case BUTTON_NONE: /* Timeout */
805 update_track = true;
806 break;
807
808 default:
809 if(default_event_handler(button) == SYS_USB_CONNECTED)
810 return SYS_USB_CONNECTED;
811 update_track = true;
812 break;
813 }
814
815 if (update_track)
816 {
817 if (update())
818 {
819 /* set dir browser to current playing song */
820 if (global_settings.browse_current &&
821 current_track_path[0] != '\0')
822 set_current_file(current_track_path);
823
824 return 0;
825 }
826 update_track = false;
827 }
828
829 if (exit) {
830#ifdef HAVE_LCD_CHARCELLS
831 status_set_record(false);
832 status_set_audio(false);
833#endif
834 if (global_settings.fade_on_stop)
835 fade(0);
836
837 lcd_stop_scroll();
838 bookmark_autobookmark();
839 audio_stop();
840#ifdef AB_REPEAT_ENABLE
841 ab_reset_markers();
842#endif
843
844 /* Keys can be locked when exiting, so either unlock here
845 or implement key locking in tree.c too */
846 keys_locked=false;
847
848 /* set dir browser to current playing song */
849 if (global_settings.browse_current &&
850 current_track_path[0] != '\0')
851 set_current_file(current_track_path);
852
853 return 0;
854 }
855
856 if ( button )
857 ata_spin();
858
859 if (restore &&
860 ((restoretimer == 0) ||
861 (restoretimer < current_tick)))
862 {
863 restore = false;
864 restoretimer = 0;
865 if (wps_display(id3, nid3))
866 {
867 /* set dir browser to current playing song */
868 if (global_settings.browse_current &&
869 current_track_path[0] != '\0')
870 set_current_file(current_track_path);
871
872 return 0;
873 }
874
875 if (id3)
876 wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
877 }
878 if (button != BUTTON_NONE)
879 lastbutton = button;
880 }
881 return 0; /* unreachable - just to reduce compiler warnings */
882}