From bc041b9d0c1457511f36aec619140d3c4726998d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Oct 2009 22:38:39 -0700 Subject: [PATCH v2 2/2] Implement %Ss for playback speed This is similar to %Sp for pitch. The conditional form %?Ss<...> is also supported in the same way as FS#10680; you can use %?Ss<%xdAa|%xdAb|> to show an icon of a tortoise (subpicture 1 of image A) or a hare (subpicture 2 of image A) when not playing at the normal speed. --- As suggested by kugel, the v2 patch makes the entry for 100% the last in the list. apps/gui/skin_engine/skin_parser.c | 1 + apps/gui/skin_engine/skin_tokens.c | 20 ++++++++++++++++++++ apps/gui/skin_engine/skin_tokens.h | 1 + 3 files changed, 22 insertions(+), 0 deletions(-) diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index fa35ed9..8a13e0e 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -275,6 +275,7 @@ static const struct wps_tag all_tags[] = { #if (CONFIG_CODEC != MAS3507D) { WPS_TOKEN_SOUND_PITCH, "Sp", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_SOUND_SPEED, "Ss", WPS_REFRESH_DYNAMIC, NULL }, #endif #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) { WPS_TOKEN_VLED_HDD, "lh", WPS_REFRESH_DYNAMIC, NULL }, diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index bfe1cc1..5bcec20 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -51,6 +51,7 @@ #include "playlist.h" #if CONFIG_CODEC == SWCODEC #include "playback.h" +#include "tdspeed.h" #endif #include "viewport.h" @@ -833,6 +834,25 @@ const char *get_token_value(struct gui_wps *gwps, } #endif +#if CONFIG_CODEC == SWCODEC + case WPS_TOKEN_SOUND_SPEED: + { + 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", + speed / PITCH_SPEED_PRECISION, + (speed % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10)); + if (intval) + *intval = pitch_speed_enum(limit, speed, + PITCH_SPEED_PRECISION * 100); + return buf; + } +#endif + case WPS_TOKEN_MAIN_HOLD: #ifdef HAS_BUTTON_HOLD if (button_hold()) diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h index 6d78355..c5f0e63 100644 --- a/apps/gui/skin_engine/skin_tokens.h +++ b/apps/gui/skin_engine/skin_tokens.h @@ -55,6 +55,7 @@ enum wps_token_type { WPS_TOKEN_SOUND_PITCH, #endif #if (CONFIG_CODEC == SWCODEC) + WPS_TOKEN_SOUND_SPEED, WPS_TOKEN_REPLAYGAIN, WPS_TOKEN_CROSSFADE, #endif -- 1.6.5.99.g9ed7e