Skip to content

Commit

Permalink
Use members from path_data directly and bypass functions
Browse files Browse the repository at this point in the history
in gfx_thumbnail_path
  • Loading branch information
LibretroAdmin committed Dec 26, 2024
1 parent a2e9915 commit 5749a21
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 551 deletions.
60 changes: 48 additions & 12 deletions gfx/gfx_thumbnail.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,47 @@ void gfx_thumbnail_cancel_pending_requests(void)
p_gfx_thumb->list_id++;
}

/* Fetches the current thumbnail file path of the
* specified thumbnail 'type'.
* Returns true if path is valid. */
static bool gfx_thumbnail_get_path(
gfx_thumbnail_path_data_t *path_data,
enum gfx_thumbnail_id thumbnail_id,
const char **path)
{
if (path_data && path)
{
switch (thumbnail_id)
{
case GFX_THUMBNAIL_RIGHT:
if (!string_is_empty(path_data->right_path))
{
*path = path_data->right_path;
return true;
}
break;
case GFX_THUMBNAIL_LEFT:
if (!string_is_empty(path_data->left_path))
{
*path = path_data->left_path;
return true;
}
case GFX_THUMBNAIL_ICON:
if (!string_is_empty(path_data->icon_path))
{
*path = path_data->icon_path;
return true;
}
break;
default:
break;
}
}

return false;
}


/* Requests loading of the specified thumbnail
* - If operation fails, 'thumbnail->status' will be set to
* GFX_THUMBNAIL_STATUS_MISSING
Expand Down Expand Up @@ -291,16 +332,10 @@ void gfx_thumbnail_request(
{
enum playlist_thumbnail_name_flags curr_flag;
const char *system = NULL;
const char *img_name = NULL;
static char last_img_name[NAME_MAX_LENGTH] = {0};
static char last_img_name[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
if (!playlist)
goto end;

/* Validate entry */
if (!gfx_thumbnail_get_img_name(path_data, &img_name, PLAYLIST_THUMBNAIL_FLAG_STD_NAME))
goto end;

/* Only trigger a thumbnail download if image
* name has changed since the last call of
* gfx_thumbnail_request()
Expand All @@ -313,13 +348,14 @@ void gfx_thumbnail_request(
* checks required for this involve significant
* overheads. We can avoid this entirely with
* a simple string comparison) */
if (string_is_equal(img_name, last_img_name))
goto end;
if ((!string_is_empty(path_data->content_img)))
if (string_is_equal(path_data->content_img, last_img_name))
goto end;

strlcpy(last_img_name, img_name, sizeof(last_img_name));
strlcpy(last_img_name, path_data->content_img, sizeof(last_img_name));

/* Get system name */
if (!gfx_thumbnail_get_system(path_data, &system))
if (string_is_empty(path_data->system))
goto end;

/* Since task_push_pl_entry_download will shift the flag, do not attempt if it is already
Expand All @@ -337,7 +373,7 @@ void gfx_thumbnail_request(
/* Trigger thumbnail download *
* Note: download will grab all 3 possible thumbnails, no matter
* what left/right thumbnails are set at the moment */
task_push_pl_entry_thumbnail_download(system, playlist,
task_push_pl_entry_thumbnail_download(path_data->system, playlist,
(unsigned)idx, false, true);
}
#endif
Expand Down
Loading

0 comments on commit 5749a21

Please sign in to comment.