From f76b2f2046d1eaefae8bf6f46c6388817d8bc284 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Tue, 3 Nov 2009 07:58:10 +0000 Subject: Initial recording screen skin support (usable in .sbs skins only for now) new skin tokens: %Rp - does the target have recording? %Rf - samplerate %Re - encoder %Rb - bitrate %Rm - mono/stereo Please put all bugs from these (which very probably dont work 100%) into FS#10755. And someone who knows how the recoding capabilities work please look this over... ideally the same value should be returned for the middle three tags no matter what the capabilities of the target are. CustomWPS on the wiki for more details git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23491 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_parser.c | 17 +++- apps/gui/skin_engine/skin_tokens.c | 196 +++++++++++++++++++++++++++++++++++++ apps/gui/skin_engine/skin_tokens.h | 7 ++ 3 files changed, 219 insertions(+), 1 deletion(-) diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index ae33e907f0..a72dcb8f02 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -360,7 +360,16 @@ static const struct wps_tag all_tags[] = { { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout }, { WPS_TOKEN_CURRENT_SCREEN, "cs", WPS_REFRESH_DYNAMIC, NULL }, { WPS_NO_TOKEN, "T", 0, parse_touchregion }, - + + + /* Recording Tokens */ + { WPS_TOKEN_HAVE_RECORDING, "Rp", WPS_REFRESH_STATIC, NULL }, +#ifdef HAVE_RECORDING + { WPS_TOKEN_REC_FREQ, "Rf", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_REC_ENCODER, "Re", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_REC_BITRATE, "Rb", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_REC_MONO, "Rm", WPS_REFRESH_DYNAMIC, NULL }, +#endif { WPS_TOKEN_UNKNOWN, "", 0, NULL } /* the array MUST end with an empty string (first char is \0) */ }; @@ -1461,6 +1470,12 @@ static int check_feature_tag(const char *wps_bufptr, const int type) #else return find_false_branch(wps_bufptr); #endif + case WPS_TOKEN_HAVE_RECORDING: +#ifdef HAVE_RECORDING + return 0; +#else + return find_false_branch(wps_bufptr); +#endif default: /* not a tag we care about, just don't skip */ return 0; } diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 46adbdc097..c599adf833 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -56,6 +56,7 @@ #include "root_menu.h" #ifdef HAVE_RECORDING #include "recording.h" +#include "pcm_record.h" #endif static char* get_codectype(const struct mp3entry* id3) @@ -873,6 +874,201 @@ const char *get_token_value(struct gui_wps *gwps, cfg_to_string(token->value.i,buf,buf_size); return buf; } + /* Recording tokens */ + case WPS_TOKEN_HAVE_RECORDING: +#ifdef HAVE_RECORDING + return "r"; +#else + return NULL; +#endif + +#ifdef HAVE_RECORDING + case WPS_TOKEN_REC_FREQ: /* order from REC_FREQ_CFG_VAL_LIST */ + { +#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) + { + 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;) + } + *intval = rec_freq+1; + } + snprintf(buf, buf_size, "%d.%1d", samprk/1000,samprk%1000); +#else /* HWCODEC */ + + static const char * const freq_strings[] = + {"--", "44", "48", "32", "22", "24", "16"}; + 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 */ + snprintf(buf, buf_size, "%d\n", + freq_strings[global_settings.rec_frequency]); +#endif + return buf; + } +#if CONFIG_CODEC == SWCODEC + case WPS_TOKEN_REC_ENCODER: + { + 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 + case WPS_TOKEN_REC_BITRATE: +#if CONFIG_CODEC == SWCODEC + if (global_settings.rec_format == REC_FORMAT_MPA_L3) + { + if (intval) + { + #if 0 /* FIXME: I dont know if this is needed? */ + switch (1<