diff options
-rw-r--r-- | apps/gui/skin_engine/skin_backdrops.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 55 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_fonts.c | 9 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_fonts.h | 1 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 32 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 52 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.h | 7 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_debug.c | 9 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 3 |
9 files changed, 77 insertions, 95 deletions
diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c index 8f928ff758..fd786a7882 100644 --- a/apps/gui/skin_engine/skin_backdrops.c +++ b/apps/gui/skin_engine/skin_backdrops.c @@ -93,7 +93,7 @@ char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen) { return backdrops[i].buffer; } - else if (backdrops[i].buffer == NULL) + else if (!bdrop && backdrops[i].buffer == NULL) { bdrop = &backdrops[i]; } @@ -107,7 +107,6 @@ char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen) loaded = screens[screen].backdrop_load(filename, bdrop->buffer); bdrop->screen = screen; strlcpy(bdrop->name, backdrop, MAX_FILENAME+1); - bdrop->name[MAX_FILENAME] = '\0'; return loaded ? bdrop->buffer : NULL; } @@ -117,4 +116,3 @@ void skin_backdrop_init(void) { } #endif - diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 316b97523c..97f9ee3748 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -116,13 +116,13 @@ void skin_statusbar_changed(struct gui_wps *skin) static void draw_progressbar(struct gui_wps *gwps, struct skin_viewport *wps_vp) - { +{ struct screen *display = gwps->display; struct wps_state *state = gwps->state; struct progressbar *pb = wps_vp->pb; struct mp3entry *id3 = state->id3; - int y = pb->y; - int height = pb->height; + int y = pb->y, height = pb->height; + unsigned long length, elapsed; if (pb->height < 0 && !pb->have_bitmap_pb) height = font_get(wps_vp->vp.font)->height; @@ -136,39 +136,39 @@ static void draw_progressbar(struct gui_wps *gwps, y = (-y -1)*line_height + (0 > center ? 0 : center); } - int elapsed, length; - if (id3) + if (id3 && id3->length) { - elapsed = id3->elapsed; length = id3->length; + elapsed = id3->elapsed + state->ff_rewind_count; } else { + length = 1; elapsed = 0; - length = 0; } if (pb->have_bitmap_pb) gui_bitmap_scrollbar_draw(display, pb->bm, pb->x, y, pb->width, pb->bm.height, - length ? length : 1, 0, - length ? elapsed + state->ff_rewind_count : 0, - HORIZONTAL); + length, 0, elapsed, HORIZONTAL); else gui_scrollbar_draw(display, pb->x, y, pb->width, height, - length ? length : 1, 0, - length ? elapsed + state->ff_rewind_count : 0, - HORIZONTAL); + length, 0, elapsed, HORIZONTAL); + + if (id3 && id3->length) + { #ifdef AB_REPEAT_ENABLE - if ( ab_repeat_mode_enabled() && length != 0 ) - ab_draw_markers(display, length, - pb->x, pb->x + pb->width, y, height); + if (ab_repeat_mode_enabled()) + ab_draw_markers(display, id3->length, + pb->x, pb->x + pb->width, y, height); #endif - if (id3 && id3->cuesheet) - cue_draw_markers(display, state->id3->cuesheet, length, - pb->x, pb->x + pb->width, y+1, height-2); + if (id3->cuesheet) + cue_draw_markers(display, id3->cuesheet, id3->length, + pb->x, pb->x + pb->width, y+1, height-2); + } } + bool audio_peek_track(struct mp3entry* id3, int offset); static void draw_playlist_viewer_list(struct gui_wps *gwps, struct playlistviewer *viewer) @@ -185,11 +185,10 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, struct mp3entry *pid3; #if CONFIG_CODEC == SWCODEC struct mp3entry id3; -#endif +#endif char buf[MAX_PATH*2], tempbuf[MAX_PATH]; unsigned int buf_used = 0; - gwps->display->set_viewport(viewer->vp); for(i=start_item; (i-start_item)<lines && i<playlist_amount(); i++) { @@ -211,8 +210,8 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, { pid3 = NULL; } - - int line = pid3 ? TRACK_HAS_INFO : TRACK_HAS_NO_INFO; + + int line = pid3 ? TRACK_HAS_INFO : TRACK_HAS_NO_INFO; int j = 0, cur_string = 0; char *filename = playlist_peek(i-cur_playlist_pos); buf[0] = '\0'; @@ -267,7 +266,7 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, } j++; } - + int vpwidth = viewer->vp->width; length = gwps->display->getstringsize(buf, NULL, NULL); if (viewer->lines[line].scroll && length >= vpwidth) @@ -275,7 +274,7 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, gwps->display->puts_scroll(0, (i-start_item), buf ); } else - { + { if (length >= vpwidth) x = 0; else @@ -307,7 +306,7 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, x = 0; break; } - } + } gwps->display->putsxy(x, (i-start_item)*line_height, buf ); } } @@ -1088,8 +1087,8 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) int i; for (i = 0; i < 8; i++) { - if (data->wps_progress_pat[i] == 0) - data->wps_progress_pat[i] = display->get_locked_pattern(); + if (data->wps_progress_pat[i] == 0) + data->wps_progress_pat[i] = display->get_locked_pattern(); } #endif diff --git a/apps/gui/skin_engine/skin_fonts.c b/apps/gui/skin_engine/skin_fonts.c index 9764b32f67..2db5ef2ec2 100644 --- a/apps/gui/skin_engine/skin_fonts.c +++ b/apps/gui/skin_engine/skin_fonts.c @@ -109,7 +109,7 @@ int skin_font_load(char* font_name) if (font->font_id < 0) return -1; - font->ref_count = 1; + font->ref_count = 1; return font->font_id; } @@ -128,13 +128,8 @@ void skin_font_unload(int font_id) font_unload(font_id); font_table[i].font_id = -1; font_table[i].name[0] = '\0'; - } + } return; } } } - - - - - diff --git a/apps/gui/skin_engine/skin_fonts.h b/apps/gui/skin_engine/skin_fonts.h index 095083818c..778be0a73a 100644 --- a/apps/gui/skin_engine/skin_fonts.h +++ b/apps/gui/skin_engine/skin_fonts.h @@ -41,5 +41,4 @@ int skin_font_load(char* font_name); /* unload a skin font. If a font has been loaded more than once it wont actually * be unloaded untill all references have been unloaded */ void skin_font_unload(int font_id); - #endif diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index b66af75cb5..059c3d779c 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -380,7 +380,7 @@ static const struct wps_tag all_tags[] = { #endif { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, - parse_setting_and_lang }, + parse_setting_and_lang }, { WPS_TOKEN_TRANSLATEDSTRING, "Sx", WPS_REFRESH_STATIC, parse_setting_and_lang }, { WPS_TOKEN_LANG_IS_RTL , "Sr", WPS_REFRESH_STATIC, NULL }, @@ -388,8 +388,8 @@ 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 @@ -827,12 +827,12 @@ static int parse_playlistview_text(struct playlistviewer *viewer, taglen = i; } else - { + { if (tag->parse_func) { /* unsupported tag, reject */ return -1; - } + } taglen = strlen(tag->name); viewer->lines[line].tokens[viewer->lines[line].count++] = tag->type; } @@ -857,7 +857,7 @@ static int parse_playlistview_text(struct playlistviewer *viewer, } return text - start; } - + static int parse_playlistview(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) @@ -874,10 +874,10 @@ static int parse_playlistview(const char *wps_bufptr, viewer->start_offset = atoi(ptr+1); token->value.data = (void*)viewer; ptr = strchr(ptr+1, '|'); - length = parse_playlistview_text(viewer, TRACK_HAS_INFO, ptr); + length = parse_playlistview_text(viewer, TRACK_HAS_INFO, ptr); if (length < 0) return WPS_ERROR_INVALID_PARAM; - length = parse_playlistview_text(viewer, TRACK_HAS_NO_INFO, ptr+length); + length = parse_playlistview_text(viewer, TRACK_HAS_NO_INFO, ptr+length); if (length < 0) return WPS_ERROR_INVALID_PARAM; @@ -909,8 +909,7 @@ static int parse_viewport(const char *wps_bufptr, curr_line = NULL; if (!skin_start_new_line(skin_vp, wps_data->num_tokens)) return WPS_ERROR_INVALID_PARAM; - - + if (*ptr == 'i') { skin_vp->label = VP_INFO_LABEL; @@ -940,7 +939,7 @@ static int parse_viewport(const char *wps_bufptr, /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ if (!(ptr = viewport_parse_viewport(vp, curr_screen, ptr, '|'))) return WPS_ERROR_INVALID_PARAM; - + /* Check for trailing | */ if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; @@ -975,9 +974,8 @@ static int parse_image_special(const char *wps_bufptr, pos = strchr(wps_bufptr + 1, '|'); newline = strchr(wps_bufptr, '\n'); - + error = (pos > newline); - #if LCD_DEPTH > 1 if (token->type == WPS_TOKEN_IMAGE_BACKDROP) @@ -1386,7 +1384,7 @@ static int parse_albumart_load(const char *wps_bufptr, aa->height = 0; else if (aa->height > LCD_HEIGHT) aa->height = LCD_HEIGHT; - + if (swap_for_rtl) aa->x = LCD_WIDTH - (aa->x + aa->width); @@ -1689,7 +1687,7 @@ static int check_feature_tag(const char *wps_bufptr, const int type) return 0; #else return find_false_branch(wps_bufptr); -#endif +#endif default: /* not a tag we care about, just don't skip */ return 0; } @@ -2083,8 +2081,8 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) if (wps_data->backdrop) { bool needed = wps_data->backdrop[0] != '-'; - wps_data->backdrop = skin_backdrop_load(wps_data->backdrop, - bmpdir, curr_screen); + wps_data->backdrop = skin_backdrop_load(wps_data->backdrop, + bmpdir, curr_screen); if (!wps_data->backdrop && needed) retval = false; } 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, struct wps_state *state = &wps_state; if (id3) { + unsigned long length = id3->length; + unsigned long elapsed = id3->elapsed + state->ff_rewind_count; switch (token->type) { case WPS_TOKEN_METADATA_ARTIST: @@ -216,9 +218,9 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, } return NULL; case WPS_TOKEN_METADATA_COMMENT: - return id3->comment; + return id3->comment; case WPS_TOKEN_FILE_PATH: - return id3->path; + return id3->path; case WPS_TOKEN_FILE_BITRATE: if(id3->bitrate) snprintf(buf, buf_size, "%d", id3->bitrate); @@ -226,31 +228,26 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, return "?"; return buf; case WPS_TOKEN_TRACK_TIME_ELAPSED: - format_time(buf, buf_size, - id3->elapsed + state->ff_rewind_count); + format_time(buf, buf_size, elapsed); return buf; case WPS_TOKEN_TRACK_TIME_REMAINING: - format_time(buf, buf_size, - id3->length - id3->elapsed - - state->ff_rewind_count); + format_time(buf, buf_size, length - elapsed); return buf; case WPS_TOKEN_TRACK_LENGTH: - format_time(buf, buf_size, id3->length); + format_time(buf, buf_size, length); return buf; case WPS_TOKEN_TRACK_ELAPSED_PERCENT: - if (id3->length <= 0) + if (length <= 0) return NULL; if (intval) { - *intval = limit * (id3->elapsed + state->ff_rewind_count) - / id3->length + 1; + *intval = limit * elapsed / length + 1; } - snprintf(buf, buf_size, "%d", - 100*(id3->elapsed + state->ff_rewind_count) / id3->length); + snprintf(buf, buf_size, "%d", 100 * elapsed / length); return buf; @@ -295,7 +292,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, return (id3->vbr) ? "(avg)" : NULL; case WPS_TOKEN_FILE_DIRECTORY: return get_dir(buf, buf_size, id3->path, token->value.i); - + #ifdef HAVE_TAGCACHE case WPS_TOKEN_DATABASE_PLAYCOUNT: if (intval) @@ -313,7 +310,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, snprintf(buf, buf_size, "%ld", id3->score); return buf; #endif - + default: return NULL; } @@ -326,7 +323,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, * The ones that expect "0" need to be handled */ case WPS_TOKEN_FILE_FREQUENCY: case WPS_TOKEN_FILE_FREQUENCY_KHZ: - case WPS_TOKEN_FILE_SIZE: + case WPS_TOKEN_FILE_SIZE: #ifdef HAVE_TAGCACHE case WPS_TOKEN_DATABASE_PLAYCOUNT: case WPS_TOKEN_DATABASE_RATING: @@ -443,7 +440,8 @@ const char *get_token_value(struct gui_wps *gwps, snprintf(buf, buf_size, "%d", global_settings.volume); if (intval) { - if (global_settings.volume == sound_min(SOUND_VOLUME)) + int minvol = sound_min(SOUND_VOLUME); + if (global_settings.volume == minvol) { *intval = 1; } @@ -457,9 +455,8 @@ const char *get_token_value(struct gui_wps *gwps, } else { - *intval = (limit - 3) * (global_settings.volume - - sound_min(SOUND_VOLUME) - 1) - / (-1 - sound_min(SOUND_VOLUME)) + 2; + *intval = (limit-3) * (global_settings.volume - minvol - 1) + / (-1 - minvol) + 2; } } return buf; @@ -473,7 +470,7 @@ const char *get_token_value(struct gui_wps *gwps, case WPS_TOKEN_ALBUMART_DISPLAY: if (!data->albumart) - return NULL; + return NULL; if (!data->albumart->draw) data->albumart->draw = true; return NULL; @@ -801,7 +798,7 @@ const char *get_token_value(struct gui_wps *gwps, id3->album_gain_string != NULL); else type = -1; - + if (type < 0) val = 6; /* no tag */ else @@ -923,7 +920,7 @@ const char *get_token_value(struct gui_wps *gwps, int sound_setting = s->sound_setting->setting; /* settings with decimals can't be used in conditionals */ if (sound_numdecimals(sound_setting) == 0) - { + { *intval = (*(int*)s->setting-sound_min(sound_setting)) /sound_steps(sound_setting) + 1; } @@ -999,7 +996,7 @@ const char *get_token_value(struct gui_wps *gwps, rec_freq = 0; while (rec_freq < SAMPR_NUM_FREQ && audio_master_sampr_list[rec_freq] != samprk) - { + { rec_freq++; } } @@ -1053,7 +1050,7 @@ const char *get_token_value(struct gui_wps *gwps, #else /* HWCODEC */ static const char * const freq_strings[] = - {"--", "44", "48", "32", "22", "24", "16"}; + {"--", "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) @@ -1069,7 +1066,7 @@ const char *get_token_value(struct gui_wps *gwps, #endif return buf; } -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC case WPS_TOKEN_REC_ENCODER: { 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, } #endif case WPS_TOKEN_REC_BITRATE: -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC if (global_settings.rec_format == REC_FORMAT_MPA_L3) { if (intval) @@ -1201,7 +1198,6 @@ const char *get_token_value(struct gui_wps *gwps, } if (intval) { - *intval = curr_screen; } snprintf(buf, buf_size, "%d", curr_screen); diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h index 2c6dd6b72a..d20a6ee2e6 100644 --- a/apps/gui/skin_engine/skin_tokens.h +++ b/apps/gui/skin_engine/skin_tokens.h @@ -23,7 +23,7 @@ #define _SKIN_TOKENS_H_ #include <stdbool.h> - + enum wps_token_type { @@ -235,13 +235,12 @@ struct wps_token { void* data; } value; }; - + struct skin_token_list { struct wps_token *token; struct skin_token_list *next; }; char* get_dir(char* buf, int buf_size, const char* path, int level); - + #endif - diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c index 59bc5edc43..2e4f428af4 100644 --- a/apps/gui/skin_engine/wps_debug.c +++ b/apps/gui/skin_engine/wps_debug.c @@ -56,7 +56,7 @@ struct debug_token_table tokens[] = { { X(TOKEN_MARKER_DATABASE) }, { X(TOKEN_MARKER_FILE) }, { X(TOKEN_MARKER_IMAGES) }, - { X(TOKEN_MARKER_METADATA) }, + { X(TOKEN_MARKER_METADATA) }, { X(TOKEN_MARKER_PLAYBACK_INFO) }, { X(TOKEN_MARKER_PLAYLIST) }, { X(TOKEN_MARKER_MISC) }, @@ -194,7 +194,7 @@ static char *get_token_desc(struct wps_token *token, char *buf, case WPS_TOKEN_PLAYBACK_STATUS: snprintf(buf, bufsize, "mode playback"); break; - + case WPS_TOKEN_RTC_PRESENT: snprintf(buf, bufsize, "rtc: present?"); break; @@ -500,7 +500,7 @@ static char *get_token_desc(struct wps_token *token, char *buf, break; case WPS_TOKEN_SETTING: snprintf(buf, bufsize, "Setting value: '%s'", - settings[token->value.i].cfg_name); + settings[token->value.i].cfg_name); break; case WPS_TOKEN_LANG_IS_RTL: snprintf(buf, bufsize, "lang: is_rtl?"); @@ -514,7 +514,7 @@ static char *get_token_desc(struct wps_token *token, char *buf, token->type - tokens[i-1].start_marker); break; } - } + } break; } @@ -649,5 +649,4 @@ void debug_skin_usage(void) (unsigned long)(skin_buffer_usage() + skin_buffer_freespace())); } - #endif /* DEBUG || SIMULATOR */ diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index f6c7463804..0a8857a0b7 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -33,7 +33,7 @@ #include "skin_tokens.h" - + /* TODO: sort this mess out */ #include "screen_access.h" @@ -245,7 +245,6 @@ struct playlistviewer { bool scroll; } lines[2]; }; - #ifdef HAVE_ALBUMART |