2009-07-27 07:21:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002-2007 Björn Stenberg
|
|
|
|
* Copyright (C) 2007-2008 Nicolas Pennequin
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "font.h"
|
|
|
|
#include <stdio.h>
|
2010-05-06 21:04:40 +00:00
|
|
|
#include "string-extra.h"
|
2009-07-27 07:21:05 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "action.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "settings_list.h"
|
|
|
|
#include "rbunicode.h"
|
|
|
|
#include "timefuncs.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "powermgmt.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "debug.h"
|
2010-06-06 06:28:40 +00:00
|
|
|
#include "cuesheet.h"
|
2009-07-27 07:21:05 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
#include "hwcompat.h"
|
|
|
|
#endif
|
|
|
|
#include "abrepeat.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "led.h"
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
/* Image stuff */
|
|
|
|
#include "albumart.h"
|
|
|
|
#endif
|
|
|
|
#include "dsp.h"
|
|
|
|
#include "playlist.h"
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#include "playback.h"
|
2009-11-09 17:57:17 +00:00
|
|
|
#include "tdspeed.h"
|
2009-07-27 07:21:05 +00:00
|
|
|
#endif
|
|
|
|
#include "viewport.h"
|
2010-08-14 15:17:59 +00:00
|
|
|
#include "tagcache.h"
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
#include "wps_internals.h"
|
2010-09-14 12:21:56 +00:00
|
|
|
#include "skin_engine.h"
|
2010-09-16 12:56:51 +00:00
|
|
|
#include "statusbar-skinned.h"
|
2009-10-16 19:14:33 +00:00
|
|
|
#include "root_menu.h"
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
#include "recording.h"
|
2009-11-03 07:58:10 +00:00
|
|
|
#include "pcm_record.h"
|
2009-10-16 19:14:33 +00:00
|
|
|
#endif
|
2009-11-15 21:39:39 +00:00
|
|
|
#include "language.h"
|
2009-11-22 19:09:54 +00:00
|
|
|
#include "usb.h"
|
2010-05-12 11:44:09 +00:00
|
|
|
#if CONFIG_TUNER
|
2010-05-12 10:38:00 +00:00
|
|
|
#include "radio.h"
|
|
|
|
#include "tuner.h"
|
2010-05-12 11:44:09 +00:00
|
|
|
#endif
|
2009-07-27 07:21:05 +00:00
|
|
|
|
2010-01-15 07:20:56 +00:00
|
|
|
extern struct wps_state wps_state;
|
|
|
|
|
2010-02-28 14:13:35 +00:00
|
|
|
static const char* get_codectype(const struct mp3entry* id3)
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
2009-10-16 19:14:37 +00:00
|
|
|
if (id3 && id3->codectype < AFMT_NUM_CODECS) {
|
2010-02-28 14:13:35 +00:00
|
|
|
return audio_formats[id3->codectype].label;
|
2009-07-27 07:21:05 +00:00
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract a part from a path.
|
|
|
|
*
|
|
|
|
* buf - buffer extract part to.
|
|
|
|
* buf_size - size of buffer.
|
|
|
|
* path - path to extract from.
|
|
|
|
* level - what to extract. 0 is file name, 1 is parent of file, 2 is
|
|
|
|
* parent of parent, etc.
|
|
|
|
*
|
|
|
|
* Returns buf if the desired level was found, NULL otherwise.
|
|
|
|
*/
|
2010-01-13 06:02:38 +00:00
|
|
|
char* get_dir(char* buf, int buf_size, const char* path, int level)
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
const char* sep;
|
|
|
|
const char* last_sep;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
sep = path + strlen(path);
|
|
|
|
last_sep = sep;
|
|
|
|
|
|
|
|
while (sep > path)
|
|
|
|
{
|
|
|
|
if ('/' == *(--sep))
|
|
|
|
{
|
|
|
|
if (!level)
|
|
|
|
break;
|
|
|
|
|
|
|
|
level--;
|
|
|
|
last_sep = sep - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level || (last_sep <= sep))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
len = MIN(last_sep - sep, buf_size - 1);
|
|
|
|
strlcpy(buf, sep + 1, len + 1);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-09-17 20:28:47 +00:00
|
|
|
#if (CONFIG_CODEC != MAS3507D) && defined (HAVE_PITCHSCREEN)
|
2009-11-09 17:43:46 +00:00
|
|
|
/* A helper to determine the enum value for pitch/speed.
|
|
|
|
|
|
|
|
When there are two choices (i.e. boolean), return 1 if the value is
|
|
|
|
different from normal value and 2 if the value is the same as the
|
|
|
|
normal value. E.g. "%?Sp<%Sp>" would show the pitch only when
|
|
|
|
playing at a modified pitch.
|
|
|
|
|
|
|
|
When there are more than two choices (i.e. enum), the left half of
|
|
|
|
the choices are to show 0..normal range, and the right half of the
|
|
|
|
choices are to show values over that. The last entry is used when
|
|
|
|
it is set to the normal setting, following the rockbox convention
|
|
|
|
to use the last entry for special values.
|
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
2 items: %?Sp<0..99 or 101..infinity|100>
|
|
|
|
3 items: %?Sp<0..99|101..infinity|100>
|
|
|
|
4 items: %?Sp<0..49|50..99|101..infinity|100>
|
|
|
|
5 items: %?Sp<0..49|50..99|101..149|150..infinity|100>
|
|
|
|
6 items: %?Sp<0..33|34..66|67..99|101..133|134..infinity|100>
|
|
|
|
7 items: %?Sp<0..33|34..66|67..99|101..133|134..167|167..infinity|100>
|
|
|
|
*/
|
|
|
|
static int pitch_speed_enum(int range, int32_t val, int32_t normval)
|
|
|
|
{
|
2010-01-03 10:50:34 +00:00
|
|
|
int center;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (range < 3)
|
|
|
|
return (val == normval) + 1;
|
|
|
|
if (val == normval)
|
|
|
|
return range;
|
|
|
|
center = range / 2;
|
|
|
|
n = (center * val) / normval + 1;
|
|
|
|
return (range <= n) ? (range - 1) : n;
|
2009-11-09 17:43:46 +00:00
|
|
|
}
|
2009-11-09 17:51:36 +00:00
|
|
|
#endif
|
2009-11-09 17:43:46 +00:00
|
|
|
|
2010-07-29 13:23:33 +00:00
|
|
|
const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
|
|
|
|
int offset_tracks, char *buf, int buf_size)
|
|
|
|
{
|
|
|
|
struct cuesheet *cue = id3?id3->cuesheet:NULL;
|
|
|
|
if (!cue || !cue->curr_track)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
struct cue_track_info *track = cue->curr_track;
|
|
|
|
if (offset_tracks)
|
|
|
|
{
|
|
|
|
if (cue->curr_track_idx+offset_tracks < cue->track_count)
|
|
|
|
track+=offset_tracks;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
switch (token->type)
|
|
|
|
{
|
|
|
|
case SKIN_TOKEN_METADATA_ARTIST:
|
|
|
|
return *track->performer ? track->performer : NULL;
|
|
|
|
case SKIN_TOKEN_METADATA_COMPOSER:
|
|
|
|
return *track->songwriter ? track->songwriter : NULL;
|
|
|
|
case SKIN_TOKEN_METADATA_ALBUM:
|
|
|
|
return *cue->title ? cue->title : NULL;
|
|
|
|
case SKIN_TOKEN_METADATA_ALBUM_ARTIST:
|
|
|
|
return *cue->performer ? cue->performer : NULL;
|
|
|
|
case SKIN_TOKEN_METADATA_TRACK_TITLE:
|
|
|
|
return *track->title ? track->title : NULL;
|
|
|
|
case SKIN_TOKEN_METADATA_TRACK_NUMBER:
|
|
|
|
snprintf(buf, buf_size, "%d/%d",
|
|
|
|
cue->curr_track_idx+offset_tracks+1, cue->track_count);
|
|
|
|
return buf;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-15 07:20:56 +00:00
|
|
|
|
2010-08-28 10:17:19 +00:00
|
|
|
static const char* get_filename_token(struct wps_token *token, char* filename,
|
2010-08-14 15:17:59 +00:00
|
|
|
char *buf, int buf_size)
|
|
|
|
{
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
switch (token->type)
|
|
|
|
{
|
|
|
|
case SKIN_TOKEN_FILE_PATH:
|
|
|
|
return filename;
|
|
|
|
case SKIN_TOKEN_FILE_NAME:
|
|
|
|
if (get_dir(buf, buf_size, filename, 0)) {
|
|
|
|
/* Remove extension */
|
|
|
|
char* sep = strrchr(buf, '.');
|
|
|
|
if (NULL != sep) {
|
|
|
|
*sep = 0;
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
case SKIN_TOKEN_FILE_NAME_WITH_EXTENSION:
|
|
|
|
return get_dir(buf, buf_size, filename, 0);
|
|
|
|
case SKIN_TOKEN_FILE_DIRECTORY:
|
|
|
|
return get_dir(buf, buf_size, filename, token->value.i);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-15 07:20:56 +00:00
|
|
|
/* All tokens which only need the info to return a value go in here */
|
|
|
|
const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
|
2010-08-14 15:17:59 +00:00
|
|
|
char *filename, char *buf, int buf_size, int limit, int *intval)
|
2010-01-15 07:20:56 +00:00
|
|
|
{
|
|
|
|
struct wps_state *state = &wps_state;
|
|
|
|
if (id3)
|
|
|
|
{
|
2010-03-06 14:14:44 +00:00
|
|
|
unsigned long length = id3->length;
|
|
|
|
unsigned long elapsed = id3->elapsed + state->ff_rewind_count;
|
2010-01-15 07:20:56 +00:00
|
|
|
switch (token->type)
|
|
|
|
{
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_ARTIST:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->artist;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_COMPOSER:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->composer;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_ALBUM:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->album;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_ALBUM_ARTIST:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->albumartist;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_GROUPING:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->grouping;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_GENRE:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->genre_string;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_DISC_NUMBER:
|
2010-01-15 07:20:56 +00:00
|
|
|
if (id3->disc_string)
|
|
|
|
return id3->disc_string;
|
|
|
|
if (id3->discnum) {
|
|
|
|
snprintf(buf, buf_size, "%d", id3->discnum);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_TRACK_NUMBER:
|
2010-01-15 07:20:56 +00:00
|
|
|
if (id3->track_string)
|
|
|
|
return id3->track_string;
|
|
|
|
if (id3->tracknum) {
|
|
|
|
snprintf(buf, buf_size, "%d", id3->tracknum);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_TRACK_TITLE:
|
2010-01-15 07:20:56 +00:00
|
|
|
return id3->title;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_VERSION:
|
2010-01-15 07:20:56 +00:00
|
|
|
switch (id3->id3version)
|
|
|
|
{
|
|
|
|
case ID3_VER_1_0:
|
|
|
|
return "1";
|
|
|
|
case ID3_VER_1_1:
|
|
|
|
return "1.1";
|
|
|
|
case ID3_VER_2_2:
|
|
|
|
return "2.2";
|
|
|
|
case ID3_VER_2_3:
|
|
|
|
return "2.3";
|
|
|
|
case ID3_VER_2_4:
|
|
|
|
return "2.4";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_YEAR:
|
2010-01-15 07:20:56 +00:00
|
|
|
if( id3->year_string )
|
|
|
|
return id3->year_string;
|
|
|
|
if (id3->year) {
|
|
|
|
snprintf(buf, buf_size, "%d", id3->year);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_METADATA_COMMENT:
|
2010-03-06 14:14:44 +00:00
|
|
|
return id3->comment;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_FILE_BITRATE:
|
2010-01-15 07:20:56 +00:00
|
|
|
if(id3->bitrate)
|
|
|
|
snprintf(buf, buf_size, "%d", id3->bitrate);
|
|
|
|
else
|
|
|
|
return "?";
|
|
|
|
return buf;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRACK_TIME_ELAPSED:
|
2010-03-06 14:14:44 +00:00
|
|
|
format_time(buf, buf_size, elapsed);
|
2010-01-15 07:20:56 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRACK_TIME_REMAINING:
|
2010-03-06 14:14:44 +00:00
|
|
|
format_time(buf, buf_size, length - elapsed);
|
2010-01-15 07:20:56 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRACK_LENGTH:
|
2010-03-06 14:14:44 +00:00
|
|
|
format_time(buf, buf_size, length);
|
2010-01-15 07:20:56 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRACK_ELAPSED_PERCENT:
|
2010-03-06 14:14:44 +00:00
|
|
|
if (length <= 0)
|
2010-01-15 07:20:56 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (intval)
|
|
|
|
{
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
if (limit == TOKEN_VALUE_ONLY)
|
|
|
|
limit = 100; /* make it a percentage */
|
2010-03-06 14:14:44 +00:00
|
|
|
*intval = limit * elapsed / length + 1;
|
2010-01-15 07:20:56 +00:00
|
|
|
}
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, buf_size, "%lu", 100 * elapsed / length);
|
2010-01-15 07:20:56 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRACK_STARTING:
|
2010-05-20 13:41:22 +00:00
|
|
|
{
|
2010-08-01 10:40:29 +00:00
|
|
|
unsigned long time = token->value.i * (HZ/TIMEOUT_UNIT);
|
2010-05-20 13:41:22 +00:00
|
|
|
if (elapsed < time)
|
|
|
|
return "starting";
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRACK_ENDING:
|
2010-05-20 13:41:22 +00:00
|
|
|
{
|
2010-08-01 10:40:29 +00:00
|
|
|
unsigned long time = token->value.i * (HZ/TIMEOUT_UNIT);
|
2010-05-20 13:41:22 +00:00
|
|
|
if (length - elapsed < time)
|
|
|
|
return "ending";
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-01-15 07:20:56 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_FILE_CODEC:
|
2010-01-15 07:20:56 +00:00
|
|
|
if (intval)
|
|
|
|
{
|
|
|
|
if(id3->codectype == AFMT_UNKNOWN)
|
|
|
|
*intval = AFMT_NUM_CODECS;
|
|
|
|
else
|
|
|
|
*intval = id3->codectype;
|
|
|
|
}
|
|
|
|
return get_codectype(id3);
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_FILE_FREQUENCY:
|
2010-01-15 07:20:56 +00:00
|
|
|
snprintf(buf, buf_size, "%ld", id3->frequency);
|
|
|
|
return buf;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_FILE_FREQUENCY_KHZ:
|
2010-01-15 07:20:56 +00:00
|
|
|
/* ignore remainders < 100, so 22050 Hz becomes just 22k */
|
|
|
|
if ((id3->frequency % 1000) < 100)
|
|
|
|
snprintf(buf, buf_size, "%ld", id3->frequency / 1000);
|
|
|
|
else
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, buf_size, "%ld.%lu",
|
2010-01-15 07:20:56 +00:00
|
|
|
id3->frequency / 1000,
|
|
|
|
(id3->frequency % 1000) / 100);
|
|
|
|
return buf;
|
2010-08-14 15:17:59 +00:00
|
|
|
case SKIN_TOKEN_FILE_VBR:
|
|
|
|
return (id3->vbr) ? "(avg)" : NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_FILE_SIZE:
|
2010-01-15 07:20:56 +00:00
|
|
|
snprintf(buf, buf_size, "%ld", id3->filesize / 1024);
|
|
|
|
return buf;
|
2010-03-06 14:14:44 +00:00
|
|
|
|
2010-01-15 07:20:56 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_DATABASE_PLAYCOUNT:
|
2010-01-15 07:20:56 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = id3->playcount + 1;
|
|
|
|
snprintf(buf, buf_size, "%ld", id3->playcount);
|
|
|
|
return buf;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_DATABASE_RATING:
|
2010-01-15 07:20:56 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = id3->rating + 1;
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, buf_size, "%d", id3->rating);
|
2010-01-15 07:20:56 +00:00
|
|
|
return buf;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_DATABASE_AUTOSCORE:
|
2010-01-15 07:20:56 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = id3->score + 1;
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, buf_size, "%d", id3->score);
|
2010-01-15 07:20:56 +00:00
|
|
|
return buf;
|
|
|
|
#endif
|
2010-03-06 14:14:44 +00:00
|
|
|
|
2010-01-15 07:20:56 +00:00
|
|
|
default:
|
2010-08-14 15:17:59 +00:00
|
|
|
return get_filename_token(token, id3->path, buf, buf_size);
|
2010-01-15 07:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* id3 == NULL, handle the error based on the expected return type */
|
|
|
|
{
|
|
|
|
switch (token->type)
|
|
|
|
{
|
|
|
|
/* Most tokens expect NULL on error so leave that for the default case,
|
|
|
|
* The ones that expect "0" need to be handled */
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_FILE_FREQUENCY:
|
|
|
|
case SKIN_TOKEN_FILE_FREQUENCY_KHZ:
|
|
|
|
case SKIN_TOKEN_FILE_SIZE:
|
2010-01-15 07:30:30 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_DATABASE_PLAYCOUNT:
|
|
|
|
case SKIN_TOKEN_DATABASE_RATING:
|
|
|
|
case SKIN_TOKEN_DATABASE_AUTOSCORE:
|
2010-01-15 07:30:30 +00:00
|
|
|
#endif
|
2010-01-15 07:20:56 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = 0;
|
|
|
|
return "0";
|
|
|
|
default:
|
2010-08-14 15:17:59 +00:00
|
|
|
return get_filename_token(token, filename, buf, buf_size);
|
2010-01-15 07:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
2010-05-12 21:44:24 +00:00
|
|
|
|
2010-05-15 21:47:30 +00:00
|
|
|
/* Formats the frequency (specified in Hz) in MHz, */
|
|
|
|
/* with one or two digits after the decimal point -- */
|
|
|
|
/* depending on the frequency changing step. */
|
|
|
|
/* Returns buf */
|
|
|
|
static char *format_freq_MHz(int freq, int freq_step, char *buf, int buf_size)
|
2010-05-12 21:44:24 +00:00
|
|
|
{
|
2010-05-15 21:47:30 +00:00
|
|
|
int scale, div;
|
|
|
|
char *fmt;
|
|
|
|
if (freq_step < 100000)
|
|
|
|
{
|
|
|
|
/* Format with two digits after decimal point */
|
|
|
|
scale = 10000;
|
|
|
|
fmt = "%d.%02d";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Format with one digit after decimal point */
|
|
|
|
scale = 100000;
|
|
|
|
fmt = "%d.%d";
|
|
|
|
}
|
|
|
|
div = 1000000 / scale;
|
|
|
|
freq = freq / scale;
|
|
|
|
snprintf(buf, buf_size, fmt, freq/div, freq%div);
|
|
|
|
return buf;
|
2010-05-12 21:44:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-12 10:38:00 +00:00
|
|
|
/* Tokens which are really only used by the radio screen go in here */
|
|
|
|
const char *get_radio_token(struct wps_token *token, int preset_offset,
|
|
|
|
char *buf, int buf_size, int limit, int *intval)
|
|
|
|
{
|
2010-05-15 21:47:30 +00:00
|
|
|
const struct fm_region_data *region_data =
|
|
|
|
&(fm_region_data[global_settings.fm_region]);
|
2010-05-12 10:38:00 +00:00
|
|
|
(void)limit;
|
|
|
|
switch (token->type)
|
|
|
|
{
|
|
|
|
/* Radio/tuner tokens */
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TUNER_TUNED:
|
2010-05-12 10:38:00 +00:00
|
|
|
if (tuner_get(RADIO_TUNED))
|
|
|
|
return "t";
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TUNER_SCANMODE:
|
2010-05-12 10:38:00 +00:00
|
|
|
if (radio_scan_mode())
|
|
|
|
return "s";
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TUNER_STEREO:
|
2010-05-12 10:38:00 +00:00
|
|
|
if (radio_is_stereo())
|
|
|
|
return "s";
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TUNER_MINFREQ: /* changes based on "region" */
|
2010-05-15 21:47:30 +00:00
|
|
|
return format_freq_MHz(region_data->freq_min,
|
|
|
|
region_data->freq_step, buf, buf_size);
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TUNER_MAXFREQ: /* changes based on "region" */
|
2010-05-15 21:47:30 +00:00
|
|
|
return format_freq_MHz(region_data->freq_max,
|
|
|
|
region_data->freq_step, buf, buf_size);
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TUNER_CURFREQ:
|
2010-05-15 21:47:30 +00:00
|
|
|
return format_freq_MHz(radio_current_frequency(),
|
|
|
|
region_data->freq_step, buf, buf_size);
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PRESET_NAME:
|
|
|
|
case SKIN_TOKEN_PRESET_FREQ:
|
|
|
|
case SKIN_TOKEN_PRESET_ID:
|
2010-05-12 10:38:00 +00:00
|
|
|
{
|
2010-05-13 08:36:38 +00:00
|
|
|
int preset_count = radio_preset_count();
|
|
|
|
int cur_preset = radio_current_preset();
|
|
|
|
if (preset_count == 0 || cur_preset < 0)
|
2010-05-12 10:38:00 +00:00
|
|
|
return NULL;
|
2010-05-13 08:36:38 +00:00
|
|
|
int preset = cur_preset + preset_offset;
|
|
|
|
/* make sure it's in the valid range */
|
|
|
|
preset %= preset_count;
|
2010-05-16 15:05:58 +00:00
|
|
|
if (preset < 0)
|
|
|
|
preset += preset_count;
|
2010-07-29 12:37:48 +00:00
|
|
|
if (token->type == SKIN_TOKEN_PRESET_NAME)
|
2010-05-12 10:38:00 +00:00
|
|
|
snprintf(buf, buf_size, "%s", radio_get_preset(preset)->name);
|
2010-07-29 12:37:48 +00:00
|
|
|
else if (token->type == SKIN_TOKEN_PRESET_FREQ)
|
2010-05-12 21:44:24 +00:00
|
|
|
format_freq_MHz(radio_get_preset(preset)->frequency,
|
2010-05-15 21:47:30 +00:00
|
|
|
region_data->freq_step, buf, buf_size);
|
2010-05-24 09:18:03 +00:00
|
|
|
else
|
|
|
|
snprintf(buf, buf_size, "%d", preset + 1);
|
2010-05-12 10:38:00 +00:00
|
|
|
return buf;
|
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PRESET_COUNT:
|
2010-05-12 10:38:00 +00:00
|
|
|
snprintf(buf, buf_size, "%d", radio_preset_count());
|
|
|
|
if (intval)
|
|
|
|
*intval = radio_preset_count();
|
|
|
|
return buf;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_HAVE_RDS:
|
2010-05-12 10:38:00 +00:00
|
|
|
#ifdef HAVE_RDS_CAP
|
|
|
|
return "rds";
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RDS_NAME:
|
2010-05-12 10:38:00 +00:00
|
|
|
return tuner_get_rds_info(RADIO_RDS_NAME);
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RDS_TEXT:
|
2010-05-12 10:38:00 +00:00
|
|
|
return tuner_get_rds_info(RADIO_RDS_TEXT);
|
|
|
|
#else
|
2010-07-29 12:37:48 +00:00
|
|
|
return NULL; /* end of the SKIN_TOKEN_HAVE_RDS case */
|
2010-05-12 10:38:00 +00:00
|
|
|
#endif /* HAVE_RDS_CAP */
|
2010-07-29 12:37:48 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
2010-05-12 10:38:00 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-14 11:56:50 +00:00
|
|
|
static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename)
|
2010-08-14 15:17:59 +00:00
|
|
|
{
|
|
|
|
struct mp3entry* pid3 = NULL;
|
2010-09-14 11:56:50 +00:00
|
|
|
struct wps_state *state = skin_get_global_state();
|
|
|
|
struct cuesheet *cue = state->id3 ? state->id3->cuesheet : NULL;
|
2010-08-14 15:17:59 +00:00
|
|
|
const char *fname = NULL;
|
|
|
|
if (cue && cue->curr_track_idx + offset < cue->track_count)
|
2010-09-14 11:56:50 +00:00
|
|
|
pid3 = state->id3;
|
2010-08-14 15:17:59 +00:00
|
|
|
else if (offset == 0)
|
2010-09-14 11:56:50 +00:00
|
|
|
pid3 = state->id3;
|
2010-08-14 15:17:59 +00:00
|
|
|
else if (offset == 1)
|
2010-09-14 11:56:50 +00:00
|
|
|
pid3 = state->nid3;
|
2010-08-14 15:17:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
static char filename_buf[MAX_PATH + 1];
|
|
|
|
fname = playlist_peek(offset, filename_buf, sizeof(filename_buf));
|
|
|
|
*filename = (char*)fname;
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#ifdef HAVE_TC_RAMCACHE
|
2010-08-14 15:23:07 +00:00
|
|
|
static struct mp3entry tempid3;
|
2010-08-14 15:17:59 +00:00
|
|
|
if (tagcache_fill_tags(&tempid3, fname))
|
|
|
|
{
|
|
|
|
pid3 = &tempid3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (!audio_peek_track(&pid3, offset))
|
|
|
|
pid3 = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return pid3;
|
|
|
|
}
|
|
|
|
|
2010-09-26 06:43:33 +00:00
|
|
|
static const char* get_lif_token_value(struct gui_wps *gwps,
|
|
|
|
struct logical_if *lif,
|
|
|
|
int offset, char *buf, int buf_size)
|
|
|
|
{
|
|
|
|
int a = lif->num_options;
|
|
|
|
int b;
|
|
|
|
const char* out_text = get_token_value(gwps, lif->token, offset,
|
|
|
|
buf, buf_size, &a);
|
|
|
|
if (a == -1 && lif->token->type != SKIN_TOKEN_VOLUME)
|
|
|
|
a = (out_text && *out_text) ? 1 : 0;
|
|
|
|
switch (lif->operand.type)
|
|
|
|
{
|
|
|
|
case STRING:
|
|
|
|
if (lif->op == IF_EQUALS)
|
|
|
|
return strcmp(out_text, lif->operand.data.text) == 0 ?
|
|
|
|
"eq" : NULL;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
break;
|
|
|
|
case INTEGER:
|
|
|
|
case DECIMAL:
|
|
|
|
b = lif->operand.data.number;
|
|
|
|
break;
|
|
|
|
case CODE:
|
|
|
|
{
|
|
|
|
char temp_buf[MAX_PATH];
|
|
|
|
const char *outb;
|
|
|
|
struct wps_token *token = lif->operand.data.code->data;
|
|
|
|
b = lif->num_options;
|
|
|
|
outb = get_token_value(gwps, token, offset, temp_buf,
|
|
|
|
sizeof(temp_buf), &b);
|
|
|
|
if (b == -1 && lif->token->type != SKIN_TOKEN_VOLUME)
|
|
|
|
{
|
|
|
|
if (!out_text || !outb)
|
|
|
|
return (lif->op == IF_EQUALS) ? NULL : "neq";
|
|
|
|
bool equal = strcmp(out_text, outb) == 0;
|
|
|
|
if (lif->op == IF_EQUALS)
|
|
|
|
return equal ? "eq" : NULL;
|
|
|
|
else if (lif->op == IF_NOTEQUALS)
|
|
|
|
return !equal ? "neq" : NULL;
|
|
|
|
else
|
|
|
|
b = (outb && *outb) ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DEFAULT:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (lif->op)
|
|
|
|
{
|
|
|
|
case IF_EQUALS:
|
|
|
|
return a == b ? "eq" : NULL;
|
|
|
|
case IF_NOTEQUALS:
|
|
|
|
return a != b ? "neq" : NULL;
|
|
|
|
case IF_LESSTHAN:
|
|
|
|
return a < b ? "lt" : NULL;
|
|
|
|
case IF_LESSTHAN_EQ:
|
|
|
|
return a <= b ? "lte" : NULL;
|
|
|
|
case IF_GREATERTHAN:
|
|
|
|
return a > b ? "gt" : NULL;
|
|
|
|
case IF_GREATERTHAN_EQ:
|
|
|
|
return a >= b ? "gte" : NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-15 07:20:56 +00:00
|
|
|
/* Return the tags value as text. buf should be used as temp storage if needed.
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
intval is used with conditionals/enums: when this function is called,
|
|
|
|
intval should contain the number of options in the conditional/enum.
|
|
|
|
When this function returns, intval is -1 if the tag is non numeric or,
|
|
|
|
if the tag is numeric, *intval is the enum case we want to go to (between 1
|
|
|
|
and the original value of *intval, inclusive).
|
|
|
|
When not treating a conditional/enum, intval should be NULL.
|
|
|
|
*/
|
|
|
|
const char *get_token_value(struct gui_wps *gwps,
|
2010-08-14 15:17:59 +00:00
|
|
|
struct wps_token *token, int offset,
|
2009-07-27 07:21:05 +00:00
|
|
|
char *buf, int buf_size,
|
|
|
|
int *intval)
|
|
|
|
{
|
|
|
|
if (!gwps)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
struct wps_data *data = gwps->data;
|
2010-09-14 11:56:50 +00:00
|
|
|
struct wps_state *state = skin_get_global_state();
|
2010-01-15 07:20:56 +00:00
|
|
|
struct mp3entry *id3; /* Think very carefully about using this.
|
|
|
|
maybe get_id3_token() is the better place? */
|
|
|
|
const char *out_text = NULL;
|
2010-08-14 15:17:59 +00:00
|
|
|
char *filename = NULL;
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
if (!data || !state)
|
|
|
|
return NULL;
|
|
|
|
|
2010-09-14 11:56:50 +00:00
|
|
|
id3 = get_mp3entry_from_offset(token->next? 1: offset, &filename);
|
2010-08-14 15:17:59 +00:00
|
|
|
if (id3)
|
|
|
|
filename = id3->path;
|
2010-01-15 07:20:56 +00:00
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
#if CONFIG_RTC
|
|
|
|
struct tm* tm = NULL;
|
|
|
|
|
|
|
|
/* if the token is an RTC one, update the time
|
|
|
|
and do the necessary checks */
|
2010-07-29 12:37:48 +00:00
|
|
|
if (token->type >= SKIN_TOKENS_RTC_BEGIN
|
|
|
|
&& token->type <= SKIN_TOKENS_RTC_END)
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
tm = get_time();
|
|
|
|
|
|
|
|
if (!valid_time(tm))
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int limit = 1;
|
|
|
|
if (intval)
|
|
|
|
{
|
|
|
|
limit = *intval;
|
|
|
|
*intval = -1;
|
|
|
|
}
|
2010-01-15 07:20:56 +00:00
|
|
|
|
2010-08-14 15:17:59 +00:00
|
|
|
if (id3 && id3 == state->id3 && id3->cuesheet )
|
2010-06-06 06:28:40 +00:00
|
|
|
{
|
2010-08-14 15:17:59 +00:00
|
|
|
out_text = get_cuesheetid3_token(token, id3,
|
|
|
|
token->next?1:offset, buf, buf_size);
|
2010-06-06 06:28:40 +00:00
|
|
|
if (out_text)
|
|
|
|
return out_text;
|
|
|
|
}
|
2010-08-14 15:17:59 +00:00
|
|
|
out_text = get_id3_token(token, id3, filename, buf, buf_size, limit, intval);
|
2010-01-15 07:20:56 +00:00
|
|
|
if (out_text)
|
|
|
|
return out_text;
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
2010-08-14 15:17:59 +00:00
|
|
|
out_text = get_radio_token(token, offset, buf, buf_size, limit, intval);
|
2010-05-12 10:38:00 +00:00
|
|
|
if (out_text)
|
|
|
|
return out_text;
|
|
|
|
#endif
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
switch (token->type)
|
|
|
|
{
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
case SKIN_TOKEN_LOGICAL_IF:
|
|
|
|
{
|
|
|
|
struct logical_if *lif = token->value.data;
|
2010-09-26 06:43:33 +00:00
|
|
|
return get_lif_token_value(gwps, lif, offset, buf, buf_size);
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_CHARACTER:
|
2009-09-02 02:55:33 +00:00
|
|
|
if (token->value.c == '\n')
|
|
|
|
return NULL;
|
2009-07-27 07:21:05 +00:00
|
|
|
return &(token->value.c);
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_STRING:
|
2009-08-16 18:23:00 +00:00
|
|
|
return (char*)token->value.data;
|
2009-09-26 00:58:32 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_TRANSLATEDSTRING:
|
2009-09-26 00:58:32 +00:00
|
|
|
return (char*)P2STR(ID2P(token->value.i));
|
2009-07-27 07:21:05 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PLAYLIST_ENTRIES:
|
2009-07-27 07:21:05 +00:00
|
|
|
snprintf(buf, buf_size, "%d", playlist_amount());
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = playlist_amount();
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
2010-09-16 14:01:43 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_LIST_TITLE_TEXT:
|
2010-09-16 12:56:51 +00:00
|
|
|
return sb_get_title(gwps->display->screen_type);
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_LIST_TITLE_ICON:
|
2010-02-26 03:45:41 +00:00
|
|
|
if (intval)
|
2010-09-16 12:56:51 +00:00
|
|
|
*intval = sb_get_icon(gwps->display->screen_type);
|
|
|
|
snprintf(buf, buf_size, "%d",sb_get_icon(gwps->display->screen_type));
|
2010-02-26 03:45:41 +00:00
|
|
|
return buf;
|
2010-09-16 14:01:43 +00:00
|
|
|
#endif
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PLAYLIST_NAME:
|
2009-07-27 07:21:05 +00:00
|
|
|
return playlist_name(NULL, buf, buf_size);
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PLAYLIST_POSITION:
|
2010-08-14 15:17:59 +00:00
|
|
|
snprintf(buf, buf_size, "%d", playlist_get_display_index()+offset);
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = playlist_get_display_index()+offset;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PLAYLIST_SHUFFLE:
|
2009-07-27 07:21:05 +00:00
|
|
|
if ( global_settings.playlist_shuffle )
|
|
|
|
return "s";
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
break;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_VOLUME:
|
2009-07-27 07:21:05 +00:00
|
|
|
snprintf(buf, buf_size, "%d", global_settings.volume);
|
|
|
|
if (intval)
|
|
|
|
{
|
2010-03-06 14:14:44 +00:00
|
|
|
int minvol = sound_min(SOUND_VOLUME);
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
if (limit == TOKEN_VALUE_ONLY)
|
|
|
|
{
|
|
|
|
*intval = global_settings.volume;
|
|
|
|
}
|
|
|
|
else if (global_settings.volume == minvol)
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
*intval = 1;
|
|
|
|
}
|
|
|
|
else if (global_settings.volume == 0)
|
|
|
|
{
|
|
|
|
*intval = limit - 1;
|
|
|
|
}
|
|
|
|
else if (global_settings.volume > 0)
|
|
|
|
{
|
|
|
|
*intval = limit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-06 14:14:44 +00:00
|
|
|
*intval = (limit-3) * (global_settings.volume - minvol - 1)
|
|
|
|
/ (-1 - minvol) + 2;
|
2009-07-27 07:21:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
#ifdef HAVE_ALBUMART
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_ALBUMART_FOUND:
|
2010-05-16 11:13:42 +00:00
|
|
|
if (data->albumart)
|
|
|
|
{
|
|
|
|
int handle = -1;
|
|
|
|
handle = playback_current_aa_hid(data->playback_aa_slot);
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
|
|
|
|
{
|
|
|
|
struct dim dim = {data->albumart->width, data->albumart->height};
|
|
|
|
handle = radio_get_art_hid(&dim);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (handle >= 0)
|
2009-10-16 19:14:41 +00:00
|
|
|
return "C";
|
2009-07-27 07:21:05 +00:00
|
|
|
}
|
2009-09-18 05:15:18 +00:00
|
|
|
return NULL;
|
2009-07-27 07:21:05 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BATTERY_PERCENT:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
int l = battery_level();
|
|
|
|
|
|
|
|
if (intval)
|
|
|
|
{
|
New skin tag: %if(<tag>, <operator>, <operand> [,option count]) which lets you do very simple logical comparissons on other tags.
<tag> is the tag to check against
<operator> is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive)
<operand> is either another tag, a number, or text.
[option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv<a|b|c|d> would have 4 options)
example: %?if(%pv, >=, 0)<Warning.. volume clipping|coool...>
That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line."
%?if(%ia, =, %Ia)<same artist> <= this artist and next artist are the same.
some tags might need a touch of tweaking to work better with this. experiment and have fun
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657
2010-08-19 13:49:32 +00:00
|
|
|
if (limit == TOKEN_VALUE_ONLY)
|
|
|
|
{
|
|
|
|
*intval = l;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
limit = MAX(limit, 3);
|
|
|
|
if (l > -1) {
|
|
|
|
/* First enum is used for "unknown level",
|
|
|
|
* last enum is used for 100%.
|
|
|
|
*/
|
|
|
|
*intval = (limit - 2) * l / 100 + 2;
|
|
|
|
} else {
|
|
|
|
*intval = 1;
|
|
|
|
}
|
2009-07-27 07:21:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l > -1) {
|
|
|
|
snprintf(buf, buf_size, "%d", l);
|
|
|
|
return buf;
|
|
|
|
} else {
|
|
|
|
return "?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BATTERY_VOLTS:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
unsigned int v = battery_voltage();
|
|
|
|
snprintf(buf, buf_size, "%d.%02d", v / 1000, (v % 1000) / 10);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BATTERY_TIME:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
int t = battery_time();
|
|
|
|
if (t >= 0)
|
|
|
|
snprintf(buf, buf_size, "%dh %dm", t / 60, t % 60);
|
|
|
|
else
|
|
|
|
return "?h ?m";
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_CHARGING
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BATTERY_CHARGER_CONNECTED:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
if(charger_input_state==CHARGER)
|
|
|
|
return "p";
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if CONFIG_CHARGING >= CHARGING_MONITOR
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BATTERY_CHARGING:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
if (charge_state == CHARGING || charge_state == TOPOFF) {
|
|
|
|
return "c";
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-11-22 19:09:54 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_USB_POWER
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_USB_POWERED:
|
2010-01-03 10:50:34 +00:00
|
|
|
if (usb_powered())
|
|
|
|
return "u";
|
|
|
|
return NULL;
|
2009-07-27 07:21:05 +00:00
|
|
|
#endif
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BATTERY_SLEEPTIME:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
if (get_sleep_timer() == 0)
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
format_time(buf, buf_size, get_sleep_timer() * 1000);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PLAYBACK_STATUS:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
2009-10-16 19:14:28 +00:00
|
|
|
int status = current_playmode();
|
|
|
|
/* music */
|
|
|
|
int mode = 1; /* stop */
|
|
|
|
if (status == STATUS_PLAY)
|
|
|
|
mode = 2; /* play */
|
2009-11-01 13:36:52 +00:00
|
|
|
if (state->is_fading ||
|
2009-10-16 19:14:28 +00:00
|
|
|
(status == STATUS_PAUSE && !status_get_ffmode()))
|
|
|
|
mode = 3; /* pause */
|
|
|
|
else
|
|
|
|
{ /* ff / rwd */
|
|
|
|
if (status_get_ffmode() == STATUS_FASTFORWARD)
|
|
|
|
mode = 4;
|
|
|
|
if (status_get_ffmode() == STATUS_FASTBACKWARD)
|
|
|
|
mode = 5;
|
|
|
|
}
|
2009-10-16 19:14:33 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2009-10-16 19:14:28 +00:00
|
|
|
/* recording */
|
|
|
|
if (status == STATUS_RECORD)
|
|
|
|
mode = 6;
|
|
|
|
else if (status == STATUS_RECORD_PAUSE)
|
|
|
|
mode = 7;
|
2009-10-16 19:14:33 +00:00
|
|
|
#endif
|
|
|
|
#if CONFIG_TUNER
|
2009-10-16 19:14:28 +00:00
|
|
|
/* radio */
|
|
|
|
if (status == STATUS_RADIO)
|
|
|
|
mode = 8;
|
|
|
|
else if (status == STATUS_RADIO_PAUSE)
|
|
|
|
mode = 9;
|
2009-10-16 19:14:33 +00:00
|
|
|
#endif
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
if (intval) {
|
|
|
|
*intval = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buf, buf_size, "%d", mode-1);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REPEAT_MODE:
|
2009-07-27 07:21:05 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = global_settings.repeat_mode + 1;
|
|
|
|
snprintf(buf, buf_size, "%d", global_settings.repeat_mode);
|
|
|
|
return buf;
|
2009-09-13 12:24:14 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_PRESENT:
|
2009-07-27 07:21:05 +00:00
|
|
|
#if CONFIG_RTC
|
|
|
|
return "c";
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_RTC
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_12HOUR_CFG:
|
2009-07-27 07:21:05 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = global_settings.timeformat + 1;
|
|
|
|
snprintf(buf, buf_size, "%d", global_settings.timeformat);
|
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_MONTH:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* d: day of month (01..31) */
|
|
|
|
snprintf(buf, buf_size, "%02d", tm->tm_mday);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_mday - 1;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* e: day of month, blank padded ( 1..31) */
|
|
|
|
snprintf(buf, buf_size, "%2d", tm->tm_mday);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_mday - 1;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* H: hour (00..23) */
|
|
|
|
snprintf(buf, buf_size, "%02d", tm->tm_hour);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_hour;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_HOUR_24:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* k: hour ( 0..23) */
|
|
|
|
snprintf(buf, buf_size, "%2d", tm->tm_hour);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_hour;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* I: hour (01..12) */
|
|
|
|
snprintf(buf, buf_size, "%02d",
|
|
|
|
(tm->tm_hour % 12 == 0) ? 12 : tm->tm_hour % 12);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = (tm->tm_hour % 12 == 0) ? 12 : tm->tm_hour % 12;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_HOUR_12:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* l: hour ( 1..12) */
|
|
|
|
snprintf(buf, buf_size, "%2d",
|
|
|
|
(tm->tm_hour % 12 == 0) ? 12 : tm->tm_hour % 12);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = (tm->tm_hour % 12 == 0) ? 12 : tm->tm_hour % 12;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_MONTH:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* m: month (01..12) */
|
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_mon + 1;
|
|
|
|
snprintf(buf, buf_size, "%02d", tm->tm_mon + 1);
|
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_MINUTE:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* M: minute (00..59) */
|
|
|
|
snprintf(buf, buf_size, "%02d", tm->tm_min);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_min;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_SECOND:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* S: second (00..59) */
|
|
|
|
snprintf(buf, buf_size, "%02d", tm->tm_sec);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_sec;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_YEAR_2_DIGITS:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* y: last two digits of year (00..99) */
|
|
|
|
snprintf(buf, buf_size, "%02d", tm->tm_year % 100);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_year % 100;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_YEAR_4_DIGITS:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* Y: year (1970...) */
|
|
|
|
snprintf(buf, buf_size, "%04d", tm->tm_year + 1900);
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_year + 1900;
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_AM_PM_UPPER:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* p: upper case AM or PM indicator */
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_hour/12 == 0 ? 0 : 1;
|
2009-07-27 07:21:05 +00:00
|
|
|
return tm->tm_hour/12 == 0 ? "AM" : "PM";
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_AM_PM_LOWER:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* P: lower case am or pm indicator */
|
2010-02-05 23:58:53 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_hour/12 == 0 ? 0 : 1;
|
2009-07-27 07:21:05 +00:00
|
|
|
return tm->tm_hour/12 == 0 ? "am" : "pm";
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_WEEKDAY_NAME:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* a: abbreviated weekday name (Sun..Sat) */
|
|
|
|
return str(LANG_WEEKDAY_SUNDAY + tm->tm_wday);
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_MONTH_NAME:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* b: abbreviated month name (Jan..Dec) */
|
|
|
|
return str(LANG_MONTH_JANUARY + tm->tm_mon);
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* u: day of week (1..7); 1 is Monday */
|
|
|
|
if (intval)
|
|
|
|
*intval = (tm->tm_wday == 0) ? 7 : tm->tm_wday;
|
|
|
|
snprintf(buf, buf_size, "%1d", tm->tm_wday + 1);
|
|
|
|
return buf;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* w: day of week (0..6); 0 is Sunday */
|
|
|
|
if (intval)
|
|
|
|
*intval = tm->tm_wday + 1;
|
|
|
|
snprintf(buf, buf_size, "%1d", tm->tm_wday);
|
|
|
|
return buf;
|
|
|
|
#else
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_MONTH:
|
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
|
|
|
|
case SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED:
|
|
|
|
case SKIN_TOKEN_RTC_HOUR_24:
|
|
|
|
case SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED:
|
|
|
|
case SKIN_TOKEN_RTC_HOUR_12:
|
|
|
|
case SKIN_TOKEN_RTC_MONTH:
|
|
|
|
case SKIN_TOKEN_RTC_MINUTE:
|
|
|
|
case SKIN_TOKEN_RTC_SECOND:
|
|
|
|
case SKIN_TOKEN_RTC_AM_PM_UPPER:
|
|
|
|
case SKIN_TOKEN_RTC_AM_PM_LOWER:
|
|
|
|
case SKIN_TOKEN_RTC_YEAR_2_DIGITS:
|
2009-07-27 07:21:05 +00:00
|
|
|
return "--";
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_YEAR_4_DIGITS:
|
2009-07-27 07:21:05 +00:00
|
|
|
return "----";
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_WEEKDAY_NAME:
|
|
|
|
case SKIN_TOKEN_RTC_MONTH_NAME:
|
2009-07-27 07:21:05 +00:00
|
|
|
return "---";
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON:
|
|
|
|
case SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
|
2009-07-27 07:21:05 +00:00
|
|
|
return "-";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PROGRESSBAR:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
char *end = utf8encode(data->wps_progress_pat[0], buf);
|
|
|
|
*end = '\0';
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_PLAYER_PROGRESSBAR:
|
2009-07-27 07:21:05 +00:00
|
|
|
if(is_new_player())
|
|
|
|
{
|
|
|
|
/* we need 11 characters (full line) for
|
|
|
|
progress-bar */
|
|
|
|
strlcpy(buf, " ", buf_size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Tell the user if we have an OldPlayer */
|
|
|
|
strlcpy(buf, " <Old LCD> ", buf_size);
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_CROSSFADE:
|
2009-11-10 04:21:40 +00:00
|
|
|
#ifdef HAVE_CROSSFADE
|
2009-07-27 07:21:05 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = global_settings.crossfade + 1;
|
|
|
|
snprintf(buf, buf_size, "%d", global_settings.crossfade);
|
2009-11-10 04:21:40 +00:00
|
|
|
#else
|
2009-11-11 17:38:00 +00:00
|
|
|
snprintf(buf, buf_size, "%d", 0);
|
2009-11-10 04:21:40 +00:00
|
|
|
#endif
|
2009-11-11 17:38:00 +00:00
|
|
|
return buf;
|
2009-07-27 07:21:05 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REPLAYGAIN:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
|
|
|
int val;
|
|
|
|
|
|
|
|
if (global_settings.replaygain_type == REPLAYGAIN_OFF)
|
|
|
|
val = 1; /* off */
|
|
|
|
else
|
|
|
|
{
|
2009-10-16 19:14:37 +00:00
|
|
|
int type;
|
|
|
|
if (LIKELY(id3))
|
|
|
|
type = get_replaygain_mode(id3->track_gain_string != NULL,
|
2009-07-27 07:21:05 +00:00
|
|
|
id3->album_gain_string != NULL);
|
2009-10-16 19:14:37 +00:00
|
|
|
else
|
|
|
|
type = -1;
|
2010-03-06 14:14:44 +00:00
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
if (type < 0)
|
|
|
|
val = 6; /* no tag */
|
|
|
|
else
|
|
|
|
val = type + 2;
|
|
|
|
|
|
|
|
if (global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
|
|
|
|
val += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (intval)
|
|
|
|
*intval = val;
|
|
|
|
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 6:
|
|
|
|
return "+0.00 dB";
|
|
|
|
break;
|
2009-10-16 19:14:37 +00:00
|
|
|
/* due to above, coming here with !id3 shouldn't be possible */
|
2009-07-27 07:21:05 +00:00
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
strlcpy(buf, id3->track_gain_string, buf_size);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 5:
|
|
|
|
strlcpy(buf, id3->album_gain_string, buf_size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
#endif /* (CONFIG_CODEC == SWCODEC) */
|
|
|
|
|
2010-09-17 20:28:47 +00:00
|
|
|
#if (CONFIG_CODEC != MAS3507D) && defined (HAVE_PITCHSCREEN)
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_SOUND_PITCH:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
2009-10-15 22:22:07 +00:00
|
|
|
int32_t pitch = sound_get_pitch();
|
|
|
|
snprintf(buf, buf_size, "%ld.%ld",
|
|
|
|
pitch / PITCH_SPEED_PRECISION,
|
2010-01-03 10:50:34 +00:00
|
|
|
(pitch % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10));
|
2009-11-09 17:43:46 +00:00
|
|
|
|
2010-01-03 10:50:34 +00:00
|
|
|
if (intval)
|
|
|
|
*intval = pitch_speed_enum(limit, pitch,
|
|
|
|
PITCH_SPEED_PRECISION * 100);
|
2009-07-27 07:21:05 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-17 20:28:47 +00:00
|
|
|
#if (CONFIG_CODEC == SWCODEC) && defined (HAVE_PITCHSCREEN)
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_SOUND_SPEED:
|
2010-01-03 10:50:34 +00:00
|
|
|
{
|
|
|
|
int32_t pitch = sound_get_pitch();
|
|
|
|
int32_t speed;
|
|
|
|
if (dsp_timestretch_available())
|
|
|
|
speed = GET_SPEED(pitch, dsp_get_timestretch());
|
|
|
|
else
|
|
|
|
speed = pitch;
|
|
|
|
snprintf(buf, buf_size, "%ld.%ld",
|
2009-11-09 17:57:17 +00:00
|
|
|
speed / PITCH_SPEED_PRECISION,
|
2010-01-03 10:50:34 +00:00
|
|
|
(speed % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10));
|
|
|
|
if (intval)
|
|
|
|
*intval = pitch_speed_enum(limit, speed,
|
|
|
|
PITCH_SPEED_PRECISION * 100);
|
2009-11-09 17:57:17 +00:00
|
|
|
return buf;
|
2010-01-03 10:50:34 +00:00
|
|
|
}
|
2009-11-09 17:57:17 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_MAIN_HOLD:
|
2009-07-27 07:21:05 +00:00
|
|
|
#ifdef HAS_BUTTON_HOLD
|
|
|
|
if (button_hold())
|
|
|
|
#else
|
|
|
|
if (is_keys_locked())
|
|
|
|
#endif /*hold switch or softlock*/
|
|
|
|
return "h";
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
#ifdef HAS_REMOTE_BUTTON_HOLD
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REMOTE_HOLD:
|
2009-07-27 07:21:05 +00:00
|
|
|
if (remote_button_hold())
|
|
|
|
return "r";
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_VLED_HDD:
|
2009-07-27 07:21:05 +00:00
|
|
|
if(led_read(HZ/2))
|
|
|
|
return "h";
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_BUTTON_VOLUME:
|
2009-11-01 02:36:51 +00:00
|
|
|
if (global_status.last_volume_change &&
|
|
|
|
TIME_BEFORE(current_tick, global_status.last_volume_change +
|
2010-08-01 10:40:29 +00:00
|
|
|
token->value.i))
|
2009-07-27 07:21:05 +00:00
|
|
|
return "v";
|
|
|
|
return NULL;
|
2010-03-18 07:08:49 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_LASTTOUCH:
|
2010-06-15 06:55:18 +00:00
|
|
|
{
|
2009-07-27 07:21:05 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2010-06-15 06:55:18 +00:00
|
|
|
unsigned int last_touch = touchscreen_last_touch();
|
|
|
|
if (last_touch != 0xffff &&
|
2010-08-01 10:48:27 +00:00
|
|
|
TIME_BEFORE(current_tick, token->value.i + last_touch))
|
2009-07-27 07:21:05 +00:00
|
|
|
return "t";
|
|
|
|
#endif
|
2010-06-15 06:55:18 +00:00
|
|
|
}
|
2009-07-27 07:21:05 +00:00
|
|
|
return NULL;
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_SETTING:
|
2009-07-27 07:21:05 +00:00
|
|
|
{
|
2010-02-17 07:17:06 +00:00
|
|
|
const struct settings_list *s = settings+token->value.i;
|
2009-07-27 07:21:05 +00:00
|
|
|
if (intval)
|
|
|
|
{
|
|
|
|
/* Handle contionals */
|
|
|
|
switch (s->flags&F_T_MASK)
|
|
|
|
{
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
2010-02-18 07:04:16 +00:00
|
|
|
if (s->flags&F_T_SOUND)
|
|
|
|
{
|
|
|
|
/* %?St|name|<min|min+1|...|max-1|max> */
|
|
|
|
int sound_setting = s->sound_setting->setting;
|
|
|
|
/* settings with decimals can't be used in conditionals */
|
|
|
|
if (sound_numdecimals(sound_setting) == 0)
|
2010-03-06 14:14:44 +00:00
|
|
|
{
|
2010-02-18 07:04:16 +00:00
|
|
|
*intval = (*(int*)s->setting-sound_min(sound_setting))
|
|
|
|
/sound_steps(sound_setting) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*intval = -1;
|
|
|
|
}
|
|
|
|
else if (s->flags&F_RGB)
|
2009-07-27 07:21:05 +00:00
|
|
|
/* %?St|name|<#000000|#000001|...|#FFFFFF> */
|
|
|
|
/* shouldn't overflow since colors are stored
|
|
|
|
* on 16 bits ...
|
|
|
|
* but this is pretty useless anyway */
|
|
|
|
*intval = *(int*)s->setting + 1;
|
|
|
|
else if (s->cfg_vals == NULL)
|
|
|
|
/* %?St|name|<1st choice|2nd choice|...> */
|
|
|
|
*intval = (*(int*)s->setting-s->int_setting->min)
|
|
|
|
/s->int_setting->step + 1;
|
|
|
|
else
|
|
|
|
/* %?St|name|<1st choice|2nd choice|...> */
|
|
|
|
/* Not sure about this one. cfg_name/vals are
|
|
|
|
* indexed from 0 right? */
|
|
|
|
*intval = *(int*)s->setting + 1;
|
|
|
|
break;
|
|
|
|
case F_T_BOOL:
|
|
|
|
/* %?St|name|<if true|if false> */
|
|
|
|
*intval = *(bool*)s->setting?1:2;
|
|
|
|
break;
|
|
|
|
case F_T_CHARPTR:
|
2010-02-17 07:17:06 +00:00
|
|
|
case F_T_UCHARPTR:
|
2009-07-27 07:21:05 +00:00
|
|
|
/* %?St|name|<if non empty string|if empty>
|
|
|
|
* The string's emptyness discards the setting's
|
|
|
|
* prefix and suffix */
|
|
|
|
*intval = ((char*)s->setting)[0]?1:2;
|
2010-05-12 10:38:00 +00:00
|
|
|
/* if there is a prefix we should ignore it here */
|
|
|
|
if (s->filename_setting->prefix)
|
|
|
|
return (char*)s->setting;
|
2009-07-27 07:21:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* This shouldn't happen ... but you never know */
|
|
|
|
*intval = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-17 07:17:06 +00:00
|
|
|
/* Special handlng for filenames because we dont want to show the prefix */
|
|
|
|
if ((s->flags&F_T_MASK) == F_T_UCHARPTR ||
|
|
|
|
(s->flags&F_T_MASK) == F_T_UCHARPTR)
|
|
|
|
{
|
|
|
|
if (s->filename_setting->prefix)
|
|
|
|
return (char*)s->setting;
|
|
|
|
}
|
2009-07-27 07:21:05 +00:00
|
|
|
cfg_to_string(token->value.i,buf,buf_size);
|
|
|
|
return buf;
|
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_HAVE_TUNER:
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
|
|
|
if (radio_hardware_present())
|
|
|
|
return "r";
|
|
|
|
#endif
|
|
|
|
return NULL;
|
2009-11-03 07:58:10 +00:00
|
|
|
/* Recording tokens */
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_HAVE_RECORDING:
|
2009-11-03 07:58:10 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
return "r";
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDING
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_IS_RECORDING:
|
2010-05-12 10:38:00 +00:00
|
|
|
if (audio_status() == AUDIO_STATUS_RECORD)
|
|
|
|
return "r";
|
|
|
|
return NULL;
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_FREQ: /* order from REC_FREQ_CFG_VAL_LIST */
|
2009-11-03 07:58:10 +00:00
|
|
|
{
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
unsigned long samprk;
|
|
|
|
int rec_freq = global_settings.rec_frequency;
|
|
|
|
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
samprk = 44100;
|
|
|
|
#else
|
|
|
|
#if defined(HAVE_SPDIF_REC)
|
|
|
|
if (global_settings.rec_source == AUDIO_SRC_SPDIF)
|
|
|
|
{
|
|
|
|
/* Use rate in use, not current measured rate if it changed */
|
|
|
|
samprk = pcm_rec_sample_rate();
|
|
|
|
rec_freq = 0;
|
|
|
|
while (rec_freq < SAMPR_NUM_FREQ &&
|
|
|
|
audio_master_sampr_list[rec_freq] != samprk)
|
2010-03-06 14:14:44 +00:00
|
|
|
{
|
2009-11-03 07:58:10 +00:00
|
|
|
rec_freq++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
samprk = rec_freq_sampr[rec_freq];
|
|
|
|
#endif /* SIMULATOR */
|
|
|
|
if (intval)
|
|
|
|
{
|
|
|
|
switch (rec_freq)
|
|
|
|
{
|
|
|
|
REC_HAVE_96_(case REC_FREQ_96:
|
|
|
|
*intval = 1;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_88_(case REC_FREQ_88:
|
|
|
|
*intval = 2;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_64_(case REC_FREQ_64:
|
|
|
|
*intval = 3;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_48_(case REC_FREQ_48:
|
|
|
|
*intval = 4;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_44_(case REC_FREQ_44:
|
|
|
|
*intval = 5;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_32_(case REC_FREQ_32:
|
|
|
|
*intval = 6;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_24_(case REC_FREQ_24:
|
|
|
|
*intval = 7;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_22_(case REC_FREQ_22:
|
|
|
|
*intval = 8;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_16_(case REC_FREQ_16:
|
|
|
|
*intval = 9;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_12_(case REC_FREQ_12:
|
|
|
|
*intval = 10;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_11_(case REC_FREQ_11:
|
|
|
|
*intval = 11;
|
|
|
|
break;)
|
|
|
|
REC_HAVE_8_(case REC_FREQ_8:
|
|
|
|
*intval = 12;
|
|
|
|
break;)
|
|
|
|
}
|
|
|
|
}
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, buf_size, "%lu.%1lu", samprk/1000,samprk%1000);
|
2009-11-03 07:58:10 +00:00
|
|
|
#else /* HWCODEC */
|
|
|
|
|
|
|
|
static const char * const freq_strings[] =
|
2010-03-06 14:14:44 +00:00
|
|
|
{"--", "44", "48", "32", "22", "24", "16"};
|
2009-11-03 07:58:10 +00:00
|
|
|
int freq = 1 + global_settings.rec_frequency;
|
|
|
|
#ifdef HAVE_SPDIF_REC
|
|
|
|
if (global_settings.rec_source == AUDIO_SRC_SPDIF)
|
|
|
|
{
|
|
|
|
/* Can't measure S/PDIF sample rate on Archos/Sim yet */
|
|
|
|
freq = 0;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_SPDIF_IN */
|
|
|
|
if (intval)
|
|
|
|
*intval = freq+1; /* so the token gets a value 1<=x<=7 */
|
2010-05-06 21:37:03 +00:00
|
|
|
snprintf(buf, buf_size, "%s\n",
|
2009-11-03 07:58:10 +00:00
|
|
|
freq_strings[global_settings.rec_frequency]);
|
|
|
|
#endif
|
|
|
|
return buf;
|
|
|
|
}
|
2010-03-06 14:14:44 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_ENCODER:
|
2009-11-03 07:58:10 +00:00
|
|
|
{
|
|
|
|
int rec_format = global_settings.rec_format+1; /* WAV, AIFF, WV, MPEG */
|
|
|
|
if (intval)
|
|
|
|
*intval = rec_format;
|
|
|
|
switch (rec_format)
|
|
|
|
{
|
|
|
|
case REC_FORMAT_PCM_WAV:
|
|
|
|
return "wav";
|
|
|
|
case REC_FORMAT_AIFF:
|
|
|
|
return "aiff";
|
|
|
|
case REC_FORMAT_WAVPACK:
|
|
|
|
return "wv";
|
|
|
|
case REC_FORMAT_MPA_L3:
|
|
|
|
return "MP3";
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_BITRATE:
|
2010-03-06 14:14:44 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2009-11-03 07:58:10 +00:00
|
|
|
if (global_settings.rec_format == REC_FORMAT_MPA_L3)
|
|
|
|
{
|
|
|
|
if (intval)
|
|
|
|
{
|
|
|
|
#if 0 /* FIXME: I dont know if this is needed? */
|
|
|
|
switch (1<<global_settings.mp3_enc_config.bitrate)
|
|
|
|
{
|
|
|
|
case MP3_BITR_CAP_8:
|
|
|
|
*intval = 1;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_16:
|
|
|
|
*intval = 2;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_24:
|
|
|
|
*intval = 3;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_32:
|
|
|
|
*intval = 4;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_40:
|
|
|
|
*intval = 5;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_48:
|
|
|
|
*intval = 6;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_56:
|
|
|
|
*intval = 7;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_64:
|
|
|
|
*intval = 8;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_80:
|
|
|
|
*intval = 9;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_96:
|
|
|
|
*intval = 10;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_112:
|
|
|
|
*intval = 11;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_128:
|
|
|
|
*intval = 12;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_144:
|
|
|
|
*intval = 13;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_160:
|
|
|
|
*intval = 14;
|
|
|
|
break;
|
|
|
|
case MP3_BITR_CAP_192:
|
|
|
|
*intval = 15;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2010-01-03 10:50:34 +00:00
|
|
|
*intval = global_settings.mp3_enc_config.bitrate+1;
|
2009-11-03 07:58:10 +00:00
|
|
|
}
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, buf_size, "%lu", global_settings.mp3_enc_config.bitrate+1);
|
2009-11-03 07:58:10 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL; /* Fixme later */
|
|
|
|
#else /* CONFIG_CODEC == HWCODEC */
|
|
|
|
if (intval)
|
|
|
|
*intval = global_settings.rec_quality+1;
|
|
|
|
snprintf(buf, buf_size, "%d", global_settings.rec_quality);
|
|
|
|
return buf;
|
|
|
|
#endif
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_MONO:
|
2010-01-03 10:50:34 +00:00
|
|
|
if (!global_settings.rec_channels)
|
|
|
|
return "m";
|
|
|
|
return NULL;
|
2010-05-12 10:38:00 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_SECONDS:
|
2010-05-12 10:38:00 +00:00
|
|
|
{
|
|
|
|
int time = (audio_recorded_time() / HZ) % 60;
|
|
|
|
if (intval)
|
|
|
|
*intval = time;
|
|
|
|
snprintf(buf, buf_size, "%02d", time);
|
|
|
|
return buf;
|
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_MINUTES:
|
2010-05-12 10:38:00 +00:00
|
|
|
{
|
|
|
|
int time = (audio_recorded_time() / HZ) / 60;
|
|
|
|
if (intval)
|
|
|
|
*intval = time;
|
|
|
|
snprintf(buf, buf_size, "%02d", time);
|
|
|
|
return buf;
|
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_REC_HOURS:
|
2010-05-12 10:38:00 +00:00
|
|
|
{
|
|
|
|
int time = (audio_recorded_time() / HZ) / 3600;
|
|
|
|
if (intval)
|
|
|
|
*intval = time;
|
|
|
|
snprintf(buf, buf_size, "%02d", time);
|
|
|
|
return buf;
|
|
|
|
}
|
2009-11-03 07:58:10 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_RECORDING */
|
2010-05-12 10:38:00 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_CURRENT_SCREEN:
|
2009-10-16 19:14:33 +00:00
|
|
|
{
|
|
|
|
int curr_screen = current_screen();
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
/* override current_screen() for recording screen since it may
|
|
|
|
* be entered from the radio screen */
|
|
|
|
if (in_recording_screen())
|
|
|
|
curr_screen = GO_TO_RECSCREEN;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (curr_screen)
|
|
|
|
{
|
|
|
|
case GO_TO_WPS:
|
|
|
|
curr_screen = 2;
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
case GO_TO_RECSCREEN:
|
|
|
|
curr_screen = 3;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
case GO_TO_FM:
|
|
|
|
curr_screen = 4;
|
|
|
|
break;
|
|
|
|
#endif
|
2010-02-27 21:24:50 +00:00
|
|
|
case GO_TO_PLAYLIST_VIEWER:
|
|
|
|
curr_screen = 5;
|
|
|
|
break;
|
2009-10-16 19:14:33 +00:00
|
|
|
default: /* lists */
|
|
|
|
curr_screen = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (intval)
|
|
|
|
{
|
|
|
|
*intval = curr_screen;
|
|
|
|
}
|
|
|
|
snprintf(buf, buf_size, "%d", curr_screen);
|
|
|
|
return buf;
|
|
|
|
}
|
2009-07-27 07:21:05 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
case SKIN_TOKEN_LANG_IS_RTL:
|
2009-11-15 21:39:39 +00:00
|
|
|
return lang_is_rtl() ? "r" : NULL;
|
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2010-07-29 13:23:33 +00:00
|
|
|
|
|
|
|
|