diff options
Diffstat (limited to 'apps/gui/skin_engine/skin_tokens.c')
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 5228dd16bc..486a2efc76 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c | |||
@@ -158,6 +158,8 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, | |||
158 | struct wps_state *state = &wps_state; | 158 | struct wps_state *state = &wps_state; |
159 | if (id3) | 159 | if (id3) |
160 | { | 160 | { |
161 | unsigned long length = id3->length; | ||
162 | unsigned long elapsed = id3->elapsed + state->ff_rewind_count; | ||
161 | switch (token->type) | 163 | switch (token->type) |
162 | { | 164 | { |
163 | case WPS_TOKEN_METADATA_ARTIST: | 165 | case WPS_TOKEN_METADATA_ARTIST: |
@@ -216,9 +218,9 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, | |||
216 | } | 218 | } |
217 | return NULL; | 219 | return NULL; |
218 | case WPS_TOKEN_METADATA_COMMENT: | 220 | case WPS_TOKEN_METADATA_COMMENT: |
219 | return id3->comment; | 221 | return id3->comment; |
220 | case WPS_TOKEN_FILE_PATH: | 222 | case WPS_TOKEN_FILE_PATH: |
221 | return id3->path; | 223 | return id3->path; |
222 | case WPS_TOKEN_FILE_BITRATE: | 224 | case WPS_TOKEN_FILE_BITRATE: |
223 | if(id3->bitrate) | 225 | if(id3->bitrate) |
224 | snprintf(buf, buf_size, "%d", id3->bitrate); | 226 | snprintf(buf, buf_size, "%d", id3->bitrate); |
@@ -226,31 +228,26 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, | |||
226 | return "?"; | 228 | return "?"; |
227 | return buf; | 229 | return buf; |
228 | case WPS_TOKEN_TRACK_TIME_ELAPSED: | 230 | case WPS_TOKEN_TRACK_TIME_ELAPSED: |
229 | format_time(buf, buf_size, | 231 | format_time(buf, buf_size, elapsed); |
230 | id3->elapsed + state->ff_rewind_count); | ||
231 | return buf; | 232 | return buf; |
232 | 233 | ||
233 | case WPS_TOKEN_TRACK_TIME_REMAINING: | 234 | case WPS_TOKEN_TRACK_TIME_REMAINING: |
234 | format_time(buf, buf_size, | 235 | format_time(buf, buf_size, length - elapsed); |
235 | id3->length - id3->elapsed - | ||
236 | state->ff_rewind_count); | ||
237 | return buf; | 236 | return buf; |
238 | 237 | ||
239 | case WPS_TOKEN_TRACK_LENGTH: | 238 | case WPS_TOKEN_TRACK_LENGTH: |
240 | format_time(buf, buf_size, id3->length); | 239 | format_time(buf, buf_size, length); |
241 | return buf; | 240 | return buf; |
242 | 241 | ||
243 | case WPS_TOKEN_TRACK_ELAPSED_PERCENT: | 242 | case WPS_TOKEN_TRACK_ELAPSED_PERCENT: |
244 | if (id3->length <= 0) | 243 | if (length <= 0) |
245 | return NULL; | 244 | return NULL; |
246 | 245 | ||
247 | if (intval) | 246 | if (intval) |
248 | { | 247 | { |
249 | *intval = limit * (id3->elapsed + state->ff_rewind_count) | 248 | *intval = limit * elapsed / length + 1; |
250 | / id3->length + 1; | ||
251 | } | 249 | } |
252 | snprintf(buf, buf_size, "%d", | 250 | snprintf(buf, buf_size, "%d", 100 * elapsed / length); |
253 | 100*(id3->elapsed + state->ff_rewind_count) / id3->length); | ||
254 | return buf; | 251 | return buf; |
255 | 252 | ||
256 | 253 | ||
@@ -295,7 +292,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, | |||
295 | return (id3->vbr) ? "(avg)" : NULL; | 292 | return (id3->vbr) ? "(avg)" : NULL; |
296 | case WPS_TOKEN_FILE_DIRECTORY: | 293 | case WPS_TOKEN_FILE_DIRECTORY: |
297 | return get_dir(buf, buf_size, id3->path, token->value.i); | 294 | return get_dir(buf, buf_size, id3->path, token->value.i); |
298 | 295 | ||
299 | #ifdef HAVE_TAGCACHE | 296 | #ifdef HAVE_TAGCACHE |
300 | case WPS_TOKEN_DATABASE_PLAYCOUNT: | 297 | case WPS_TOKEN_DATABASE_PLAYCOUNT: |
301 | if (intval) | 298 | if (intval) |
@@ -313,7 +310,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, | |||
313 | snprintf(buf, buf_size, "%ld", id3->score); | 310 | snprintf(buf, buf_size, "%ld", id3->score); |
314 | return buf; | 311 | return buf; |
315 | #endif | 312 | #endif |
316 | 313 | ||
317 | default: | 314 | default: |
318 | return NULL; | 315 | return NULL; |
319 | } | 316 | } |
@@ -326,7 +323,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, | |||
326 | * The ones that expect "0" need to be handled */ | 323 | * The ones that expect "0" need to be handled */ |
327 | case WPS_TOKEN_FILE_FREQUENCY: | 324 | case WPS_TOKEN_FILE_FREQUENCY: |
328 | case WPS_TOKEN_FILE_FREQUENCY_KHZ: | 325 | case WPS_TOKEN_FILE_FREQUENCY_KHZ: |
329 | case WPS_TOKEN_FILE_SIZE: | 326 | case WPS_TOKEN_FILE_SIZE: |
330 | #ifdef HAVE_TAGCACHE | 327 | #ifdef HAVE_TAGCACHE |
331 | case WPS_TOKEN_DATABASE_PLAYCOUNT: | 328 | case WPS_TOKEN_DATABASE_PLAYCOUNT: |
332 | case WPS_TOKEN_DATABASE_RATING: | 329 | case WPS_TOKEN_DATABASE_RATING: |
@@ -443,7 +440,8 @@ const char *get_token_value(struct gui_wps *gwps, | |||
443 | snprintf(buf, buf_size, "%d", global_settings.volume); | 440 | snprintf(buf, buf_size, "%d", global_settings.volume); |
444 | if (intval) | 441 | if (intval) |
445 | { | 442 | { |
446 | if (global_settings.volume == sound_min(SOUND_VOLUME)) | 443 | int minvol = sound_min(SOUND_VOLUME); |
444 | if (global_settings.volume == minvol) | ||
447 | { | 445 | { |
448 | *intval = 1; | 446 | *intval = 1; |
449 | } | 447 | } |
@@ -457,9 +455,8 @@ const char *get_token_value(struct gui_wps *gwps, | |||
457 | } | 455 | } |
458 | else | 456 | else |
459 | { | 457 | { |
460 | *intval = (limit - 3) * (global_settings.volume | 458 | *intval = (limit-3) * (global_settings.volume - minvol - 1) |
461 | - sound_min(SOUND_VOLUME) - 1) | 459 | / (-1 - minvol) + 2; |
462 | / (-1 - sound_min(SOUND_VOLUME)) + 2; | ||
463 | } | 460 | } |
464 | } | 461 | } |
465 | return buf; | 462 | return buf; |
@@ -473,7 +470,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
473 | 470 | ||
474 | case WPS_TOKEN_ALBUMART_DISPLAY: | 471 | case WPS_TOKEN_ALBUMART_DISPLAY: |
475 | if (!data->albumart) | 472 | if (!data->albumart) |
476 | return NULL; | 473 | return NULL; |
477 | if (!data->albumart->draw) | 474 | if (!data->albumart->draw) |
478 | data->albumart->draw = true; | 475 | data->albumart->draw = true; |
479 | return NULL; | 476 | return NULL; |
@@ -801,7 +798,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
801 | id3->album_gain_string != NULL); | 798 | id3->album_gain_string != NULL); |
802 | else | 799 | else |
803 | type = -1; | 800 | type = -1; |
804 | 801 | ||
805 | if (type < 0) | 802 | if (type < 0) |
806 | val = 6; /* no tag */ | 803 | val = 6; /* no tag */ |
807 | else | 804 | else |
@@ -923,7 +920,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
923 | int sound_setting = s->sound_setting->setting; | 920 | int sound_setting = s->sound_setting->setting; |
924 | /* settings with decimals can't be used in conditionals */ | 921 | /* settings with decimals can't be used in conditionals */ |
925 | if (sound_numdecimals(sound_setting) == 0) | 922 | if (sound_numdecimals(sound_setting) == 0) |
926 | { | 923 | { |
927 | *intval = (*(int*)s->setting-sound_min(sound_setting)) | 924 | *intval = (*(int*)s->setting-sound_min(sound_setting)) |
928 | /sound_steps(sound_setting) + 1; | 925 | /sound_steps(sound_setting) + 1; |
929 | } | 926 | } |
@@ -999,7 +996,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
999 | rec_freq = 0; | 996 | rec_freq = 0; |
1000 | while (rec_freq < SAMPR_NUM_FREQ && | 997 | while (rec_freq < SAMPR_NUM_FREQ && |
1001 | audio_master_sampr_list[rec_freq] != samprk) | 998 | audio_master_sampr_list[rec_freq] != samprk) |
1002 | { | 999 | { |
1003 | rec_freq++; | 1000 | rec_freq++; |
1004 | } | 1001 | } |
1005 | } | 1002 | } |
@@ -1053,7 +1050,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
1053 | #else /* HWCODEC */ | 1050 | #else /* HWCODEC */ |
1054 | 1051 | ||
1055 | static const char * const freq_strings[] = | 1052 | static const char * const freq_strings[] = |
1056 | {"--", "44", "48", "32", "22", "24", "16"}; | 1053 | {"--", "44", "48", "32", "22", "24", "16"}; |
1057 | int freq = 1 + global_settings.rec_frequency; | 1054 | int freq = 1 + global_settings.rec_frequency; |
1058 | #ifdef HAVE_SPDIF_REC | 1055 | #ifdef HAVE_SPDIF_REC |
1059 | if (global_settings.rec_source == AUDIO_SRC_SPDIF) | 1056 | if (global_settings.rec_source == AUDIO_SRC_SPDIF) |
@@ -1069,7 +1066,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
1069 | #endif | 1066 | #endif |
1070 | return buf; | 1067 | return buf; |
1071 | } | 1068 | } |
1072 | #if CONFIG_CODEC == SWCODEC | 1069 | #if CONFIG_CODEC == SWCODEC |
1073 | case WPS_TOKEN_REC_ENCODER: | 1070 | case WPS_TOKEN_REC_ENCODER: |
1074 | { | 1071 | { |
1075 | int rec_format = global_settings.rec_format+1; /* WAV, AIFF, WV, MPEG */ | 1072 | int rec_format = global_settings.rec_format+1; /* WAV, AIFF, WV, MPEG */ |
@@ -1092,7 +1089,7 @@ const char *get_token_value(struct gui_wps *gwps, | |||
1092 | } | 1089 | } |
1093 | #endif | 1090 | #endif |
1094 | case WPS_TOKEN_REC_BITRATE: | 1091 | case WPS_TOKEN_REC_BITRATE: |
1095 | #if CONFIG_CODEC == SWCODEC | 1092 | #if CONFIG_CODEC == SWCODEC |
1096 | if (global_settings.rec_format == REC_FORMAT_MPA_L3) | 1093 | if (global_settings.rec_format == REC_FORMAT_MPA_L3) |
1097 | { | 1094 | { |
1098 | if (intval) | 1095 | if (intval) |
@@ -1201,7 +1198,6 @@ const char *get_token_value(struct gui_wps *gwps, | |||
1201 | } | 1198 | } |
1202 | if (intval) | 1199 | if (intval) |
1203 | { | 1200 | { |
1204 | |||
1205 | *intval = curr_screen; | 1201 | *intval = curr_screen; |
1206 | } | 1202 | } |
1207 | snprintf(buf, buf_size, "%d", curr_screen); | 1203 | snprintf(buf, buf_size, "%d", curr_screen); |