Thumbnail fixes (#16062)

* Minor thumbnail improvements

- set standard name if only one entry is in the playlist
- use first database name for thumbnails if core has multiple

* Fix playlist thumbnail downloader

Playlist thumbnail downloader function was missed from the flexible
thumbnail name update, now it is added.
This commit is contained in:
zoltanvb 2024-01-02 02:23:18 +01:00 committed by GitHub
parent c969143efb
commit 8886b92455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 12 deletions

View File

@ -500,10 +500,19 @@ bool gfx_thumbnail_set_content_playlist(
{ {
char *db_name_no_ext = NULL; char *db_name_no_ext = NULL;
char tmp_buf[PATH_MAX_LENGTH]; char tmp_buf[PATH_MAX_LENGTH];
const char* pos = strchr(db_name, '|');
if (pos && (size_t) (pos - db_name)+1 < sizeof(tmp_buf)) {
/* If db_name comes from core info, and there are multiple
* databases mentioned separated by |, use only first one */
strlcpy(tmp_buf, db_name, (size_t) (pos - db_name)+1);
}
else {
/* Remove .lpl extension /* Remove .lpl extension
* > path_remove_extension() requires a char * (not const) * > path_remove_extension() requires a char * (not const)
* so have to use a temporary buffer... */ * so have to use a temporary buffer... */
strlcpy(tmp_buf, db_name, sizeof(tmp_buf)); strlcpy(tmp_buf, db_name, sizeof(tmp_buf));
}
db_name_no_ext = path_remove_extension(tmp_buf); db_name_no_ext = path_remove_extension(tmp_buf);
if (!string_is_empty(db_name_no_ext)) if (!string_is_empty(db_name_no_ext))

View File

@ -1097,6 +1097,11 @@ enum playlist_thumbnail_name_flags playlist_get_next_thumbnail_name_flag(playlis
return PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME; return PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME;
if (entry->thumbnail_flags & PLAYLIST_THUMBNAIL_FLAG_FULL_NAME) if (entry->thumbnail_flags & PLAYLIST_THUMBNAIL_FLAG_FULL_NAME)
return PLAYLIST_THUMBNAIL_FLAG_STD_NAME; return PLAYLIST_THUMBNAIL_FLAG_STD_NAME;
/* Special case: only one entry in playlist, only one query is possible
* as flag swapping relies on going back and forth among entries
* so just use the most likely version here */
if (idx == 0 && RBUF_LEN(playlist->entries) == 1)
return PLAYLIST_THUMBNAIL_FLAG_STD_NAME;
return PLAYLIST_THUMBNAIL_FLAG_FULL_NAME; return PLAYLIST_THUMBNAIL_FLAG_FULL_NAME;
} }

View File

@ -366,6 +366,7 @@ static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb)
static void task_pl_thumbnail_download_handler(retro_task_t *task) static void task_pl_thumbnail_download_handler(retro_task_t *task)
{ {
pl_thumb_handle_t *pl_thumb = NULL; pl_thumb_handle_t *pl_thumb = NULL;
enum playlist_thumbnail_name_flags next_flag = PLAYLIST_THUMBNAIL_FLAG_INVALID;
if (!task) if (!task)
goto task_finished; goto task_finished;
@ -421,6 +422,8 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
/* Start iterating over thumbnail type */ /* Start iterating over thumbnail type */
pl_thumb->type_idx = 1; pl_thumb->type_idx = 1;
pl_thumb->status = PL_THUMB_ITERATE_TYPE; pl_thumb->status = PL_THUMB_ITERATE_TYPE;
playlist_update_thumbnail_name_flag(pl_thumb->playlist, pl_thumb->list_index, PLAYLIST_THUMBNAIL_FLAG_FULL_NAME);
pl_thumb->name_flags = PLAYLIST_THUMBNAIL_FLAG_FULL_NAME;
} }
else else
{ {
@ -450,6 +453,9 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
/* Check whether all thumbnail types have been processed */ /* Check whether all thumbnail types have been processed */
if (pl_thumb->type_idx > 3) if (pl_thumb->type_idx > 3)
{ {
next_flag = playlist_get_next_thumbnail_name_flag(pl_thumb->playlist,pl_thumb->list_index);
if (next_flag == PLAYLIST_THUMBNAIL_FLAG_NONE) {
if (pl_thumb->playlist )
/* Time to move on to the next entry */ /* Time to move on to the next entry */
pl_thumb->list_index++; pl_thumb->list_index++;
if (pl_thumb->list_index < pl_thumb->list_size) if (pl_thumb->list_index < pl_thumb->list_size)
@ -457,6 +463,12 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
else else
pl_thumb->status = PL_THUMB_END; pl_thumb->status = PL_THUMB_END;
break; break;
} else {
/* Increment the name flag to cover the 3 supported naming conventions. */
pl_thumb->type_idx = 1;
playlist_update_thumbnail_name_flag(pl_thumb->playlist, pl_thumb->list_index, next_flag);
pl_thumb->name_flags = next_flag;
}
} }
/* Download current thumbnail */ /* Download current thumbnail */