(task_pl_thumbnail_download) Cleanups
This commit is contained in:
parent
d9d1c13612
commit
5bcf8bebd0
|
@ -5394,9 +5394,10 @@ static int action_ok_pl_content_thumbnails(const char *path,
|
||||||
static int action_ok_pl_entry_content_thumbnails(const char *path,
|
static int action_ok_pl_entry_content_thumbnails(const char *path,
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
{
|
{
|
||||||
|
char system[PATH_MAX_LENGTH];
|
||||||
menu_handle_t *menu = NULL;
|
menu_handle_t *menu = NULL;
|
||||||
playlist_t *playlist = playlist_get_cached();
|
playlist_t *playlist = playlist_get_cached();
|
||||||
char system[PATH_MAX_LENGTH];
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
system[0] = '\0';
|
system[0] = '\0';
|
||||||
|
|
||||||
|
@ -5408,7 +5409,9 @@ static int action_ok_pl_entry_content_thumbnails(const char *path,
|
||||||
|
|
||||||
menu_driver_get_thumbnail_system(system, sizeof(system));
|
menu_driver_get_thumbnail_system(system, sizeof(system));
|
||||||
|
|
||||||
task_push_pl_entry_thumbnail_download(system, playlist, menu->rpl_entry_selection_ptr);
|
task_push_pl_entry_thumbnail_download(system,
|
||||||
|
settings->paths.directory_thumbnails,
|
||||||
|
playlist, menu->rpl_entry_selection_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "tasks_internal.h"
|
#include "tasks_internal.h"
|
||||||
#include "task_file_transfer.h"
|
#include "task_file_transfer.h"
|
||||||
|
|
||||||
#include "../configuration.h"
|
|
||||||
#include "../file_path_special.h"
|
#include "../file_path_special.h"
|
||||||
#include "../playlist.h"
|
#include "../playlist.h"
|
||||||
#include "../menu/menu_thumbnail_path.h"
|
#include "../menu/menu_thumbnail_path.h"
|
||||||
|
@ -51,6 +50,7 @@ typedef struct pl_thumb_handle
|
||||||
{
|
{
|
||||||
char *system;
|
char *system;
|
||||||
char *playlist_path;
|
char *playlist_path;
|
||||||
|
char *dir_thumbnails;
|
||||||
playlist_t *playlist;
|
playlist_t *playlist;
|
||||||
menu_thumbnail_path_data_t *thumbnail_path_data;
|
menu_thumbnail_path_data_t *thumbnail_path_data;
|
||||||
retro_task_t *http_task;
|
retro_task_t *http_task;
|
||||||
|
@ -71,7 +71,6 @@ static bool get_thumbnail_paths(
|
||||||
char *path, size_t path_size,
|
char *path, size_t path_size,
|
||||||
char *url, size_t url_size)
|
char *url, size_t url_size)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
const char *system = NULL;
|
const char *system = NULL;
|
||||||
const char *db_name = NULL;
|
const char *db_name = NULL;
|
||||||
const char *img_name = NULL;
|
const char *img_name = NULL;
|
||||||
|
@ -85,14 +84,10 @@ static bool get_thumbnail_paths(
|
||||||
raw_url[0] = '\0';
|
raw_url[0] = '\0';
|
||||||
tmp_buf[0] = '\0';
|
tmp_buf[0] = '\0';
|
||||||
|
|
||||||
/* Sanity check */
|
|
||||||
if (!pl_thumb || !settings)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!pl_thumb->thumbnail_path_data)
|
if (!pl_thumb->thumbnail_path_data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (string_is_empty(settings->paths.directory_thumbnails))
|
if (string_is_empty(pl_thumb->dir_thumbnails))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Extract required strings */
|
/* Extract required strings */
|
||||||
|
@ -129,7 +124,7 @@ static bool get_thumbnail_paths(
|
||||||
system_name = db_name;
|
system_name = db_name;
|
||||||
|
|
||||||
/* Generate local path */
|
/* Generate local path */
|
||||||
fill_pathname_join(path, settings->paths.directory_thumbnails,
|
fill_pathname_join(path, pl_thumb->dir_thumbnails,
|
||||||
system_name, path_size);
|
system_name, path_size);
|
||||||
fill_pathname_join(tmp_buf, path, sub_dir, sizeof(tmp_buf));
|
fill_pathname_join(tmp_buf, path, sub_dir, sizeof(tmp_buf));
|
||||||
fill_pathname_join(path, tmp_buf, img_name, path_size);
|
fill_pathname_join(path, tmp_buf, img_name, path_size);
|
||||||
|
@ -167,10 +162,6 @@ static void download_pl_thumbnail(pl_thumb_handle_t *pl_thumb, bool overwrite)
|
||||||
path[0] = '\0';
|
path[0] = '\0';
|
||||||
url[0] = '\0';
|
url[0] = '\0';
|
||||||
|
|
||||||
/* Sanity check */
|
|
||||||
if (!pl_thumb)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Check if paths are valid */
|
/* Check if paths are valid */
|
||||||
if (get_thumbnail_paths(pl_thumb, path, sizeof(path), url, sizeof(url)))
|
if (get_thumbnail_paths(pl_thumb, path, sizeof(path), url, sizeof(url)))
|
||||||
{
|
{
|
||||||
|
@ -195,8 +186,9 @@ static void download_pl_thumbnail(pl_thumb_handle_t *pl_thumb, bool overwrite)
|
||||||
|
|
||||||
static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb, bool free_playlist)
|
static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb, bool free_playlist)
|
||||||
{
|
{
|
||||||
if (pl_thumb)
|
if (!pl_thumb)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (!string_is_empty(pl_thumb->system))
|
if (!string_is_empty(pl_thumb->system))
|
||||||
{
|
{
|
||||||
free(pl_thumb->system);
|
free(pl_thumb->system);
|
||||||
|
@ -209,6 +201,12 @@ static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb, bool free_playlist
|
||||||
pl_thumb->playlist_path = NULL;
|
pl_thumb->playlist_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string_is_empty(pl_thumb->dir_thumbnails))
|
||||||
|
{
|
||||||
|
free(pl_thumb->dir_thumbnails);
|
||||||
|
pl_thumb->dir_thumbnails = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl_thumb->playlist && free_playlist)
|
if (pl_thumb->playlist && free_playlist)
|
||||||
{
|
{
|
||||||
playlist_free(pl_thumb->playlist);
|
playlist_free(pl_thumb->playlist);
|
||||||
|
@ -224,7 +222,6 @@ static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb, bool free_playlist
|
||||||
free(pl_thumb);
|
free(pl_thumb);
|
||||||
pl_thumb = NULL;
|
pl_thumb = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Callback: Refresh menu thumbnail display once
|
/* Callback: Refresh menu thumbnail display once
|
||||||
* download is complete */
|
* download is complete */
|
||||||
|
@ -340,6 +337,7 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Download current thumbnail */
|
/* Download current thumbnail */
|
||||||
|
if (pl_thumb)
|
||||||
download_pl_thumbnail(pl_thumb, false);
|
download_pl_thumbnail(pl_thumb, false);
|
||||||
|
|
||||||
/* Increment thumbnail type */
|
/* Increment thumbnail type */
|
||||||
|
@ -436,7 +434,10 @@ static void task_pl_entry_thumbnail_download_handler(retro_task_t *task)
|
||||||
pl_thumb_handle_t *pl_thumb = NULL;
|
pl_thumb_handle_t *pl_thumb = NULL;
|
||||||
|
|
||||||
if (!task)
|
if (!task)
|
||||||
goto task_finished;
|
{
|
||||||
|
free_pl_thumb_handle(pl_thumb, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pl_thumb = (pl_thumb_handle_t*)task->state;
|
pl_thumb = (pl_thumb_handle_t*)task->state;
|
||||||
|
|
||||||
|
@ -500,6 +501,7 @@ static void task_pl_entry_thumbnail_download_handler(retro_task_t *task)
|
||||||
task_set_progress(task, ((pl_thumb->type_idx - 1) * 100) / 3);
|
task_set_progress(task, ((pl_thumb->type_idx - 1) * 100) / 3);
|
||||||
|
|
||||||
/* Download current thumbnail */
|
/* Download current thumbnail */
|
||||||
|
if (pl_thumb)
|
||||||
download_pl_thumbnail(pl_thumb, true);
|
download_pl_thumbnail(pl_thumb, true);
|
||||||
|
|
||||||
/* Increment thumbnail type */
|
/* Increment thumbnail type */
|
||||||
|
@ -524,7 +526,9 @@ task_finished:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool task_push_pl_entry_thumbnail_download(
|
bool task_push_pl_entry_thumbnail_download(
|
||||||
const char *system, playlist_t *playlist, unsigned idx)
|
const char *system,
|
||||||
|
const char *dir_thumbnails,
|
||||||
|
playlist_t *playlist, unsigned idx)
|
||||||
{
|
{
|
||||||
retro_task_t *task = task_init();
|
retro_task_t *task = task_init();
|
||||||
pl_thumb_handle_t *pl_thumb = (pl_thumb_handle_t*)calloc(1, sizeof(pl_thumb_handle_t));
|
pl_thumb_handle_t *pl_thumb = (pl_thumb_handle_t*)calloc(1, sizeof(pl_thumb_handle_t));
|
||||||
|
@ -560,6 +564,7 @@ bool task_push_pl_entry_thumbnail_download(
|
||||||
pl_thumb->list_index = idx;
|
pl_thumb->list_index = idx;
|
||||||
pl_thumb->type_idx = 1;
|
pl_thumb->type_idx = 1;
|
||||||
pl_thumb->status = PL_THUMB_BEGIN;
|
pl_thumb->status = PL_THUMB_BEGIN;
|
||||||
|
pl_thumb->dir_thumbnails = strdup(dir_thumbnails);
|
||||||
|
|
||||||
task_queue_push(task);
|
task_queue_push(task);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool task_push_netplay_nat_traversal(void *nat_traversal_state, uint16_t port);
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
bool task_push_pl_thumbnail_download(const char *system, const char *playlist_path);
|
bool task_push_pl_thumbnail_download(const char *system, const char *playlist_path);
|
||||||
bool task_push_pl_entry_thumbnail_download(const char *system, playlist_t *playlist, unsigned idx);
|
bool task_push_pl_entry_thumbnail_download(const char *system, const char *dir_thumbnails, playlist_t *playlist, unsigned idx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue