summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-11-03 07:58:10 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-11-03 07:58:10 +0000
commitf76b2f2046d1eaefae8bf6f46c6388817d8bc284 (patch)
treeed2fcefe7b595664f4bbaf6bcf4cf0b068e0a15a /apps
parentd06aafc03a594ed7ad8833babf78d31b091c72ee (diff)
downloadrockbox-f76b2f2046d1eaefae8bf6f46c6388817d8bc284.tar.gz
rockbox-f76b2f2046d1eaefae8bf6f46c6388817d8bc284.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/skin_engine/skin_parser.c17
-rw-r--r--apps/gui/skin_engine/skin_tokens.c196
-rw-r--r--apps/gui/skin_engine/skin_tokens.h7
3 files changed, 219 insertions, 1 deletions
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[] = {
360 { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout }, 360 { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout },
361 { WPS_TOKEN_CURRENT_SCREEN, "cs", WPS_REFRESH_DYNAMIC, NULL }, 361 { WPS_TOKEN_CURRENT_SCREEN, "cs", WPS_REFRESH_DYNAMIC, NULL },
362 { WPS_NO_TOKEN, "T", 0, parse_touchregion }, 362 { WPS_NO_TOKEN, "T", 0, parse_touchregion },
363 363
364
365 /* Recording Tokens */
366 { WPS_TOKEN_HAVE_RECORDING, "Rp", WPS_REFRESH_STATIC, NULL },
367#ifdef HAVE_RECORDING
368 { WPS_TOKEN_REC_FREQ, "Rf", WPS_REFRESH_DYNAMIC, NULL },
369 { WPS_TOKEN_REC_ENCODER, "Re", WPS_REFRESH_DYNAMIC, NULL },
370 { WPS_TOKEN_REC_BITRATE, "Rb", WPS_REFRESH_DYNAMIC, NULL },
371 { WPS_TOKEN_REC_MONO, "Rm", WPS_REFRESH_DYNAMIC, NULL },
372#endif
364 { WPS_TOKEN_UNKNOWN, "", 0, NULL } 373 { WPS_TOKEN_UNKNOWN, "", 0, NULL }
365 /* the array MUST end with an empty string (first char is \0) */ 374 /* the array MUST end with an empty string (first char is \0) */
366}; 375};
@@ -1461,6 +1470,12 @@ static int check_feature_tag(const char *wps_bufptr, const int type)
1461#else 1470#else
1462 return find_false_branch(wps_bufptr); 1471 return find_false_branch(wps_bufptr);
1463#endif 1472#endif
1473 case WPS_TOKEN_HAVE_RECORDING:
1474#ifdef HAVE_RECORDING
1475 return 0;
1476#else
1477 return find_false_branch(wps_bufptr);
1478#endif
1464 default: /* not a tag we care about, just don't skip */ 1479 default: /* not a tag we care about, just don't skip */
1465 return 0; 1480 return 0;
1466 } 1481 }
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 @@
56#include "root_menu.h" 56#include "root_menu.h"
57#ifdef HAVE_RECORDING 57#ifdef HAVE_RECORDING
58#include "recording.h" 58#include "recording.h"
59#include "pcm_record.h"
59#endif 60#endif
60 61
61static char* get_codectype(const struct mp3entry* id3) 62static char* get_codectype(const struct mp3entry* id3)
@@ -873,6 +874,201 @@ const char *get_token_value(struct gui_wps *gwps,
873 cfg_to_string(token->value.i,buf,buf_size); 874 cfg_to_string(token->value.i,buf,buf_size);
874 return buf; 875 return buf;
875 } 876 }
877 /* Recording tokens */
878 case WPS_TOKEN_HAVE_RECORDING:
879#ifdef HAVE_RECORDING
880 return "r";
881#else
882 return NULL;
883#endif
884
885#ifdef HAVE_RECORDING
886 case WPS_TOKEN_REC_FREQ: /* order from REC_FREQ_CFG_VAL_LIST */
887 {
888#if CONFIG_CODEC == SWCODEC
889 unsigned long samprk;
890 int rec_freq = global_settings.rec_frequency;
891
892#ifdef SIMULATOR
893 samprk = 44100;
894#else
895#if defined(HAVE_SPDIF_REC)
896 if (global_settings.rec_source == AUDIO_SRC_SPDIF)
897 {
898 /* Use rate in use, not current measured rate if it changed */
899 samprk = pcm_rec_sample_rate();
900 rec_freq = 0;
901 while (rec_freq < SAMPR_NUM_FREQ &&
902 audio_master_sampr_list[rec_freq] != samprk)
903 {
904 rec_freq++;
905 }
906 }
907 else
908#endif
909 samprk = rec_freq_sampr[rec_freq];
910#endif /* SIMULATOR */
911 if (intval)
912 {
913 switch (rec_freq)
914 {
915 REC_HAVE_96_(case REC_FREQ_96:
916 *intval = 1;
917 break;)
918 REC_HAVE_88_(case REC_FREQ_88:
919 *intval = 2;
920 break;)
921 REC_HAVE_64_(case REC_FREQ_64:
922 *intval = 3;
923 break;)
924 REC_HAVE_48_(case REC_FREQ_48:
925 *intval = 4;
926 break;)
927 REC_HAVE_44_(case REC_FREQ_44:
928 *intval = 5;
929 break;)
930 REC_HAVE_32_(case REC_FREQ_32:
931 *intval = 6;
932 break;)
933 REC_HAVE_24_(case REC_FREQ_24:
934 *intval = 7;
935 break;)
936 REC_HAVE_22_(case REC_FREQ_22:
937 *intval = 8;
938 break;)
939 REC_HAVE_16_(case REC_FREQ_16:
940 *intval = 9;
941 break;)
942 REC_HAVE_12_(case REC_FREQ_12:
943 *intval = 10;
944 break;)
945 REC_HAVE_11_(case REC_FREQ_11:
946 *intval = 11;
947 break;)
948 REC_HAVE_8_(case REC_FREQ_8:
949 *intval = 12;
950 break;)
951 }
952 *intval = rec_freq+1;
953 }
954 snprintf(buf, buf_size, "%d.%1d", samprk/1000,samprk%1000);
955#else /* HWCODEC */
956
957 static const char * const freq_strings[] =
958 {"--", "44", "48", "32", "22", "24", "16"};
959 int freq = 1 + global_settings.rec_frequency;
960#ifdef HAVE_SPDIF_REC
961 if (global_settings.rec_source == AUDIO_SRC_SPDIF)
962 {
963 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
964 freq = 0;
965 }
966#endif /* HAVE_SPDIF_IN */
967 if (intval)
968 *intval = freq+1; /* so the token gets a value 1<=x<=7 */
969 snprintf(buf, buf_size, "%d\n",
970 freq_strings[global_settings.rec_frequency]);
971#endif
972 return buf;
973 }
974#if CONFIG_CODEC == SWCODEC
975 case WPS_TOKEN_REC_ENCODER:
976 {
977 int rec_format = global_settings.rec_format+1; /* WAV, AIFF, WV, MPEG */
978 if (intval)
979 *intval = rec_format;
980 switch (rec_format)
981 {
982 case REC_FORMAT_PCM_WAV:
983 return "wav";
984 case REC_FORMAT_AIFF:
985 return "aiff";
986 case REC_FORMAT_WAVPACK:
987 return "wv";
988 case REC_FORMAT_MPA_L3:
989 return "MP3";
990 default:
991 return NULL;
992 }
993 break;
994 }
995#endif
996 case WPS_TOKEN_REC_BITRATE:
997#if CONFIG_CODEC == SWCODEC
998 if (global_settings.rec_format == REC_FORMAT_MPA_L3)
999 {
1000 if (intval)
1001 {
1002 #if 0 /* FIXME: I dont know if this is needed? */
1003 switch (1<<global_settings.mp3_enc_config.bitrate)
1004 {
1005 case MP3_BITR_CAP_8:
1006 *intval = 1;
1007 break;
1008 case MP3_BITR_CAP_16:
1009 *intval = 2;
1010 break;
1011 case MP3_BITR_CAP_24:
1012 *intval = 3;
1013 break;
1014 case MP3_BITR_CAP_32:
1015 *intval = 4;
1016 break;
1017 case MP3_BITR_CAP_40:
1018 *intval = 5;
1019 break;
1020 case MP3_BITR_CAP_48:
1021 *intval = 6;
1022 break;
1023 case MP3_BITR_CAP_56:
1024 *intval = 7;
1025 break;
1026 case MP3_BITR_CAP_64:
1027 *intval = 8;
1028 break;
1029 case MP3_BITR_CAP_80:
1030 *intval = 9;
1031 break;
1032 case MP3_BITR_CAP_96:
1033 *intval = 10;
1034 break;
1035 case MP3_BITR_CAP_112:
1036 *intval = 11;
1037 break;
1038 case MP3_BITR_CAP_128:
1039 *intval = 12;
1040 break;
1041 case MP3_BITR_CAP_144:
1042 *intval = 13;
1043 break;
1044 case MP3_BITR_CAP_160:
1045 *intval = 14;
1046 break;
1047 case MP3_BITR_CAP_192:
1048 *intval = 15;
1049 break;
1050 }
1051 #endif
1052 }
1053 *intval = global_settings.mp3_enc_config.bitrate+1;
1054 snprintf(buf, buf_size, "%d", global_settings.mp3_enc_config.bitrate+1);
1055 return buf;
1056 }
1057 else
1058 return NULL; /* Fixme later */
1059#else /* CONFIG_CODEC == HWCODEC */
1060 if (intval)
1061 *intval = global_settings.rec_quality+1;
1062 snprintf(buf, buf_size, "%d", global_settings.rec_quality);
1063 return buf;
1064#endif
1065 case WPS_TOKEN_REC_MONO:
1066 if (intval)
1067 *intval = global_settings.rec_channels?2:1;
1068 snprintf(buf, buf_size, "%s", !global_settings.rec_channels?"m":'\0');
1069 return buf;
1070
1071#endif /* HAVE_RECORDING */
876 case WPS_TOKEN_CURRENT_SCREEN: 1072 case WPS_TOKEN_CURRENT_SCREEN:
877 { 1073 {
878 int curr_screen = current_screen(); 1074 int curr_screen = current_screen();
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index 6d783551e6..31546b8cf6 100644
--- a/apps/gui/skin_engine/skin_tokens.h
+++ b/apps/gui/skin_engine/skin_tokens.h
@@ -193,6 +193,13 @@ enum wps_token_type {
193 /* Setting option */ 193 /* Setting option */
194 WPS_TOKEN_SETTING, 194 WPS_TOKEN_SETTING,
195 WPS_TOKEN_CURRENT_SCREEN, 195 WPS_TOKEN_CURRENT_SCREEN,
196
197 /* Recording Tokens */
198 WPS_TOKEN_HAVE_RECORDING,
199 WPS_TOKEN_REC_FREQ,
200 WPS_TOKEN_REC_ENCODER,
201 WPS_TOKEN_REC_BITRATE, /* SWCODEC: MP3 bitrate, HWCODEC: MP3 "quality" */
202 WPS_TOKEN_REC_MONO,
196}; 203};
197 204
198struct wps_token { 205struct wps_token {