1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002-2007 Björn Stenberg
11 * Copyright (C) 2007-2008 Nicolas Pennequin
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
29 #include "settings_list.h"
30 #include "rbunicode.h"
31 #include "timefuncs.h"
34 #include "powermgmt.h"
37 #ifdef HAVE_LCD_CHARCELLS
44 #ifdef HAVE_LCD_BITMAP
50 #if CONFIG_CODEC == SWCODEC
55 #include "wps_internals.h"
56 #include "root_menu.h"
58 #include "recording.h"
59 #include "pcm_record.h"
62 static char* get_codectype(const struct mp3entry
* id3
)
64 if (id3
&& id3
->codectype
< AFMT_NUM_CODECS
) {
65 return (char*)audio_formats
[id3
->codectype
].label
;
71 /* Extract a part from a path.
73 * buf - buffer extract part to.
74 * buf_size - size of buffer.
75 * path - path to extract from.
76 * level - what to extract. 0 is file name, 1 is parent of file, 2 is
77 * parent of parent, etc.
79 * Returns buf if the desired level was found, NULL otherwise.
81 static char* get_dir(char* buf
, int buf_size
, const char* path
, int level
)
87 sep
= path
+ strlen(path
);
102 if (level
|| (last_sep
<= sep
))
105 len
= MIN(last_sep
- sep
, buf_size
- 1);
106 strlcpy(buf
, sep
+ 1, len
+ 1);
110 #if (CONFIG_CODEC != MAS3507D)
111 /* A helper to determine the enum value for pitch/speed.
113 When there are two choices (i.e. boolean), return 1 if the value is
114 different from normal value and 2 if the value is the same as the
115 normal value. E.g. "%?Sp<%Sp>" would show the pitch only when
116 playing at a modified pitch.
118 When there are more than two choices (i.e. enum), the left half of
119 the choices are to show 0..normal range, and the right half of the
120 choices are to show values over that. The last entry is used when
121 it is set to the normal setting, following the rockbox convention
122 to use the last entry for special values.
126 2 items: %?Sp<0..99 or 101..infinity|100>
127 3 items: %?Sp<0..99|101..infinity|100>
128 4 items: %?Sp<0..49|50..99|101..infinity|100>
129 5 items: %?Sp<0..49|50..99|101..149|150..infinity|100>
130 6 items: %?Sp<0..33|34..66|67..99|101..133|134..infinity|100>
131 7 items: %?Sp<0..33|34..66|67..99|101..133|134..167|167..infinity|100>
133 static int pitch_speed_enum(int range
, int32_t val
, int32_t normval
)
139 return (val
== normval
) + 1;
143 n
= (center
* val
) / normval
+ 1;
144 return (range
<= n
) ? (range
- 1) : n
;
148 /* Return the tag found at index i and write its value in buf.
149 The return value is buf if the tag had a value, or NULL if not.
151 intval is used with conditionals/enums: when this function is called,
152 intval should contain the number of options in the conditional/enum.
153 When this function returns, intval is -1 if the tag is non numeric or,
154 if the tag is numeric, *intval is the enum case we want to go to (between 1
155 and the original value of *intval, inclusive).
156 When not treating a conditional/enum, intval should be NULL.
159 /* a few convinience macros for the id3 == NULL case
160 * depends on a few variable names in get_token_value() */
162 #define HANDLE_NULL_ID3(id3field) (LIKELY(id3) ? (id3field) : NULL)
164 #define HANDLE_NULL_ID3_NUM_ZERO { if (UNLIKELY(!id3)) return zero_str; }
166 #define HANDLE_NULL_ID3_NUM_INTVAL(id3field) \
169 *intval = (LIKELY(id3) ? (id3field) + 1 : 0); \
173 snprintf(buf, buf_size, "%ld", (id3field)); \
179 const char *get_token_value(struct gui_wps
*gwps
,
180 struct wps_token
*token
,
181 char *buf
, int buf_size
,
187 struct wps_data
*data
= gwps
->data
;
188 struct wps_state
*state
= gwps
->state
;
190 static const char * const zero_str
= "0";
195 struct mp3entry
*id3
;
204 elapsed
= id3
->elapsed
;
205 length
= id3
->length
;
214 struct tm
* tm
= NULL
;
216 /* if the token is an RTC one, update the time
217 and do the necessary checks */
218 if (token
->type
>= WPS_TOKENS_RTC_BEGIN
219 && token
->type
<= WPS_TOKENS_RTC_END
)
237 case WPS_TOKEN_CHARACTER
:
238 if (token
->value
.c
== '\n')
240 return &(token
->value
.c
);
242 case WPS_TOKEN_STRING
:
243 return (char*)token
->value
.data
;
245 case WPS_TOKEN_TRANSLATEDSTRING
:
246 return (char*)P2STR(ID2P(token
->value
.i
));
248 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
249 format_time(buf
, buf_size
,
250 elapsed
+ state
->ff_rewind_count
);
253 case WPS_TOKEN_TRACK_TIME_REMAINING
:
254 format_time(buf
, buf_size
,
256 state
->ff_rewind_count
);
259 case WPS_TOKEN_TRACK_LENGTH
:
260 format_time(buf
, buf_size
, length
);
263 case WPS_TOKEN_PLAYLIST_ENTRIES
:
264 snprintf(buf
, buf_size
, "%d", playlist_amount());
267 case WPS_TOKEN_PLAYLIST_NAME
:
268 return playlist_name(NULL
, buf
, buf_size
);
270 case WPS_TOKEN_PLAYLIST_POSITION
:
271 snprintf(buf
, buf_size
, "%d", playlist_get_display_index());
274 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
275 if ( global_settings
.playlist_shuffle
)
281 case WPS_TOKEN_VOLUME
:
282 snprintf(buf
, buf_size
, "%d", global_settings
.volume
);
285 if (global_settings
.volume
== sound_min(SOUND_VOLUME
))
289 else if (global_settings
.volume
== 0)
293 else if (global_settings
.volume
> 0)
299 *intval
= (limit
- 3) * (global_settings
.volume
300 - sound_min(SOUND_VOLUME
) - 1)
301 / (-1 - sound_min(SOUND_VOLUME
)) + 2;
306 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
312 *intval
= limit
* (elapsed
+ state
->ff_rewind_count
)
315 snprintf(buf
, buf_size
, "%d",
316 100*(elapsed
+ state
->ff_rewind_count
) / length
);
319 case WPS_TOKEN_METADATA_ARTIST
:
320 return HANDLE_NULL_ID3(id3
->artist
);
322 case WPS_TOKEN_METADATA_COMPOSER
:
323 return HANDLE_NULL_ID3(id3
->composer
);
325 case WPS_TOKEN_METADATA_ALBUM
:
326 return HANDLE_NULL_ID3(id3
->album
);
328 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
329 return HANDLE_NULL_ID3(id3
->albumartist
);
331 case WPS_TOKEN_METADATA_GROUPING
:
332 return HANDLE_NULL_ID3(id3
->grouping
);
334 case WPS_TOKEN_METADATA_GENRE
:
335 return HANDLE_NULL_ID3(id3
->genre_string
);
337 case WPS_TOKEN_METADATA_DISC_NUMBER
:
339 if (id3
->disc_string
)
340 return id3
->disc_string
;
342 snprintf(buf
, buf_size
, "%d", id3
->discnum
);
348 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
350 if (id3
->track_string
)
351 return id3
->track_string
;
354 snprintf(buf
, buf_size
, "%d", id3
->tracknum
);
360 case WPS_TOKEN_METADATA_TRACK_TITLE
:
361 return HANDLE_NULL_ID3(id3
->title
);
363 case WPS_TOKEN_METADATA_VERSION
:
366 switch (id3
->id3version
)
389 case WPS_TOKEN_METADATA_YEAR
:
391 if( id3
->year_string
)
392 return id3
->year_string
;
395 snprintf(buf
, buf_size
, "%d", id3
->year
);
401 case WPS_TOKEN_METADATA_COMMENT
:
402 return HANDLE_NULL_ID3(id3
->comment
);
405 case WPS_TOKEN_ALBUMART_FOUND
:
406 if (data
->albumart
) {
407 if (playback_current_aa_hid(data
->playback_aa_slot
) >= 0)
412 case WPS_TOKEN_ALBUMART_DISPLAY
:
415 if (!data
->albumart
->draw
)
416 data
->albumart
->draw
= true;
420 case WPS_TOKEN_FILE_BITRATE
:
421 if(id3
&& id3
->bitrate
)
422 snprintf(buf
, buf_size
, "%d", id3
->bitrate
);
427 case WPS_TOKEN_FILE_CODEC
:
432 else if(id3
->codectype
== AFMT_UNKNOWN
)
433 *intval
= AFMT_NUM_CODECS
;
435 *intval
= id3
->codectype
;
437 return get_codectype(id3
);
439 case WPS_TOKEN_FILE_FREQUENCY
:
440 HANDLE_NULL_ID3_NUM_ZERO
;
441 snprintf(buf
, buf_size
, "%ld", id3
->frequency
);
444 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
445 HANDLE_NULL_ID3_NUM_ZERO
;
446 /* ignore remainders < 100, so 22050 Hz becomes just 22k */
447 if ((id3
->frequency
% 1000) < 100)
448 snprintf(buf
, buf_size
, "%ld", id3
->frequency
/ 1000);
450 snprintf(buf
, buf_size
, "%ld.%d",
451 id3
->frequency
/ 1000,
452 (id3
->frequency
% 1000) / 100);
455 case WPS_TOKEN_FILE_NAME
:
456 if (LIKELY(id3
) && get_dir(buf
, buf_size
, id3
->path
, 0)) {
457 /* Remove extension */
458 char* sep
= strrchr(buf
, '.');
468 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
470 return get_dir(buf
, buf_size
, id3
->path
, 0);
473 case WPS_TOKEN_FILE_PATH
:
474 return HANDLE_NULL_ID3(id3
->path
);
476 case WPS_TOKEN_FILE_SIZE
:
477 HANDLE_NULL_ID3_NUM_ZERO
;
478 snprintf(buf
, buf_size
, "%ld", id3
->filesize
/ 1024);
481 case WPS_TOKEN_FILE_VBR
:
482 return (LIKELY(id3
) && id3
->vbr
) ? "(avg)" : NULL
;
484 case WPS_TOKEN_FILE_DIRECTORY
:
486 return get_dir(buf
, buf_size
, id3
->path
, token
->value
.i
);
489 case WPS_TOKEN_BATTERY_PERCENT
:
491 int l
= battery_level();
495 limit
= MAX(limit
, 2);
497 /* First enum is used for "unknown level". */
498 *intval
= (limit
- 1) * l
/ 100 + 2;
505 snprintf(buf
, buf_size
, "%d", l
);
512 case WPS_TOKEN_BATTERY_VOLTS
:
514 unsigned int v
= battery_voltage();
515 snprintf(buf
, buf_size
, "%d.%02d", v
/ 1000, (v
% 1000) / 10);
519 case WPS_TOKEN_BATTERY_TIME
:
521 int t
= battery_time();
523 snprintf(buf
, buf_size
, "%dh %dm", t
/ 60, t
% 60);
530 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
532 if(charger_input_state
==CHARGER
)
538 #if CONFIG_CHARGING >= CHARGING_MONITOR
539 case WPS_TOKEN_BATTERY_CHARGING
:
541 if (charge_state
== CHARGING
|| charge_state
== TOPOFF
) {
548 case WPS_TOKEN_BATTERY_SLEEPTIME
:
550 if (get_sleep_timer() == 0)
554 format_time(buf
, buf_size
, get_sleep_timer() * 1000);
559 case WPS_TOKEN_PLAYBACK_STATUS
:
561 int status
= current_playmode();
563 int mode
= 1; /* stop */
564 if (status
== STATUS_PLAY
)
566 if (state
->is_fading
||
567 (status
== STATUS_PAUSE
&& !status_get_ffmode()))
568 mode
= 3; /* pause */
571 if (status_get_ffmode() == STATUS_FASTFORWARD
)
573 if (status_get_ffmode() == STATUS_FASTBACKWARD
)
576 #ifdef HAVE_RECORDING
578 if (status
== STATUS_RECORD
)
580 else if (status
== STATUS_RECORD_PAUSE
)
585 if (status
== STATUS_RADIO
)
587 else if (status
== STATUS_RADIO_PAUSE
)
595 snprintf(buf
, buf_size
, "%d", mode
-1);
599 case WPS_TOKEN_REPEAT_MODE
:
601 *intval
= global_settings
.repeat_mode
+ 1;
602 snprintf(buf
, buf_size
, "%d", global_settings
.repeat_mode
);
605 case WPS_TOKEN_RTC_PRESENT
:
613 case WPS_TOKEN_RTC_12HOUR_CFG
:
615 *intval
= global_settings
.timeformat
+ 1;
616 snprintf(buf
, buf_size
, "%d", global_settings
.timeformat
);
619 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
620 /* d: day of month (01..31) */
621 snprintf(buf
, buf_size
, "%02d", tm
->tm_mday
);
624 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
625 /* e: day of month, blank padded ( 1..31) */
626 snprintf(buf
, buf_size
, "%2d", tm
->tm_mday
);
629 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
630 /* H: hour (00..23) */
631 snprintf(buf
, buf_size
, "%02d", tm
->tm_hour
);
634 case WPS_TOKEN_RTC_HOUR_24
:
635 /* k: hour ( 0..23) */
636 snprintf(buf
, buf_size
, "%2d", tm
->tm_hour
);
639 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
640 /* I: hour (01..12) */
641 snprintf(buf
, buf_size
, "%02d",
642 (tm
->tm_hour
% 12 == 0) ? 12 : tm
->tm_hour
% 12);
645 case WPS_TOKEN_RTC_HOUR_12
:
646 /* l: hour ( 1..12) */
647 snprintf(buf
, buf_size
, "%2d",
648 (tm
->tm_hour
% 12 == 0) ? 12 : tm
->tm_hour
% 12);
651 case WPS_TOKEN_RTC_MONTH
:
652 /* m: month (01..12) */
654 *intval
= tm
->tm_mon
+ 1;
655 snprintf(buf
, buf_size
, "%02d", tm
->tm_mon
+ 1);
658 case WPS_TOKEN_RTC_MINUTE
:
659 /* M: minute (00..59) */
660 snprintf(buf
, buf_size
, "%02d", tm
->tm_min
);
663 case WPS_TOKEN_RTC_SECOND
:
664 /* S: second (00..59) */
665 snprintf(buf
, buf_size
, "%02d", tm
->tm_sec
);
668 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
669 /* y: last two digits of year (00..99) */
670 snprintf(buf
, buf_size
, "%02d", tm
->tm_year
% 100);
673 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
674 /* Y: year (1970...) */
675 snprintf(buf
, buf_size
, "%04d", tm
->tm_year
+ 1900);
678 case WPS_TOKEN_RTC_AM_PM_UPPER
:
679 /* p: upper case AM or PM indicator */
680 return tm
->tm_hour
/12 == 0 ? "AM" : "PM";
682 case WPS_TOKEN_RTC_AM_PM_LOWER
:
683 /* P: lower case am or pm indicator */
684 return tm
->tm_hour
/12 == 0 ? "am" : "pm";
686 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
687 /* a: abbreviated weekday name (Sun..Sat) */
688 return str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
);
690 case WPS_TOKEN_RTC_MONTH_NAME
:
691 /* b: abbreviated month name (Jan..Dec) */
692 return str(LANG_MONTH_JANUARY
+ tm
->tm_mon
);
694 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
695 /* u: day of week (1..7); 1 is Monday */
697 *intval
= (tm
->tm_wday
== 0) ? 7 : tm
->tm_wday
;
698 snprintf(buf
, buf_size
, "%1d", tm
->tm_wday
+ 1);
701 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
702 /* w: day of week (0..6); 0 is Sunday */
704 *intval
= tm
->tm_wday
+ 1;
705 snprintf(buf
, buf_size
, "%1d", tm
->tm_wday
);
708 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
709 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
710 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
711 case WPS_TOKEN_RTC_HOUR_24
:
712 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
713 case WPS_TOKEN_RTC_HOUR_12
:
714 case WPS_TOKEN_RTC_MONTH
:
715 case WPS_TOKEN_RTC_MINUTE
:
716 case WPS_TOKEN_RTC_SECOND
:
717 case WPS_TOKEN_RTC_AM_PM_UPPER
:
718 case WPS_TOKEN_RTC_AM_PM_LOWER
:
719 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
721 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
723 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
724 case WPS_TOKEN_RTC_MONTH_NAME
:
726 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
727 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
731 #ifdef HAVE_LCD_CHARCELLS
732 case WPS_TOKEN_PROGRESSBAR
:
734 char *end
= utf8encode(data
->wps_progress_pat
[0], buf
);
739 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
742 /* we need 11 characters (full line) for
744 strlcpy(buf
, " ", buf_size
);
748 /* Tell the user if we have an OldPlayer */
749 strlcpy(buf
, " <Old LCD> ", buf_size
);
756 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
757 HANDLE_NULL_ID3_NUM_INTVAL(id3
->playcount
);
759 case WPS_TOKEN_DATABASE_RATING
:
760 HANDLE_NULL_ID3_NUM_INTVAL(id3
->rating
);
762 case WPS_TOKEN_DATABASE_AUTOSCORE
:
763 HANDLE_NULL_ID3_NUM_INTVAL(id3
->score
);
766 #if (CONFIG_CODEC == SWCODEC)
767 case WPS_TOKEN_CROSSFADE
:
769 *intval
= global_settings
.crossfade
+ 1;
770 snprintf(buf
, buf_size
, "%d", global_settings
.crossfade
);
773 case WPS_TOKEN_REPLAYGAIN
:
777 if (global_settings
.replaygain_type
== REPLAYGAIN_OFF
)
783 type
= get_replaygain_mode(id3
->track_gain_string
!= NULL
,
784 id3
->album_gain_string
!= NULL
);
789 val
= 6; /* no tag */
793 if (global_settings
.replaygain_type
== REPLAYGAIN_SHUFFLE
)
806 /* due to above, coming here with !id3 shouldn't be possible */
809 strlcpy(buf
, id3
->track_gain_string
, buf_size
);
813 strlcpy(buf
, id3
->album_gain_string
, buf_size
);
818 #endif /* (CONFIG_CODEC == SWCODEC) */
820 #if (CONFIG_CODEC != MAS3507D)
821 case WPS_TOKEN_SOUND_PITCH
:
823 int32_t pitch
= sound_get_pitch();
824 snprintf(buf
, buf_size
, "%ld.%ld",
825 pitch
/ PITCH_SPEED_PRECISION
,
826 (pitch
% PITCH_SPEED_PRECISION
) / (PITCH_SPEED_PRECISION
/ 10));
829 *intval
= pitch_speed_enum(limit
, pitch
,
830 PITCH_SPEED_PRECISION
* 100);
835 case WPS_TOKEN_MAIN_HOLD
:
836 #ifdef HAS_BUTTON_HOLD
839 if (is_keys_locked())
840 #endif /*hold switch or softlock*/
845 #ifdef HAS_REMOTE_BUTTON_HOLD
846 case WPS_TOKEN_REMOTE_HOLD
:
847 if (remote_button_hold())
853 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
854 case WPS_TOKEN_VLED_HDD
:
860 case WPS_TOKEN_BUTTON_VOLUME
:
861 if (global_status
.last_volume_change
&&
862 TIME_BEFORE(current_tick
, global_status
.last_volume_change
+
863 token
->value
.i
* TIMEOUT_UNIT
))
866 case WPS_TOKEN_LASTTOUCH
:
867 #ifdef HAVE_TOUCHSCREEN
868 if (TIME_BEFORE(current_tick
, token
->value
.i
* TIMEOUT_UNIT
+
869 touchscreen_last_touch()))
874 case WPS_TOKEN_SETTING
:
878 /* Handle contionals */
879 const struct settings_list
*s
= settings
+token
->value
.i
;
880 switch (s
->flags
&F_T_MASK
)
885 /* %?St|name|<#000000|#000001|...|#FFFFFF> */
886 /* shouldn't overflow since colors are stored
888 * but this is pretty useless anyway */
889 *intval
= *(int*)s
->setting
+ 1;
890 else if (s
->cfg_vals
== NULL
)
891 /* %?St|name|<1st choice|2nd choice|...> */
892 *intval
= (*(int*)s
->setting
-s
->int_setting
->min
)
893 /s
->int_setting
->step
+ 1;
895 /* %?St|name|<1st choice|2nd choice|...> */
896 /* Not sure about this one. cfg_name/vals are
897 * indexed from 0 right? */
898 *intval
= *(int*)s
->setting
+ 1;
901 /* %?St|name|<if true|if false> */
902 *intval
= *(bool*)s
->setting
?1:2;
905 /* %?St|name|<if non empty string|if empty>
906 * The string's emptyness discards the setting's
907 * prefix and suffix */
908 *intval
= ((char*)s
->setting
)[0]?1:2;
911 /* This shouldn't happen ... but you never know */
916 cfg_to_string(token
->value
.i
,buf
,buf_size
);
919 /* Recording tokens */
920 case WPS_TOKEN_HAVE_RECORDING
:
921 #ifdef HAVE_RECORDING
927 #ifdef HAVE_RECORDING
928 case WPS_TOKEN_REC_FREQ
: /* order from REC_FREQ_CFG_VAL_LIST */
930 #if CONFIG_CODEC == SWCODEC
931 unsigned long samprk
;
932 int rec_freq
= global_settings
.rec_frequency
;
937 #if defined(HAVE_SPDIF_REC)
938 if (global_settings
.rec_source
== AUDIO_SRC_SPDIF
)
940 /* Use rate in use, not current measured rate if it changed */
941 samprk
= pcm_rec_sample_rate();
943 while (rec_freq
< SAMPR_NUM_FREQ
&&
944 audio_master_sampr_list
[rec_freq
] != samprk
)
951 samprk
= rec_freq_sampr
[rec_freq
];
952 #endif /* SIMULATOR */
957 REC_HAVE_96_(case REC_FREQ_96
:
960 REC_HAVE_88_(case REC_FREQ_88
:
963 REC_HAVE_64_(case REC_FREQ_64
:
966 REC_HAVE_48_(case REC_FREQ_48
:
969 REC_HAVE_44_(case REC_FREQ_44
:
972 REC_HAVE_32_(case REC_FREQ_32
:
975 REC_HAVE_24_(case REC_FREQ_24
:
978 REC_HAVE_22_(case REC_FREQ_22
:
981 REC_HAVE_16_(case REC_FREQ_16
:
984 REC_HAVE_12_(case REC_FREQ_12
:
987 REC_HAVE_11_(case REC_FREQ_11
:
990 REC_HAVE_8_(case REC_FREQ_8
:
994 *intval
= rec_freq
+1;
996 snprintf(buf
, buf_size
, "%d.%1d", samprk
/1000,samprk
%1000);
999 static const char * const freq_strings
[] =
1000 {"--", "44", "48", "32", "22", "24", "16"};
1001 int freq
= 1 + global_settings
.rec_frequency
;
1002 #ifdef HAVE_SPDIF_REC
1003 if (global_settings
.rec_source
== AUDIO_SRC_SPDIF
)
1005 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
1008 #endif /* HAVE_SPDIF_IN */
1010 *intval
= freq
+1; /* so the token gets a value 1<=x<=7 */
1011 snprintf(buf
, buf_size
, "%d\n",
1012 freq_strings
[global_settings
.rec_frequency
]);
1016 #if CONFIG_CODEC == SWCODEC
1017 case WPS_TOKEN_REC_ENCODER
:
1019 int rec_format
= global_settings
.rec_format
+1; /* WAV, AIFF, WV, MPEG */
1021 *intval
= rec_format
;
1024 case REC_FORMAT_PCM_WAV
:
1026 case REC_FORMAT_AIFF
:
1028 case REC_FORMAT_WAVPACK
:
1030 case REC_FORMAT_MPA_L3
:
1038 case WPS_TOKEN_REC_BITRATE
:
1039 #if CONFIG_CODEC == SWCODEC
1040 if (global_settings
.rec_format
== REC_FORMAT_MPA_L3
)
1044 #if 0 /* FIXME: I dont know if this is needed? */
1045 switch (1<<global_settings
.mp3_enc_config
.bitrate
)
1047 case MP3_BITR_CAP_8
:
1050 case MP3_BITR_CAP_16
:
1053 case MP3_BITR_CAP_24
:
1056 case MP3_BITR_CAP_32
:
1059 case MP3_BITR_CAP_40
:
1062 case MP3_BITR_CAP_48
:
1065 case MP3_BITR_CAP_56
:
1068 case MP3_BITR_CAP_64
:
1071 case MP3_BITR_CAP_80
:
1074 case MP3_BITR_CAP_96
:
1077 case MP3_BITR_CAP_112
:
1080 case MP3_BITR_CAP_128
:
1083 case MP3_BITR_CAP_144
:
1086 case MP3_BITR_CAP_160
:
1089 case MP3_BITR_CAP_192
:
1095 *intval
= global_settings
.mp3_enc_config
.bitrate
+1;
1096 snprintf(buf
, buf_size
, "%d", global_settings
.mp3_enc_config
.bitrate
+1);
1100 return NULL
; /* Fixme later */
1101 #else /* CONFIG_CODEC == HWCODEC */
1103 *intval
= global_settings
.rec_quality
+1;
1104 snprintf(buf
, buf_size
, "%d", global_settings
.rec_quality
);
1107 case WPS_TOKEN_REC_MONO
:
1109 *intval
= global_settings
.rec_channels
?2:1;
1110 snprintf(buf
, buf_size
, "%s", !global_settings
.rec_channels
?"m":'\0');
1113 #endif /* HAVE_RECORDING */
1114 case WPS_TOKEN_CURRENT_SCREEN
:
1116 int curr_screen
= current_screen();
1118 #ifdef HAVE_RECORDING
1119 /* override current_screen() for recording screen since it may
1120 * be entered from the radio screen */
1121 if (in_recording_screen())
1122 curr_screen
= GO_TO_RECSCREEN
;
1125 switch (curr_screen
)
1130 #ifdef HAVE_RECORDING
1131 case GO_TO_RECSCREEN
:
1140 default: /* lists */
1147 *intval
= curr_screen
;
1149 snprintf(buf
, buf_size
, "%d", curr_screen
);