2005-11-18 09:03:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Jerome Kuptz
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-11-18 09:03:25 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2005-11-17 20:20:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2006-08-16 13:25:45 +00:00
|
|
|
#include "config.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
#include "system.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "backlight.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "kernel.h"
|
2007-04-18 13:03:01 +00:00
|
|
|
#include "filetypes.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "settings.h"
|
2009-08-03 04:57:43 +00:00
|
|
|
#include "skin_engine/skin_engine.h"
|
2009-07-27 07:21:05 +00:00
|
|
|
#include "mp3_playback.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "audio.h"
|
|
|
|
#include "usb.h"
|
|
|
|
#include "status.h"
|
2008-11-01 16:14:28 +00:00
|
|
|
#include "storage.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "screens.h"
|
|
|
|
#include "playlist.h"
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "icons.h"
|
|
|
|
#include "peakmeter.h"
|
|
|
|
#endif
|
|
|
|
#include "lang.h"
|
|
|
|
#include "bookmark.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "onplay.h"
|
|
|
|
#include "abrepeat.h"
|
|
|
|
#include "playback.h"
|
|
|
|
#include "splash.h"
|
2007-02-14 14:40:24 +00:00
|
|
|
#include "cuesheet.h"
|
2006-11-08 02:23:01 +00:00
|
|
|
#include "ata_idle_notify.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "root_menu.h"
|
2007-04-25 22:08:00 +00:00
|
|
|
#include "backdrop.h"
|
2008-05-03 12:30:40 +00:00
|
|
|
#include "quickscreen.h"
|
2008-10-05 13:01:54 +00:00
|
|
|
#include "pitchscreen.h"
|
2008-10-16 10:38:03 +00:00
|
|
|
#include "appevents.h"
|
2009-01-02 01:43:00 +00:00
|
|
|
#include "viewport.h"
|
2009-03-12 18:50:24 +00:00
|
|
|
#include "pcmbuf.h"
|
2009-05-15 05:36:16 +00:00
|
|
|
#include "option_select.h"
|
|
|
|
#include "dsp.h"
|
2009-07-22 22:10:25 +00:00
|
|
|
#include "playlist_viewer.h"
|
2009-08-03 04:57:43 +00:00
|
|
|
#include "wps.h"
|
2009-10-19 15:28:15 +00:00
|
|
|
#include "statusbar-skinned.h"
|
2007-04-25 22:08:00 +00:00
|
|
|
|
2009-03-17 01:56:20 +00:00
|
|
|
#define RESTORE_WPS_INSTANTLY 0l
|
|
|
|
#define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
|
2009-08-03 22:39:27 +00:00
|
|
|
|
|
|
|
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
|
|
|
|
/* 3% of 30min file == 54s step size */
|
|
|
|
#define MIN_FF_REWIND_STEP 500
|
|
|
|
|
2009-10-14 15:49:11 +00:00
|
|
|
/* currently only one wps_state is needed, initialize to 0 */
|
2009-10-20 23:12:20 +00:00
|
|
|
struct wps_state wps_state = { .id3 = NULL };
|
2009-10-14 16:00:52 +00:00
|
|
|
static struct gui_wps gui_wps[NB_SCREENS] = {{ .data = NULL }};
|
|
|
|
static struct wps_data wps_datas[NB_SCREENS] = {{ .wps_loaded = 0 }};
|
2009-10-20 23:12:20 +00:00
|
|
|
static struct wps_sync_data wps_sync_data = { .do_full_update = false };
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2006-12-13 11:52:21 +00:00
|
|
|
/* initial setup of wps_data */
|
|
|
|
static void wps_state_init(void);
|
2009-04-06 00:39:43 +00:00
|
|
|
static void track_changed_callback(void *param);
|
|
|
|
static void nextid3available_callback(void* param);
|
2009-04-14 22:13:29 +00:00
|
|
|
|
2010-02-24 06:19:25 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
static void wps_disarm_touchregions(struct wps_data *data);
|
|
|
|
#endif
|
|
|
|
|
2009-08-20 14:29:03 +00:00
|
|
|
#define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
#define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
|
|
|
|
#define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \
|
|
|
|
WPS_DEFAULTCFG:RWPS_DEFAULTCFG)
|
|
|
|
#else
|
|
|
|
#define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
|
|
|
|
#endif
|
|
|
|
|
2009-08-03 22:39:27 +00:00
|
|
|
void wps_data_load(enum screen_type screen, const char *buf, bool isfile)
|
2009-08-03 15:06:30 +00:00
|
|
|
{
|
2009-08-06 01:08:10 +00:00
|
|
|
bool loaded_ok;
|
|
|
|
|
2009-08-20 14:29:03 +00:00
|
|
|
#ifndef __PCTOOL__
|
|
|
|
/*
|
|
|
|
* Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this
|
|
|
|
* wants to be a virtual file. Feel free to modify dirbrowse()
|
|
|
|
* if you're feeling brave.
|
|
|
|
*/
|
|
|
|
|
2009-09-04 00:41:38 +00:00
|
|
|
if (buf && ! strcmp(buf, DEFAULT_WPS(screen)) )
|
2009-08-20 14:29:03 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
if (screen == SCREEN_REMOTE)
|
|
|
|
global_settings.rwps_file[0] = '\0';
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
global_settings.wps_file[0] = '\0';
|
|
|
|
buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __PCTOOL__ */
|
|
|
|
|
2009-11-04 05:24:30 +00:00
|
|
|
loaded_ok = buf && skin_data_load(screen, gui_wps[screen].data, buf, isfile);
|
2009-10-19 15:28:15 +00:00
|
|
|
|
2009-08-03 22:39:27 +00:00
|
|
|
if (!loaded_ok) /* load the hardcoded default */
|
|
|
|
{
|
|
|
|
char *skin_buf[NB_SCREENS] = {
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2010-01-29 07:52:13 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2010-06-07 03:44:11 +00:00
|
|
|
"%X(d)\n"
|
2010-01-29 07:52:13 +00:00
|
|
|
#endif
|
2009-08-03 22:39:27 +00:00
|
|
|
"%s%?it<%?in<%in. |>%it|%fn>\n"
|
2010-06-07 03:44:11 +00:00
|
|
|
"%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
|
|
|
|
"%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
|
2009-08-03 22:39:27 +00:00
|
|
|
"%al%pc/%pt%ar[%pp:%pe]\n"
|
2010-06-07 03:44:11 +00:00
|
|
|
"%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
|
2009-08-03 22:39:27 +00:00
|
|
|
"%pb\n%pm\n",
|
|
|
|
#else
|
2010-06-07 03:44:11 +00:00
|
|
|
"%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
|
2009-08-03 22:39:27 +00:00
|
|
|
"%pc%?ps<*|/>%pt\n",
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2010-01-29 07:52:13 +00:00
|
|
|
#if LCD_REMOTE_DEPTH > 1
|
2010-06-07 03:44:11 +00:00
|
|
|
"%X(d)\n"
|
2010-01-29 07:52:13 +00:00
|
|
|
#endif
|
2010-06-07 03:44:11 +00:00
|
|
|
"%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
|
2009-08-03 22:39:27 +00:00
|
|
|
"%s%?it<%?in<%in. |>%it|%fn>\n"
|
|
|
|
"%al%pc/%pt%ar[%pp:%pe]\n"
|
2010-06-07 03:44:11 +00:00
|
|
|
"%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
|
2009-08-03 22:39:27 +00:00
|
|
|
"%pb\n",
|
|
|
|
#endif
|
|
|
|
};
|
2009-11-04 05:24:30 +00:00
|
|
|
skin_data_load(screen, gui_wps[screen].data, skin_buf[screen], false);
|
2009-08-03 22:39:27 +00:00
|
|
|
}
|
2009-08-03 15:06:30 +00:00
|
|
|
}
|
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
void fade(bool fade_in, bool updatewps)
|
|
|
|
{
|
|
|
|
int fp_global_vol = global_settings.volume << 8;
|
|
|
|
int fp_min_vol = sound_min(SOUND_VOLUME) << 8;
|
|
|
|
int fp_step = (fp_global_vol - fp_min_vol) / 30;
|
|
|
|
int i;
|
2009-11-01 13:36:52 +00:00
|
|
|
wps_state.is_fading = !fade_in;
|
2009-07-27 07:21:05 +00:00
|
|
|
if (fade_in) {
|
|
|
|
/* fade in */
|
|
|
|
int fp_volume = fp_min_vol;
|
|
|
|
|
|
|
|
/* zero out the sound */
|
|
|
|
sound_set_volume(fp_min_vol >> 8);
|
|
|
|
|
|
|
|
sleep(HZ/10); /* let audio thread run */
|
|
|
|
audio_resume();
|
|
|
|
|
|
|
|
while (fp_volume < fp_global_vol - fp_step) {
|
|
|
|
fp_volume += fp_step;
|
|
|
|
sound_set_volume(fp_volume >> 8);
|
|
|
|
if (updatewps)
|
|
|
|
{
|
|
|
|
FOR_NB_SCREENS(i)
|
2009-08-03 04:57:43 +00:00
|
|
|
skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC);
|
2009-07-27 07:21:05 +00:00
|
|
|
}
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
sound_set_volume(global_settings.volume);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* fade out */
|
|
|
|
int fp_volume = fp_global_vol;
|
|
|
|
|
|
|
|
while (fp_volume > fp_min_vol + fp_step) {
|
|
|
|
fp_volume -= fp_step;
|
|
|
|
sound_set_volume(fp_volume >> 8);
|
|
|
|
if (updatewps)
|
|
|
|
{
|
|
|
|
FOR_NB_SCREENS(i)
|
2009-08-03 04:57:43 +00:00
|
|
|
skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC);
|
2009-07-27 07:21:05 +00:00
|
|
|
}
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
audio_pause();
|
2009-11-01 13:36:52 +00:00
|
|
|
wps_state.is_fading = false;
|
2009-07-27 07:21:05 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
/* let audio thread run and wait for the mas to run out of data */
|
|
|
|
while (!mp3_pause_done())
|
|
|
|
#endif
|
|
|
|
sleep(HZ/10);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* reset volume to what it was before the fade */
|
|
|
|
sound_set_volume(global_settings.volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-06 09:28:25 +00:00
|
|
|
static bool update_onvol_change(struct gui_wps * gwps)
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
2009-08-03 04:57:43 +00:00
|
|
|
skin_update(gwps, WPS_REFRESH_NON_STATIC);
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
splashf(0, "Vol: %3d dB",
|
|
|
|
sound_val2phys(SOUND_VOLUME, global_settings.volume));
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-03 15:06:30 +00:00
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
bool ffwd_rew(int button)
|
|
|
|
{
|
|
|
|
unsigned int step = 0; /* current ff/rewind step */
|
|
|
|
unsigned int max_step = 0; /* maximum ff/rewind step */
|
|
|
|
int ff_rewind_count = 0; /* current ff/rewind count (in ticks) */
|
|
|
|
int direction = -1; /* forward=1 or backward=-1 */
|
|
|
|
bool exit = false;
|
|
|
|
bool usb = false;
|
|
|
|
int i = 0;
|
|
|
|
const long ff_rw_accel = (global_settings.ff_rewind_accel + 3);
|
|
|
|
|
|
|
|
if (button == ACTION_NONE)
|
|
|
|
{
|
|
|
|
status_set_ffmode(0);
|
|
|
|
return usb;
|
|
|
|
}
|
|
|
|
while (!exit)
|
|
|
|
{
|
|
|
|
switch ( button )
|
|
|
|
{
|
|
|
|
case ACTION_WPS_SEEKFWD:
|
|
|
|
direction = 1;
|
|
|
|
case ACTION_WPS_SEEKBACK:
|
|
|
|
if (wps_state.ff_rewind)
|
|
|
|
{
|
|
|
|
if (direction == 1)
|
|
|
|
{
|
|
|
|
/* fast forwarding, calc max step relative to end */
|
|
|
|
max_step = (wps_state.id3->length -
|
|
|
|
(wps_state.id3->elapsed +
|
|
|
|
ff_rewind_count)) *
|
|
|
|
FF_REWIND_MAX_PERCENT / 100;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* rewinding, calc max step relative to start */
|
|
|
|
max_step = (wps_state.id3->elapsed + ff_rewind_count) *
|
|
|
|
FF_REWIND_MAX_PERCENT / 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_step = MAX(max_step, MIN_FF_REWIND_STEP);
|
|
|
|
|
|
|
|
if (step > max_step)
|
|
|
|
step = max_step;
|
|
|
|
|
|
|
|
ff_rewind_count += step * direction;
|
|
|
|
|
|
|
|
/* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
|
|
|
|
step += step >> ff_rw_accel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( (audio_status() & AUDIO_STATUS_PLAY) &&
|
|
|
|
wps_state.id3 && wps_state.id3->length )
|
|
|
|
{
|
|
|
|
if (!wps_state.paused)
|
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
|
|
|
audio_pre_ff_rewind();
|
|
|
|
#else
|
|
|
|
audio_pause();
|
|
|
|
#endif
|
|
|
|
#if CONFIG_KEYPAD == PLAYER_PAD
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_wps[i].display->stop_scroll();
|
|
|
|
#endif
|
|
|
|
if (direction > 0)
|
|
|
|
status_set_ffmode(STATUS_FASTFORWARD);
|
|
|
|
else
|
|
|
|
status_set_ffmode(STATUS_FASTBACKWARD);
|
|
|
|
|
|
|
|
wps_state.ff_rewind = true;
|
|
|
|
|
|
|
|
step = 1000 * global_settings.ff_rewind_min_step;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (direction > 0) {
|
|
|
|
if ((wps_state.id3->elapsed + ff_rewind_count) >
|
|
|
|
wps_state.id3->length)
|
|
|
|
ff_rewind_count = wps_state.id3->length -
|
|
|
|
wps_state.id3->elapsed;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((int)(wps_state.id3->elapsed + ff_rewind_count) < 0)
|
|
|
|
ff_rewind_count = -wps_state.id3->elapsed;
|
|
|
|
}
|
|
|
|
|
2009-08-03 04:57:43 +00:00
|
|
|
/* set the wps state ff_rewind_count so the progess info
|
|
|
|
displays corectly */
|
|
|
|
wps_state.ff_rewind_count = (wps_state.wps_time_countup == false)?
|
|
|
|
ff_rewind_count:-ff_rewind_count;
|
2009-07-27 07:21:05 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2009-08-03 04:57:43 +00:00
|
|
|
{
|
|
|
|
skin_update(&gui_wps[i],
|
|
|
|
WPS_REFRESH_PLAYER_PROGRESS |
|
|
|
|
WPS_REFRESH_DYNAMIC);
|
|
|
|
}
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACTION_WPS_STOPSEEK:
|
|
|
|
wps_state.id3->elapsed = wps_state.id3->elapsed+ff_rewind_count;
|
|
|
|
audio_ff_rewind(wps_state.id3->elapsed);
|
2009-08-03 04:57:43 +00:00
|
|
|
wps_state.ff_rewind_count = 0;
|
2009-07-27 07:21:05 +00:00
|
|
|
wps_state.ff_rewind = false;
|
|
|
|
status_set_ffmode(0);
|
|
|
|
#if (CONFIG_CODEC != SWCODEC)
|
|
|
|
if (!wps_state.paused)
|
|
|
|
audio_resume();
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
FOR_NB_SCREENS(i)
|
2009-08-03 04:57:43 +00:00
|
|
|
skin_update(&gui_wps[i], WPS_REFRESH_ALL);
|
2009-07-27 07:21:05 +00:00
|
|
|
#endif
|
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED) {
|
|
|
|
status_set_ffmode(0);
|
|
|
|
usb = true;
|
|
|
|
exit = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!exit)
|
|
|
|
{
|
|
|
|
button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK);
|
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
if (button == ACTION_TOUCHSCREEN)
|
|
|
|
button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data);
|
|
|
|
#endif
|
2009-08-29 16:25:04 +00:00
|
|
|
}
|
2009-07-27 07:21:05 +00:00
|
|
|
}
|
|
|
|
return usb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void display_keylock_text(bool locked)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_wps[i].display->stop_scroll();
|
|
|
|
|
|
|
|
splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-14 22:13:29 +00:00
|
|
|
#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
|
|
|
|
static void gwps_caption_backlight(struct wps_state *state)
|
|
|
|
{
|
|
|
|
if (state && state->id3)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_BACKLIGHT
|
|
|
|
if (global_settings.caption_backlight)
|
|
|
|
{
|
|
|
|
/* turn on backlight n seconds before track ends, and turn it off n
|
|
|
|
seconds into the new track. n == backlight_timeout, or 5s */
|
|
|
|
int n = global_settings.backlight_timeout * 1000;
|
|
|
|
|
|
|
|
if ( n < 1000 )
|
|
|
|
n = 5000; /* use 5s if backlight is always on or off */
|
|
|
|
|
|
|
|
if (((state->id3->elapsed < 1000) ||
|
|
|
|
((state->id3->length - state->id3->elapsed) < (unsigned)n)) &&
|
|
|
|
(state->paused == false))
|
|
|
|
backlight_on();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
if (global_settings.remote_caption_backlight)
|
|
|
|
{
|
|
|
|
/* turn on remote backlight n seconds before track ends, and turn it
|
|
|
|
off n seconds into the new track. n == remote_backlight_timeout,
|
|
|
|
or 5s */
|
|
|
|
int n = global_settings.remote_backlight_timeout * 1000;
|
|
|
|
|
|
|
|
if ( n < 1000 )
|
|
|
|
n = 5000; /* use 5s if backlight is always on or off */
|
|
|
|
|
|
|
|
if (((state->id3->elapsed < 1000) ||
|
|
|
|
((state->id3->length - state->id3->elapsed) < (unsigned)n)) &&
|
|
|
|
(state->paused == false))
|
|
|
|
remote_backlight_on();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-04-04 20:33:38 +00:00
|
|
|
static void change_dir(int direction)
|
|
|
|
{
|
|
|
|
if (global_settings.prevent_skip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (direction < 0)
|
|
|
|
audio_prev_dir();
|
|
|
|
else if (direction > 0)
|
|
|
|
audio_next_dir();
|
2009-07-03 05:08:33 +00:00
|
|
|
/* prevent the next dir to immediatly start being ffw'd */
|
|
|
|
action_wait_for_release();
|
2009-04-04 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void prev_track(unsigned long skip_thresh)
|
2008-05-04 13:47:58 +00:00
|
|
|
{
|
2009-04-05 19:39:09 +00:00
|
|
|
if (wps_state.id3->elapsed < skip_thresh)
|
2009-03-27 13:53:29 +00:00
|
|
|
{
|
2008-05-04 13:47:58 +00:00
|
|
|
audio_prev();
|
2009-03-27 13:53:29 +00:00
|
|
|
return;
|
2008-05-04 13:47:58 +00:00
|
|
|
}
|
2009-03-27 13:53:29 +00:00
|
|
|
else
|
|
|
|
{
|
2009-07-20 05:18:18 +00:00
|
|
|
if (wps_state.id3->cuesheet)
|
2008-05-04 13:47:58 +00:00
|
|
|
{
|
2009-07-24 01:13:30 +00:00
|
|
|
curr_cuesheet_skip(wps_state.id3->cuesheet, -1, wps_state.id3->elapsed);
|
2008-05-04 13:47:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wps_state.paused)
|
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
|
|
|
audio_pre_ff_rewind();
|
|
|
|
#else
|
|
|
|
audio_pause();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
audio_ff_rewind(0);
|
|
|
|
|
|
|
|
#if (CONFIG_CODEC != SWCODEC)
|
|
|
|
if (!wps_state.paused)
|
|
|
|
audio_resume();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-08 20:37:26 +00:00
|
|
|
static void next_track(void)
|
2008-05-04 13:47:58 +00:00
|
|
|
{
|
|
|
|
/* take care of if we're playing a cuesheet */
|
2009-07-20 05:18:18 +00:00
|
|
|
if (wps_state.id3->cuesheet)
|
2008-05-04 13:47:58 +00:00
|
|
|
{
|
2009-07-24 01:13:30 +00:00
|
|
|
if (curr_cuesheet_skip(wps_state.id3->cuesheet, 1, wps_state.id3->elapsed))
|
2008-05-04 13:47:58 +00:00
|
|
|
{
|
|
|
|
/* if the result was false, then we really want
|
|
|
|
to skip to the next track */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
audio_next();
|
|
|
|
}
|
2009-03-12 18:50:24 +00:00
|
|
|
|
|
|
|
static void play_hop(int direction)
|
|
|
|
{
|
2009-10-17 16:05:23 +00:00
|
|
|
long step = global_settings.skip_length*1000;
|
|
|
|
long elapsed = wps_state.id3->elapsed;
|
|
|
|
long remaining = wps_state.id3->length - elapsed;
|
2009-03-12 18:50:24 +00:00
|
|
|
|
2009-10-17 16:05:23 +00:00
|
|
|
if (step < 0)
|
|
|
|
{
|
|
|
|
if (direction < 0)
|
|
|
|
{
|
|
|
|
prev_track(DEFAULT_SKIP_TRESH);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (remaining < DEFAULT_SKIP_TRESH*2)
|
|
|
|
{
|
|
|
|
next_track();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elapsed += (remaining - DEFAULT_SKIP_TRESH*2);
|
|
|
|
}
|
|
|
|
else if (!global_settings.prevent_skip &&
|
2009-04-05 19:29:21 +00:00
|
|
|
(!step ||
|
|
|
|
(direction > 0 && step >= remaining) ||
|
|
|
|
(direction < 0 && elapsed < DEFAULT_SKIP_TRESH)))
|
2009-04-04 20:33:38 +00:00
|
|
|
{ /* Do normal track skipping */
|
|
|
|
if (direction > 0)
|
2009-03-27 13:57:56 +00:00
|
|
|
next_track();
|
2009-04-04 20:33:38 +00:00
|
|
|
else if (direction < 0)
|
|
|
|
prev_track(DEFAULT_SKIP_TRESH);
|
|
|
|
return;
|
|
|
|
}
|
2009-10-17 16:05:23 +00:00
|
|
|
else if (direction == 1 && step >= remaining)
|
2009-04-04 20:33:38 +00:00
|
|
|
{
|
2009-03-12 18:50:24 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2009-04-04 20:33:38 +00:00
|
|
|
if(global_settings.beep)
|
|
|
|
pcmbuf_beep(1000, 150, 1500*global_settings.beep);
|
2009-03-12 18:50:24 +00:00
|
|
|
#endif
|
|
|
|
return;
|
2009-03-27 13:53:29 +00:00
|
|
|
}
|
2009-04-04 20:33:38 +00:00
|
|
|
else if ((direction == -1 && elapsed < step))
|
2009-03-27 13:53:29 +00:00
|
|
|
{
|
2009-04-04 20:33:38 +00:00
|
|
|
elapsed = 0;
|
2009-03-27 13:53:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-04 20:33:38 +00:00
|
|
|
elapsed += step * direction;
|
2009-03-12 18:50:24 +00:00
|
|
|
}
|
2009-03-27 13:53:29 +00:00
|
|
|
if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused)
|
|
|
|
{
|
2009-03-12 18:50:24 +00:00
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
|
|
|
audio_pre_ff_rewind();
|
|
|
|
#else
|
|
|
|
audio_pause();
|
|
|
|
#endif
|
|
|
|
}
|
2009-04-04 20:33:38 +00:00
|
|
|
audio_ff_rewind(wps_state.id3->elapsed = elapsed);
|
2009-03-12 18:50:24 +00:00
|
|
|
#if (CONFIG_CODEC != SWCODEC)
|
|
|
|
if (!wps_state.paused)
|
|
|
|
audio_resume();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-02-01 13:43:08 +00:00
|
|
|
|
2009-04-09 08:30:05 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
|
|
|
/*
|
|
|
|
* If the user is unable to see the wps, because the display is deactivated,
|
2009-07-10 16:27:24 +00:00
|
|
|
* we suppress updates until the wps is activated again (the lcd driver will
|
2009-04-25 19:23:40 +00:00
|
|
|
* call this hook to issue an instant update)
|
2009-04-09 08:30:05 +00:00
|
|
|
* */
|
2009-10-20 21:54:59 +00:00
|
|
|
static void wps_lcd_activation_hook(void *param)
|
2009-04-09 08:30:05 +00:00
|
|
|
{
|
2009-10-20 21:54:59 +00:00
|
|
|
(void)param;
|
2009-10-20 23:12:20 +00:00
|
|
|
wps_sync_data.do_full_update = true;
|
2009-04-09 08:30:05 +00:00
|
|
|
/* force timeout in wps main loop, so that the update is instantly */
|
|
|
|
queue_post(&button_queue, BUTTON_NONE, 0);
|
|
|
|
}
|
|
|
|
#endif
|
2009-03-17 01:39:20 +00:00
|
|
|
|
2009-03-17 01:56:20 +00:00
|
|
|
static void gwps_leave_wps(void)
|
|
|
|
{
|
2009-12-09 07:25:46 +00:00
|
|
|
int i;
|
2009-03-17 01:56:20 +00:00
|
|
|
|
2009-03-19 23:04:39 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2009-08-06 00:14:40 +00:00
|
|
|
{
|
2009-03-19 23:04:39 +00:00
|
|
|
gui_wps[i].display->stop_scroll();
|
2010-02-08 09:47:08 +00:00
|
|
|
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
2010-02-08 09:38:03 +00:00
|
|
|
gui_wps[i].display->backdrop_show(sb_get_backdrop(i));
|
2010-02-08 09:47:08 +00:00
|
|
|
#endif
|
2010-05-12 10:38:00 +00:00
|
|
|
viewportmanager_theme_undo(i, skin_has_sbs(i, gui_wps[i].data));
|
2009-12-21 05:19:12 +00:00
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
}
|
2009-03-17 01:56:20 +00:00
|
|
|
|
2009-04-09 08:30:05 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
|
|
|
/* Play safe and unregister the hook */
|
2009-10-20 21:54:59 +00:00
|
|
|
remove_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook);
|
2009-04-09 08:30:05 +00:00
|
|
|
#endif
|
2009-10-19 15:28:15 +00:00
|
|
|
/* unhandle statusbar update delay */
|
|
|
|
sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY);
|
2009-03-17 01:56:20 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 01:38:30 +00:00
|
|
|
/*
|
|
|
|
* display the wps on entering or restoring */
|
|
|
|
static void gwps_enter_wps(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
struct gui_wps *gwps = &gui_wps[i];
|
|
|
|
struct screen *display = gwps->display;
|
2010-02-08 09:38:03 +00:00
|
|
|
display->stop_scroll();
|
2010-05-12 10:38:00 +00:00
|
|
|
viewportmanager_theme_enable(i, skin_has_sbs(i, gui_wps[i].data), NULL);
|
2009-11-16 01:38:30 +00:00
|
|
|
|
|
|
|
/* Update the values in the first (default) viewport - in case the user
|
|
|
|
has modified the statusbar or colour settings */
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
if (display->depth > 1)
|
|
|
|
{
|
|
|
|
struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, gwps->data)->vp;
|
|
|
|
vp->fg_pattern = display->get_foreground();
|
|
|
|
vp->bg_pattern = display->get_background();
|
|
|
|
}
|
2010-01-27 06:47:56 +00:00
|
|
|
#endif
|
2010-01-26 21:29:08 +00:00
|
|
|
/* make the backdrop actually take effect */
|
2010-02-08 22:34:04 +00:00
|
|
|
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
|
|
|
display->backdrop_show(gwps->data->backdrop);
|
|
|
|
#endif
|
2010-01-26 21:29:08 +00:00
|
|
|
display->clear_display();
|
2009-11-16 01:38:30 +00:00
|
|
|
skin_update(gwps, WPS_REFRESH_ALL);
|
2010-02-24 06:19:25 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
wps_disarm_touchregions(gui_wps[i].data);
|
|
|
|
#endif
|
2009-11-16 01:38:30 +00:00
|
|
|
}
|
2010-01-26 21:29:08 +00:00
|
|
|
/* force statusbar/skin update since we just cleared the whole screen */
|
|
|
|
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
|
2009-11-16 01:38:30 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 01:41:56 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2010-02-24 06:19:25 +00:00
|
|
|
/** Disarms all touchregions. */
|
|
|
|
static void wps_disarm_touchregions(struct wps_data *data)
|
|
|
|
{
|
|
|
|
struct skin_token_list *regions = data->touchregions;
|
|
|
|
while (regions)
|
|
|
|
{
|
|
|
|
((struct touchregion *)regions->token->value.data)->armed = false;
|
|
|
|
regions = regions->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-17 06:25:18 +00:00
|
|
|
int wps_get_touchaction(struct wps_data *data)
|
2009-04-20 01:41:56 +00:00
|
|
|
{
|
2010-02-24 06:19:25 +00:00
|
|
|
int returncode = ACTION_NONE;
|
2009-04-20 01:41:56 +00:00
|
|
|
short x,y;
|
|
|
|
short vx, vy;
|
|
|
|
int type = action_get_touchscreen_press(&x, &y);
|
2009-05-17 06:25:18 +00:00
|
|
|
static int last_action = ACTION_NONE;
|
2009-04-20 01:41:56 +00:00
|
|
|
struct touchregion *r;
|
2009-05-17 06:25:18 +00:00
|
|
|
bool repeated = (type == BUTTON_REPEAT);
|
|
|
|
bool released = (type == BUTTON_REL);
|
2010-02-24 06:19:25 +00:00
|
|
|
bool pressed = (type == BUTTON_TOUCHSCREEN);
|
2009-08-16 21:22:57 +00:00
|
|
|
struct skin_token_list *regions = data->touchregions;
|
2010-02-24 06:19:25 +00:00
|
|
|
|
2009-08-16 21:22:57 +00:00
|
|
|
while (regions)
|
2009-04-20 01:41:56 +00:00
|
|
|
{
|
2009-08-16 21:22:57 +00:00
|
|
|
r = (struct touchregion *)regions->token->value.data;
|
2009-04-20 01:41:56 +00:00
|
|
|
/* make sure this region's viewport is visible */
|
|
|
|
if (r->wvp->hidden_flags&VP_DRAW_HIDDEN)
|
2009-08-16 21:22:57 +00:00
|
|
|
{
|
|
|
|
regions = regions->next;
|
2009-04-20 01:41:56 +00:00
|
|
|
continue;
|
2009-08-16 21:22:57 +00:00
|
|
|
}
|
2009-07-10 11:53:15 +00:00
|
|
|
/* check if it's inside this viewport */
|
2009-09-05 23:57:09 +00:00
|
|
|
if (viewport_point_within_vp(&(r->wvp->vp), x, y))
|
|
|
|
{ /* reposition the touch inside the viewport since touchregions
|
|
|
|
* are relative to a preceding viewport */
|
|
|
|
vx = x - r->wvp->vp.x;
|
|
|
|
vy = y - r->wvp->vp.y;
|
2009-04-20 01:41:56 +00:00
|
|
|
/* now see if the point is inside this region */
|
|
|
|
if (vx >= r->x && vx < r->x+r->width &&
|
|
|
|
vy >= r->y && vy < r->y+r->height)
|
2009-05-17 06:25:18 +00:00
|
|
|
{
|
2009-08-10 03:48:27 +00:00
|
|
|
/* reposition the touch within the area */
|
|
|
|
vx -= r->x;
|
|
|
|
vy -= r->y;
|
|
|
|
|
|
|
|
switch(r->type)
|
2009-05-17 06:25:18 +00:00
|
|
|
{
|
2009-08-10 03:48:27 +00:00
|
|
|
case WPS_TOUCHREGION_ACTION:
|
2010-02-24 06:19:25 +00:00
|
|
|
if (r->armed && ((repeated && r->repeat) || (released && !r->repeat)))
|
2009-08-10 03:48:27 +00:00
|
|
|
{
|
|
|
|
last_action = r->action;
|
2010-02-24 06:19:25 +00:00
|
|
|
returncode = r->action;
|
2009-08-10 03:48:27 +00:00
|
|
|
}
|
2010-02-24 06:19:25 +00:00
|
|
|
if (pressed)
|
|
|
|
r->armed = true;
|
2009-08-10 03:48:27 +00:00
|
|
|
break;
|
|
|
|
case WPS_TOUCHREGION_SCROLLBAR:
|
|
|
|
if(r->width > r->height)
|
|
|
|
/* landscape */
|
|
|
|
wps_state.id3->elapsed = (vx *
|
|
|
|
wps_state.id3->length) / r->width;
|
|
|
|
else
|
|
|
|
/* portrait */
|
|
|
|
wps_state.id3->elapsed = (vy *
|
|
|
|
wps_state.id3->length) / r->height;
|
|
|
|
|
2009-09-17 20:49:34 +00:00
|
|
|
if (!wps_state.paused)
|
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
|
|
|
audio_pre_ff_rewind();
|
|
|
|
#else
|
|
|
|
audio_pause();
|
|
|
|
#endif
|
2009-08-10 03:48:27 +00:00
|
|
|
audio_ff_rewind(wps_state.id3->elapsed);
|
2009-09-17 20:49:34 +00:00
|
|
|
#if (CONFIG_CODEC != SWCODEC)
|
|
|
|
if (!wps_state.paused)
|
|
|
|
audio_resume();
|
|
|
|
#endif
|
2009-08-10 03:48:27 +00:00
|
|
|
break;
|
|
|
|
case WPS_TOUCHREGION_VOLUME:
|
|
|
|
{
|
|
|
|
const int min_vol = sound_min(SOUND_VOLUME);
|
|
|
|
const int max_vol = sound_max(SOUND_VOLUME);
|
|
|
|
if(r->width > r->height)
|
|
|
|
/* landscape */
|
|
|
|
global_settings.volume = (vx *
|
|
|
|
(max_vol - min_vol)) / r->width;
|
|
|
|
else
|
|
|
|
/* portrait */
|
2010-02-14 15:31:19 +00:00
|
|
|
global_settings.volume = ((r->height - vy) *
|
2009-08-10 03:48:27 +00:00
|
|
|
(max_vol-min_vol)) / r->height;
|
|
|
|
|
|
|
|
global_settings.volume += min_vol;
|
|
|
|
setvol();
|
2010-02-24 06:19:25 +00:00
|
|
|
returncode = ACTION_REDRAW;
|
2009-08-10 03:48:27 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-29 16:25:04 +00:00
|
|
|
}
|
2009-04-20 01:41:56 +00:00
|
|
|
}
|
2009-08-16 21:22:57 +00:00
|
|
|
regions = regions->next;
|
2009-04-20 01:41:56 +00:00
|
|
|
}
|
2009-08-10 03:48:27 +00:00
|
|
|
|
2010-02-24 06:19:25 +00:00
|
|
|
/* On release, all regions are disarmed. */
|
|
|
|
if (released)
|
|
|
|
wps_disarm_touchregions(data);
|
|
|
|
|
|
|
|
if (returncode != ACTION_NONE)
|
|
|
|
return returncode;
|
|
|
|
|
2009-05-17 06:25:18 +00:00
|
|
|
if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD))
|
|
|
|
return ACTION_WPS_STOPSEEK;
|
|
|
|
last_action = ACTION_TOUCHSCREEN;
|
2009-04-20 01:41:56 +00:00
|
|
|
return ACTION_TOUCHSCREEN;
|
|
|
|
}
|
|
|
|
#endif
|
2009-03-17 01:39:20 +00:00
|
|
|
/* The WPS can be left in two ways:
|
|
|
|
* a) call a function, which draws over the wps. In this case, the wps
|
|
|
|
* will be still active (i.e. the below function didn't return)
|
|
|
|
* b) return with a value evaluated by root_menu.c, in this case the wps
|
|
|
|
* is really left, and root_menu will handle the next screen
|
|
|
|
*
|
|
|
|
* In either way, call gwps_leave_wps(), in order to restore the correct
|
|
|
|
* "main screen" backdrops and statusbars
|
|
|
|
*/
|
2005-11-18 09:03:25 +00:00
|
|
|
long gui_wps_show(void)
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2006-08-15 12:27:07 +00:00
|
|
|
long button = 0;
|
2009-04-08 17:11:50 +00:00
|
|
|
bool restore = true;
|
2009-03-17 01:56:20 +00:00
|
|
|
long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */
|
2005-11-17 20:20:01 +00:00
|
|
|
bool exit = false;
|
2007-08-22 16:33:34 +00:00
|
|
|
bool bookmark = false;
|
2009-04-08 17:11:50 +00:00
|
|
|
bool update = false;
|
2009-10-31 14:55:13 +00:00
|
|
|
bool vol_changed = false;
|
2005-11-17 20:20:01 +00:00
|
|
|
int i;
|
2006-08-22 07:57:40 +00:00
|
|
|
long last_left = 0, last_right = 0;
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
status_set_audio(true);
|
|
|
|
status_set_param(false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
ab_repeat_init();
|
|
|
|
ab_reset_markers();
|
|
|
|
#endif
|
2009-04-08 17:11:50 +00:00
|
|
|
wps_state_init();
|
2009-12-09 07:25:46 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
|
2006-03-21 07:59:23 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
/* did someone else (i.e power thread) change audio pause mode? */
|
|
|
|
if (wps_state.paused != audio_paused) {
|
|
|
|
wps_state.paused = audio_paused;
|
|
|
|
|
|
|
|
/* if another thread paused audio, we are probably in car mode,
|
|
|
|
about to shut down. lets save the settings. */
|
|
|
|
if (wps_state.paused) {
|
|
|
|
settings_save();
|
2005-12-04 13:05:56 +00:00
|
|
|
#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
|
2008-11-01 16:14:28 +00:00
|
|
|
call_storage_idle_notifys(true);
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2010-05-12 10:38:00 +00:00
|
|
|
button = skin_wait_for_action(gui_wps, CONTEXT_WPS|ALLOW_SOFTLOCK,
|
|
|
|
restore ? 1 : HZ/5);
|
2008-11-16 09:56:38 +00:00
|
|
|
|
2009-03-29 17:58:24 +00:00
|
|
|
/* Exit if audio has stopped playing. This happens e.g. at end of
|
|
|
|
playlist or if using the sleep timer. */
|
|
|
|
if (!(audio_status() & AUDIO_STATUS_PLAY))
|
2005-11-17 20:20:01 +00:00
|
|
|
exit = true;
|
2009-04-20 01:41:56 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
if (button == ACTION_TOUCHSCREEN)
|
|
|
|
button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data);
|
|
|
|
#endif
|
2008-07-07 05:17:15 +00:00
|
|
|
/* The iPods/X5/M5 use a single button for the A-B mode markers,
|
|
|
|
defined as ACTION_WPSAB_SINGLE in their config files. */
|
2006-12-22 05:19:56 +00:00
|
|
|
#ifdef ACTION_WPSAB_SINGLE
|
|
|
|
if (!global_settings.party_mode && ab_repeat_mode_enabled())
|
|
|
|
{
|
|
|
|
static int wps_ab_state = 0;
|
|
|
|
if (button == ACTION_WPSAB_SINGLE)
|
|
|
|
{
|
|
|
|
switch (wps_ab_state)
|
|
|
|
{
|
|
|
|
case 0: /* set the A spot */
|
|
|
|
button = ACTION_WPS_ABSETA_PREVDIR;
|
|
|
|
break;
|
|
|
|
case 1: /* set the B spot */
|
|
|
|
button = ACTION_WPS_ABSETB_NEXTDIR;
|
|
|
|
break;
|
|
|
|
case 2:
|
2007-04-13 15:42:25 +00:00
|
|
|
button = ACTION_WPS_ABRESET;
|
2006-12-22 05:19:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
wps_ab_state = (wps_ab_state+1) % 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2005-11-17 20:20:01 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2010-05-09 02:07:42 +00:00
|
|
|
#ifdef HAVE_HOTKEY
|
2010-04-01 03:14:44 +00:00
|
|
|
case ACTION_WPS_HOTKEY:
|
2010-05-09 02:02:51 +00:00
|
|
|
if (!global_settings.hotkey_wps)
|
|
|
|
break;
|
|
|
|
/* fall through */
|
2010-05-09 02:07:42 +00:00
|
|
|
#endif
|
2010-05-09 02:02:51 +00:00
|
|
|
case ACTION_WPS_CONTEXT:
|
2009-01-02 01:29:13 +00:00
|
|
|
{
|
2010-04-01 03:14:44 +00:00
|
|
|
bool hotkey = button == ACTION_WPS_HOTKEY;
|
2009-03-17 01:39:20 +00:00
|
|
|
gwps_leave_wps();
|
2010-02-20 19:06:39 +00:00
|
|
|
int retval = onplay(wps_state.id3->path,
|
2010-04-01 03:14:44 +00:00
|
|
|
FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey);
|
2007-11-04 12:40:18 +00:00
|
|
|
/* if music is stopped in the context menu we want to exit the wps */
|
2010-02-20 19:06:39 +00:00
|
|
|
if (retval == ONPLAY_MAINMENU
|
2007-11-04 12:40:18 +00:00
|
|
|
|| !audio_status())
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_ROOT;
|
2010-02-20 19:06:39 +00:00
|
|
|
else if (retval == ONPLAY_PLAYLIST)
|
|
|
|
return GO_TO_PLAYLIST_VIEWER;
|
2010-06-09 08:51:29 +00:00
|
|
|
#ifdef HAVE_PICTUREFLOW_INTEGRATION
|
2010-06-09 04:25:41 +00:00
|
|
|
else if (retval == ONPLAY_PICTUREFLOW)
|
|
|
|
return GO_TO_PICTUREFLOW;
|
2010-06-09 08:14:41 +00:00
|
|
|
#endif
|
2005-11-17 20:20:01 +00:00
|
|
|
restore = true;
|
2009-01-02 01:29:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_BROWSE:
|
2005-11-17 20:20:01 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2008-11-16 09:56:38 +00:00
|
|
|
status_set_record(false);
|
|
|
|
status_set_audio(false);
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2009-03-19 23:04:39 +00:00
|
|
|
gwps_leave_wps();
|
2008-11-16 09:56:38 +00:00
|
|
|
return GO_TO_PREVIOUS_BROWSER;
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* play/pause */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_PLAY:
|
2006-03-19 08:40:31 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
break;
|
2005-11-17 20:20:01 +00:00
|
|
|
if ( wps_state.paused )
|
|
|
|
{
|
|
|
|
wps_state.paused = false;
|
|
|
|
if ( global_settings.fade_on_stop )
|
2008-06-23 02:45:55 +00:00
|
|
|
fade(true, true);
|
2005-11-17 20:20:01 +00:00
|
|
|
else
|
|
|
|
audio_resume();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wps_state.paused = true;
|
|
|
|
if ( global_settings.fade_on_stop )
|
2008-06-23 02:45:55 +00:00
|
|
|
fade(false, true);
|
2005-11-17 20:20:01 +00:00
|
|
|
else
|
|
|
|
audio_pause();
|
|
|
|
settings_save();
|
2005-12-04 13:05:56 +00:00
|
|
|
#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
|
2008-11-01 16:14:28 +00:00
|
|
|
call_storage_idle_notifys(true); /* make sure resume info is saved */
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_VOLUP:
|
2005-11-17 20:20:01 +00:00
|
|
|
global_settings.volume++;
|
2009-10-31 14:55:13 +00:00
|
|
|
vol_changed = true;
|
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_VOLDOWN:
|
2005-11-17 20:20:01 +00:00
|
|
|
global_settings.volume--;
|
2009-10-31 14:55:13 +00:00
|
|
|
vol_changed = true;
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
2006-08-22 07:57:40 +00:00
|
|
|
/* fast forward
|
2009-03-27 13:53:29 +00:00
|
|
|
OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_SEEKFWD:
|
2006-08-22 07:57:40 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
break;
|
2009-04-04 20:33:38 +00:00
|
|
|
if (current_tick -last_right < HZ)
|
2007-02-14 14:40:24 +00:00
|
|
|
{
|
2009-07-20 05:18:18 +00:00
|
|
|
if (wps_state.id3->cuesheet)
|
2007-02-14 14:40:24 +00:00
|
|
|
{
|
|
|
|
audio_next();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-04 20:33:38 +00:00
|
|
|
change_dir(1);
|
2007-02-14 14:40:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-27 13:53:29 +00:00
|
|
|
else
|
|
|
|
ffwd_rew(ACTION_WPS_SEEKFWD);
|
2008-05-04 13:47:58 +00:00
|
|
|
last_right = last_left = 0;
|
2006-08-22 07:57:40 +00:00
|
|
|
break;
|
|
|
|
/* fast rewind
|
2009-03-27 13:53:29 +00:00
|
|
|
OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_SEEKBACK:
|
2006-03-19 08:40:31 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
break;
|
2009-04-04 20:33:38 +00:00
|
|
|
if (current_tick -last_left < HZ)
|
2007-02-14 14:40:24 +00:00
|
|
|
{
|
2009-07-20 05:18:18 +00:00
|
|
|
if (wps_state.id3->cuesheet)
|
2007-02-14 14:40:24 +00:00
|
|
|
{
|
|
|
|
if (!wps_state.paused)
|
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
|
|
|
audio_pre_ff_rewind();
|
|
|
|
#else
|
|
|
|
audio_pause();
|
|
|
|
#endif
|
|
|
|
audio_ff_rewind(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-04 20:33:38 +00:00
|
|
|
change_dir(-1);
|
2007-02-14 14:40:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-27 13:53:29 +00:00
|
|
|
else
|
|
|
|
ffwd_rew(ACTION_WPS_SEEKBACK);
|
2008-05-04 13:47:58 +00:00
|
|
|
last_left = last_right = 0;
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* prev / restart */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_SKIPPREV:
|
2006-03-19 08:40:31 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
break;
|
2006-08-22 07:57:40 +00:00
|
|
|
last_left = current_tick;
|
2005-11-17 20:20:01 +00:00
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
/* if we're in A/B repeat mode and the current position
|
|
|
|
is past the A marker, jump back to the A marker... */
|
2006-01-21 23:43:57 +00:00
|
|
|
if ( ab_repeat_mode_enabled() )
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2006-01-21 23:43:57 +00:00
|
|
|
if ( ab_after_A_marker(wps_state.id3->elapsed) )
|
|
|
|
{
|
|
|
|
ab_jump_to_A_marker();
|
|
|
|
break;
|
|
|
|
#if (AB_REPEAT_ENABLE == 2)
|
|
|
|
} else {
|
|
|
|
ab_reset_markers();
|
|
|
|
#endif
|
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2009-04-04 20:33:38 +00:00
|
|
|
else
|
2005-11-17 20:20:01 +00:00
|
|
|
/* ...otherwise, do it normally */
|
|
|
|
#endif
|
2008-05-04 13:47:58 +00:00
|
|
|
play_hop(-1);
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-04 13:47:58 +00:00
|
|
|
/* next
|
2008-07-14 20:39:30 +00:00
|
|
|
OR if skip length set, hop by predetermined amount. */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_SKIPNEXT:
|
2006-03-19 08:40:31 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
break;
|
2006-08-22 07:57:40 +00:00
|
|
|
last_right = current_tick;
|
2005-11-17 20:20:01 +00:00
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
/* if we're in A/B repeat mode and the current position is
|
|
|
|
before the A marker, jump to the A marker... */
|
2006-01-21 23:43:57 +00:00
|
|
|
if ( ab_repeat_mode_enabled() )
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2006-01-21 23:43:57 +00:00
|
|
|
if ( ab_before_A_marker(wps_state.id3->elapsed) )
|
|
|
|
{
|
|
|
|
ab_jump_to_A_marker();
|
|
|
|
break;
|
|
|
|
#if (AB_REPEAT_ENABLE == 2)
|
|
|
|
} else {
|
|
|
|
ab_reset_markers();
|
|
|
|
#endif
|
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2009-04-04 20:33:38 +00:00
|
|
|
else
|
2005-11-17 20:20:01 +00:00
|
|
|
/* ...otherwise, do it normally */
|
|
|
|
#endif
|
2008-05-04 13:47:58 +00:00
|
|
|
play_hop(1);
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
/* next / prev directories */
|
2006-08-16 13:25:45 +00:00
|
|
|
/* and set A-B markers if in a-b mode */
|
|
|
|
case ACTION_WPS_ABSETB_NEXTDIR:
|
2006-08-15 12:27:07 +00:00
|
|
|
if (global_settings.party_mode)
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
2006-08-16 13:25:45 +00:00
|
|
|
#if defined(AB_REPEAT_ENABLE)
|
2006-08-15 12:27:07 +00:00
|
|
|
if (ab_repeat_mode_enabled())
|
|
|
|
{
|
|
|
|
ab_set_B_marker(wps_state.id3->elapsed);
|
|
|
|
ab_jump_to_A_marker();
|
|
|
|
}
|
|
|
|
else
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2006-08-15 12:27:07 +00:00
|
|
|
{
|
2009-04-04 20:33:38 +00:00
|
|
|
change_dir(1);
|
2006-08-15 12:27:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-08-16 13:25:45 +00:00
|
|
|
case ACTION_WPS_ABSETA_PREVDIR:
|
2006-08-15 12:27:07 +00:00
|
|
|
if (global_settings.party_mode)
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
2006-08-16 13:25:45 +00:00
|
|
|
#if defined(AB_REPEAT_ENABLE)
|
2006-08-15 12:27:07 +00:00
|
|
|
if (ab_repeat_mode_enabled())
|
|
|
|
ab_set_A_marker(wps_state.id3->elapsed);
|
|
|
|
else
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2006-08-15 12:27:07 +00:00
|
|
|
{
|
2009-04-04 20:33:38 +00:00
|
|
|
change_dir(-1);
|
2006-08-15 12:27:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* menu key functions */
|
|
|
|
case ACTION_WPS_MENU:
|
2009-03-19 23:04:39 +00:00
|
|
|
gwps_leave_wps();
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_ROOT;
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
2006-04-10 03:51:17 +00:00
|
|
|
#ifdef HAVE_QUICKSCREEN
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_QUICKSCREEN:
|
2009-01-02 01:29:13 +00:00
|
|
|
{
|
2009-03-17 01:39:20 +00:00
|
|
|
gwps_leave_wps();
|
2005-11-22 21:55:05 +00:00
|
|
|
if (quick_screen_quick(button))
|
2009-08-29 16:25:04 +00:00
|
|
|
return GO_TO_ROOT;
|
2005-11-17 20:20:01 +00:00
|
|
|
restore = true;
|
2009-01-02 01:29:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
#endif /* HAVE_QUICKSCREEN */
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
/* screen settings */
|
|
|
|
#ifdef BUTTON_F3
|
2006-08-22 08:23:24 +00:00
|
|
|
case ACTION_F3:
|
2009-01-02 01:29:13 +00:00
|
|
|
{
|
2009-03-17 01:39:20 +00:00
|
|
|
gwps_leave_wps();
|
2006-08-22 08:23:24 +00:00
|
|
|
if (quick_screen_f3(BUTTON_F3))
|
2009-08-29 16:25:04 +00:00
|
|
|
return GO_TO_ROOT;
|
2005-11-17 20:20:01 +00:00
|
|
|
restore = true;
|
2009-01-02 01:29:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-08-16 13:25:45 +00:00
|
|
|
#endif /* BUTTON_F3 */
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
/* pitch screen */
|
2006-08-15 12:27:07 +00:00
|
|
|
#ifdef HAVE_PITCHSCREEN
|
|
|
|
case ACTION_WPS_PITCHSCREEN:
|
2009-01-02 01:29:13 +00:00
|
|
|
{
|
2009-03-17 01:39:20 +00:00
|
|
|
gwps_leave_wps();
|
2008-10-05 13:01:54 +00:00
|
|
|
if (1 == gui_syncpitchscreen_run())
|
2009-08-29 16:25:04 +00:00
|
|
|
return GO_TO_ROOT;
|
2005-11-17 20:20:01 +00:00
|
|
|
restore = true;
|
2009-01-02 01:29:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
#endif /* HAVE_PITCHSCREEN */
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
/* reset A&B markers */
|
2007-04-13 15:42:25 +00:00
|
|
|
case ACTION_WPS_ABRESET:
|
2005-11-17 20:20:01 +00:00
|
|
|
if (ab_repeat_mode_enabled())
|
|
|
|
{
|
|
|
|
ab_reset_markers();
|
2009-04-08 17:11:50 +00:00
|
|
|
update = true;
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif /* AB_REPEAT_ENABLE */
|
|
|
|
|
|
|
|
/* stop and exit wps */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_STOP:
|
2006-03-19 08:40:31 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
break;
|
2007-08-22 16:33:34 +00:00
|
|
|
bookmark = true;
|
2005-11-17 20:20:01 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_WPS_ID3SCREEN:
|
2009-01-02 01:29:13 +00:00
|
|
|
{
|
2009-03-17 01:39:20 +00:00
|
|
|
gwps_leave_wps();
|
2009-08-29 16:25:04 +00:00
|
|
|
if (browse_id3())
|
|
|
|
return GO_TO_ROOT;
|
2005-11-17 20:20:01 +00:00
|
|
|
restore = true;
|
2009-01-02 01:29:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-05-15 05:36:16 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */
|
|
|
|
{
|
|
|
|
global_settings.playlist_shuffle =
|
|
|
|
!global_settings.playlist_shuffle;
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
dsp_set_replaygain();
|
|
|
|
#endif
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_randomise(NULL, current_tick, true);
|
|
|
|
else
|
|
|
|
playlist_sort(NULL, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */
|
|
|
|
{
|
|
|
|
const struct settings_list *rep_setting =
|
|
|
|
find_setting(&global_settings.repeat_mode, NULL);
|
|
|
|
option_select_next_val(rep_setting, false, true);
|
|
|
|
audio_flush_and_reload_tracks();
|
|
|
|
}
|
|
|
|
break;
|
2009-07-10 11:53:15 +00:00
|
|
|
#endif /* HAVE_TOUCHSCREEN */
|
|
|
|
/* this case is used by the softlock feature
|
|
|
|
* it requests a full update here */
|
|
|
|
case ACTION_REDRAW:
|
2009-10-20 23:12:20 +00:00
|
|
|
wps_sync_data.do_full_update = true;
|
2009-06-18 13:50:11 +00:00
|
|
|
break;
|
|
|
|
case ACTION_NONE: /* Timeout, do a partial update */
|
2009-04-08 17:11:50 +00:00
|
|
|
update = true;
|
2006-08-15 12:27:07 +00:00
|
|
|
ffwd_rew(button); /* hopefully fix the ffw/rwd bug */
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
2007-08-02 12:13:20 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
case ACTION_WPS_REC:
|
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
#endif
|
2005-11-18 09:43:42 +00:00
|
|
|
case SYS_POWEROFF:
|
|
|
|
default_event_handler(SYS_POWEROFF);
|
|
|
|
break;
|
2009-07-22 22:10:25 +00:00
|
|
|
case ACTION_WPS_VIEW_PLAYLIST:
|
|
|
|
gwps_leave_wps();
|
2010-02-20 19:06:39 +00:00
|
|
|
return GO_TO_PLAYLIST_VIEWER;
|
2009-07-22 22:10:25 +00:00
|
|
|
break;
|
2005-11-17 20:20:01 +00:00
|
|
|
default:
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
2009-08-29 16:25:04 +00:00
|
|
|
{
|
|
|
|
gwps_leave_wps();
|
2007-03-01 23:46:01 +00:00
|
|
|
return GO_TO_ROOT;
|
2009-08-29 16:25:04 +00:00
|
|
|
}
|
2009-04-08 17:11:50 +00:00
|
|
|
update = true;
|
2005-11-17 20:20:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-10-31 14:55:13 +00:00
|
|
|
if (vol_changed)
|
|
|
|
{
|
|
|
|
bool res = false;
|
2009-11-04 12:46:31 +00:00
|
|
|
vol_changed = false;
|
2009-10-31 14:55:13 +00:00
|
|
|
setvol();
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
if(update_onvol_change(&gui_wps[i]))
|
|
|
|
res = true;
|
|
|
|
}
|
|
|
|
if (res) {
|
|
|
|
restore = true;
|
|
|
|
restoretimer = RESTORE_WPS_NEXT_SECOND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-16 01:38:33 +00:00
|
|
|
|
2009-11-16 01:38:36 +00:00
|
|
|
if (restore &&
|
2009-11-16 01:38:33 +00:00
|
|
|
((restoretimer == RESTORE_WPS_INSTANTLY) ||
|
|
|
|
TIME_AFTER(current_tick, restoretimer)))
|
|
|
|
{
|
|
|
|
restore = false;
|
|
|
|
restoretimer = RESTORE_WPS_INSTANTLY;
|
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
|
|
|
add_event(LCD_EVENT_ACTIVATION, false, wps_lcd_activation_hook);
|
|
|
|
#endif
|
|
|
|
/* we remove the update delay since it's not very usable in the wps,
|
|
|
|
* e.g. during volume changing or ffwd/rewind */
|
|
|
|
sb_skin_set_update_delay(0);
|
|
|
|
wps_sync_data.do_full_update = update = false;
|
2009-12-09 07:25:46 +00:00
|
|
|
gwps_enter_wps();
|
2009-11-16 01:38:33 +00:00
|
|
|
}
|
|
|
|
else if (wps_sync_data.do_full_update || update)
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2009-04-14 22:13:29 +00:00
|
|
|
#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
|
|
|
|
gwps_caption_backlight(&wps_state);
|
|
|
|
#endif
|
2005-11-18 09:03:25 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2009-04-12 00:30:28 +00:00
|
|
|
{
|
2009-04-09 08:30:05 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
|
|
|
/* currently, all remotes are readable without backlight
|
|
|
|
* so still update those */
|
2009-10-20 21:54:59 +00:00
|
|
|
if (lcd_active() || (i != SCREEN_MAIN))
|
2009-04-09 08:30:05 +00:00
|
|
|
#endif
|
2009-04-12 00:30:28 +00:00
|
|
|
{
|
2010-03-03 02:20:40 +00:00
|
|
|
skin_update(&gui_wps[i], wps_sync_data.do_full_update ?
|
|
|
|
WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC);
|
2009-04-12 00:30:28 +00:00
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2009-10-20 23:12:20 +00:00
|
|
|
wps_sync_data.do_full_update = false;
|
2009-04-08 17:11:50 +00:00
|
|
|
update = false;
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (exit) {
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
status_set_record(false);
|
|
|
|
status_set_audio(false);
|
|
|
|
#endif
|
|
|
|
if (global_settings.fade_on_stop)
|
2008-06-23 02:45:55 +00:00
|
|
|
fade(false, true);
|
2006-03-21 07:59:23 +00:00
|
|
|
|
2007-08-22 16:33:34 +00:00
|
|
|
if (bookmark)
|
2010-03-28 23:27:49 +00:00
|
|
|
bookmark_autobookmark(true);
|
2005-11-17 20:20:01 +00:00
|
|
|
audio_stop();
|
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
ab_reset_markers();
|
2007-08-02 12:13:20 +00:00
|
|
|
#endif
|
2009-03-19 14:33:22 +00:00
|
|
|
gwps_leave_wps();
|
2007-08-02 12:13:20 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
if (button == ACTION_WPS_REC)
|
|
|
|
return GO_TO_RECSCREEN;
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2007-04-08 02:11:33 +00:00
|
|
|
if (global_settings.browse_current)
|
|
|
|
return GO_TO_PREVIOUS_BROWSER;
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_PREVIOUS;
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2006-03-21 07:59:23 +00:00
|
|
|
|
2009-01-01 05:12:27 +00:00
|
|
|
if (button && !IS_SYSEVENT(button) )
|
2008-11-01 16:14:28 +00:00
|
|
|
storage_spin();
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 00:39:43 +00:00
|
|
|
/* this is called from the playback thread so NO DRAWING! */
|
|
|
|
static void track_changed_callback(void *param)
|
|
|
|
{
|
|
|
|
wps_state.id3 = (struct mp3entry*)param;
|
|
|
|
wps_state.nid3 = audio_next_track();
|
2009-07-20 05:18:18 +00:00
|
|
|
if (wps_state.id3->cuesheet)
|
2009-04-06 00:39:43 +00:00
|
|
|
{
|
2009-07-20 05:18:18 +00:00
|
|
|
cue_find_current_track(wps_state.id3->cuesheet, wps_state.id3->elapsed);
|
2009-04-06 00:39:43 +00:00
|
|
|
}
|
2009-10-20 23:12:20 +00:00
|
|
|
wps_sync_data.do_full_update = true;
|
2009-04-06 00:39:43 +00:00
|
|
|
}
|
|
|
|
static void nextid3available_callback(void* param)
|
|
|
|
{
|
|
|
|
(void)param;
|
|
|
|
wps_state.nid3 = audio_next_track();
|
2009-10-20 23:12:20 +00:00
|
|
|
wps_sync_data.do_full_update = true;
|
2009-04-06 00:39:43 +00:00
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
|
2006-12-13 11:52:21 +00:00
|
|
|
static void wps_state_init(void)
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
|
|
|
wps_state.ff_rewind = false;
|
|
|
|
wps_state.paused = false;
|
2009-04-08 17:11:50 +00:00
|
|
|
if(audio_status() & AUDIO_STATUS_PLAY)
|
|
|
|
{
|
|
|
|
wps_state.id3 = audio_current_track();
|
|
|
|
wps_state.nid3 = audio_next_track();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wps_state.id3 = NULL;
|
|
|
|
wps_state.nid3 = NULL;
|
|
|
|
}
|
|
|
|
/* We'll be updating due to restore initialized with true */
|
2009-10-20 23:12:20 +00:00
|
|
|
wps_sync_data.do_full_update = false;
|
2009-04-06 00:39:43 +00:00
|
|
|
/* add the WPS track event callbacks */
|
|
|
|
add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback);
|
|
|
|
add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback);
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2005-11-18 09:03:25 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
void gui_sync_wps_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2008-12-09 23:07:59 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
2009-09-07 02:36:56 +00:00
|
|
|
wps_datas[i].albumart = NULL;
|
2009-10-16 19:14:41 +00:00
|
|
|
wps_datas[i].playback_aa_slot = -1;
|
2007-04-25 13:09:56 +00:00
|
|
|
#endif
|
2009-01-07 10:57:51 +00:00
|
|
|
gui_wps[i].data = &wps_datas[i];
|
|
|
|
gui_wps[i].display = &screens[i];
|
|
|
|
/* Currently no seperate wps_state needed/possible
|
2009-07-10 11:53:15 +00:00
|
|
|
so use the only available ( "global" ) one */
|
2009-01-07 10:57:51 +00:00
|
|
|
gui_wps[i].state = &wps_state;
|
2009-10-20 23:12:20 +00:00
|
|
|
/* must point to the same struct for both screens */
|
|
|
|
gui_wps[i].sync_data = &wps_sync_data;
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-11 12:29:37 +00:00
|
|
|
|
2009-08-03 15:46:21 +00:00
|
|
|
|
|
|
|
#ifdef IPOD_ACCESSORY_PROTOCOL
|
2009-11-01 13:36:52 +00:00
|
|
|
bool is_wps_fading(void)
|
|
|
|
{
|
|
|
|
return wps_state.is_fading;
|
|
|
|
}
|
|
|
|
|
2009-08-03 15:46:21 +00:00
|
|
|
int wps_get_ff_rewind_count(void)
|
|
|
|
{
|
|
|
|
return wps_state.ff_rewind_count;
|
|
|
|
}
|
|
|
|
#endif
|