From 8c15799e7056729fab8ca06de406bffe89602558 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Mon, 9 Nov 2009 17:57:17 +0000 Subject: [PATCH] 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. Flyspray: FS#10681 Author: Junio C Hamano git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23591 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_parser.c | 3 +++ apps/gui/skin_engine/skin_tokens.c | 20 ++++++++++++++++++++ apps/gui/skin_engine/skin_tokens.h | 1 + 3 files changed, 24 insertions(+) diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index d06494d908..0e21ec0c81 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -279,6 +279,9 @@ static const struct wps_tag all_tags[] = { #if (CONFIG_CODEC != MAS3507D) { WPS_TOKEN_SOUND_PITCH, "Sp", WPS_REFRESH_DYNAMIC, NULL }, #endif +#if (CONFIG_CODEC == SWCODEC) + { 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 }, #endif diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 9cd8dfcdb0..b271bfedfc 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -49,6 +49,7 @@ #include "playlist.h" #if CONFIG_CODEC == SWCODEC #include "playback.h" +#include "tdspeed.h" #endif #include "viewport.h" @@ -832,6 +833,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 cb8e671097..27594db27f 100644 --- a/apps/gui/skin_engine/skin_tokens.h +++ b/apps/gui/skin_engine/skin_tokens.h @@ -68,6 +68,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