Use flags for some structs instead of tons of bools - less state/variables to bookkeep,

less memory used
This commit is contained in:
LibretroAdmin 2022-10-06 06:53:13 +02:00
parent 141c33ceb5
commit 30eb0edcf8
6 changed files with 315 additions and 218 deletions

View File

@ -226,33 +226,26 @@ void gfx_widgets_msg_queue_push(
msg_widget->offset_y = 0;
msg_widget->alpha = 1.0f;
msg_widget->dying = false;
msg_widget->expired = false;
msg_widget->width = 0;
msg_widget->expiration_timer = 0;
msg_widget->expiration_timer_started = false;
msg_widget->task_ptr = task;
msg_widget->task_count = 0;
msg_widget->task_progress = 0;
msg_widget->task_finished = false;
msg_widget->task_error = false;
msg_widget->task_cancelled = false;
msg_widget->task_ident = 0;
msg_widget->unfolded = false;
msg_widget->unfolding = false;
msg_widget->unfold = 0.0f;
msg_widget->hourglass_rotation = 0.0f;
msg_widget->hourglass_timer = 0.0f;
msg_widget->flags = 0;
if (!p_dispwidget->msg_queue_has_icons)
{
msg_widget->unfolded = true;
msg_widget->unfolding = false;
msg_widget->flags |= DISPWIDG_FLAG_UNFOLDED;
msg_widget->flags &= ~DISPWIDG_FLAG_UNFOLDING;
msg_widget->unfold = 1.0f;
}
@ -262,14 +255,17 @@ void gfx_widgets_msg_queue_push(
msg_widget->msg_new = strdup(title);
msg_widget->msg_len = strlen(title);
msg_widget->task_error = !string_is_empty(task->error);
msg_widget->task_cancelled = task->cancelled;
msg_widget->task_finished = task->finished;
if (!string_is_empty(task->error))
msg_widget->flags |= DISPWIDG_FLAG_TASK_ERROR;
if (task->cancelled)
msg_widget->flags |= DISPWIDG_FLAG_TASK_CANCELLED;
if (task->finished)
msg_widget->flags |= DISPWIDG_FLAG_TASK_FINISHED;
msg_widget->task_progress = task->progress;
msg_widget->task_ident = task->ident;
msg_widget->task_count = 1;
msg_widget->unfolded = true;
msg_widget->flags |= DISPWIDG_FLAG_UNFOLDED;
msg_widget->width = font_driver_get_message_width(
p_dispwidget->gfx_widget_fonts.msg_queue.font,
@ -337,11 +333,11 @@ void gfx_widgets_msg_queue_push(
/* Update task info */
else
{
if (msg_widget->expiration_timer_started)
if (msg_widget->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED)
{
uintptr_t _tag = (uintptr_t)&msg_widget->expiration_timer;
uintptr_t _tag = (uintptr_t)&msg_widget->expiration_timer;
gfx_animation_kill_by_tag(&_tag);
msg_widget->expiration_timer_started = false;
msg_widget->flags &= ~DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED;
}
if (!string_is_equal(task->title, msg_widget->msg_new))
@ -389,9 +385,12 @@ void gfx_widgets_msg_queue_push(
msg_widget->width = new_width;
}
msg_widget->task_error = !string_is_empty(task->error);
msg_widget->task_cancelled = task->cancelled;
msg_widget->task_finished = task->finished;
if (!string_is_empty(task->error))
msg_widget->flags |= DISPWIDG_FLAG_TASK_ERROR;
if (task->cancelled)
msg_widget->flags |= DISPWIDG_FLAG_TASK_CANCELLED;
if (task->finished)
msg_widget->flags |= DISPWIDG_FLAG_TASK_FINISHED;
msg_widget->task_progress = task->progress;
}
}
@ -402,7 +401,7 @@ static void gfx_widgets_unfold_end(void *userdata)
disp_widget_msg_t *unfold = (disp_widget_msg_t*)userdata;
dispgfx_widget_t *p_dispwidget = &dispwidget_st;
unfold->unfolding = false;
unfold->flags &= ~DISPWIDG_FLAG_UNFOLDING;
p_dispwidget->moving = false;
}
@ -425,8 +424,8 @@ static void gfx_widgets_move_end(void *userdata)
gfx_animation_push(&entry);
unfold->unfolded = true;
unfold->unfolding = true;
unfold->flags |= DISPWIDG_FLAG_UNFOLDED;
unfold->flags |= DISPWIDG_FLAG_UNFOLDING;
}
else
p_dispwidget->moving = false;
@ -436,8 +435,8 @@ static void gfx_widgets_msg_queue_expired(void *userdata)
{
disp_widget_msg_t *msg = (disp_widget_msg_t *)userdata;
if (msg && !msg->expired)
msg->expired = true;
if (msg && !(msg->flags & DISPWIDG_FLAG_EXPIRED))
msg->flags |= DISPWIDG_FLAG_EXPIRED;
}
static void gfx_widgets_msg_queue_move(dispgfx_widget_t *p_dispwidget)
@ -455,13 +454,13 @@ static void gfx_widgets_msg_queue_move(dispgfx_widget_t *p_dispwidget)
{
disp_widget_msg_t* msg = p_dispwidget->current_msgs[i];
if (!msg || msg->dying)
if (!msg || (msg->flags & DISPWIDG_FLAG_DYING))
continue;
y += p_dispwidget->msg_queue_height
/ (msg->task_ptr ? 2 : 1) + p_dispwidget->msg_queue_spacing;
if (!msg->unfolded)
if (!(msg->flags & DISPWIDG_FLAG_UNFOLDED))
unfold = msg;
if (msg->offset_y != y)
@ -499,7 +498,9 @@ static void gfx_widgets_msg_queue_free(
/* remove the reference the task has of ourself
only if the task is not finished already
(finished tasks are freed before the widget) */
if (!msg->task_finished && !msg->task_error && !msg->task_cancelled)
if ( !(msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
&& !(msg->flags & DISPWIDG_FLAG_TASK_ERROR)
&& !(msg->flags & DISPWIDG_FLAG_TASK_CANCELLED))
msg->task_ptr->frontend_userdata = NULL;
/* update tasks count */
@ -511,7 +512,7 @@ static void gfx_widgets_msg_queue_free(
gfx_animation_kill_by_tag(&tag);
/* Kill all timers */
if (msg->expiration_timer_started)
if (msg->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED)
{
uintptr_t _tag = (uintptr_t)&msg->expiration_timer;
gfx_animation_kill_by_tag(&_tag);
@ -569,7 +570,7 @@ static void gfx_widgets_msg_queue_kill(
return;
p_dispwidget->moving = true;
msg->dying = true;
msg->flags |= DISPWIDG_FLAG_DYING;
p_dispwidget->msg_queue_kill = idx;
@ -710,7 +711,8 @@ static void gfx_widgets_start_msg_expiration_timer(
gfx_animation_timer_start(&msg_widget->expiration_timer, &timer);
msg_widget->expiration_timer_started = true;
msg_widget->flags |=
DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED;
}
static void gfx_widgets_hourglass_tick(void *userdata);
@ -1012,7 +1014,7 @@ void gfx_widgets_iterate(
/* Start expiration timer if not associated to a task */
if (!msg_widget->task_ptr)
{
if (!msg_widget->expiration_timer_started)
if (!(msg_widget->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED))
gfx_widgets_start_msg_expiration_timer(
msg_widget, MSG_QUEUE_ANIMATION_DURATION * 2
+ msg_widget->duration);
@ -1038,12 +1040,14 @@ void gfx_widgets_iterate(
if (!msg_widget)
continue;
if (msg_widget->task_ptr && (msg_widget->task_finished
|| msg_widget->task_cancelled))
if (!msg_widget->expiration_timer_started)
if (msg_widget->task_ptr
&& ((msg_widget->flags & DISPWIDG_FLAG_TASK_FINISHED)
|| (msg_widget->flags & DISPWIDG_FLAG_TASK_CANCELLED)))
if (!(msg_widget->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED))
gfx_widgets_start_msg_expiration_timer(msg_widget, TASK_FINISHED_DURATION);
if (msg_widget->expired && !p_dispwidget->moving)
if ( (msg_widget->flags & DISPWIDG_FLAG_EXPIRED)
&& !p_dispwidget->moving)
{
gfx_widgets_msg_queue_kill(p_dispwidget,
(unsigned)i);
@ -1176,12 +1180,12 @@ static void gfx_widgets_draw_task_msg(
task_percentage_offset =
p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width
* (msg->task_error ? 12 : 5)
* ((msg->flags & DISPWIDG_FLAG_TASK_ERROR) ? 12 : 5)
+ p_dispwidget->simple_widget_padding * 1.25f; /*11 = STRLEN_CONST("Task failed") + 1 */
if (msg->task_finished)
if (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
{
if (msg->task_error)
if (msg->flags & DISPWIDG_FLAG_TASK_ERROR)
strlcpy(task_percentage, "Task failed", sizeof(task_percentage));
else
{
@ -1203,7 +1207,7 @@ static void gfx_widgets_draw_task_msg(
text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha*255.0f));
/* Rect */
if (msg->task_finished)
if (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
if (msg->task_count == 1)
msg_queue_current_background = msg_queue_task_progress_1;
else
@ -1231,7 +1235,9 @@ static void gfx_widgets_draw_task_msg(
);
/* Progress bar */
if (!msg->task_finished && msg->task_progress >= 0 && msg->task_progress <= 100)
if ( !(msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
&& (msg->task_progress >= 0)
&& (msg->task_progress <= 100))
{
if (msg->task_count == 1)
msg_queue_current_bar = msg_queue_task_progress_1;
@ -1259,7 +1265,7 @@ static void gfx_widgets_draw_task_msg(
float radians = 0.0f; /* rad */
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
if (!msg->task_finished)
if (!msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
{
radians = msg->hourglass_rotation;
cosine = cosf(radians);
@ -1273,7 +1279,7 @@ static void gfx_widgets_draw_task_msg(
p_dispwidget->msg_queue_height / 2,
p_dispwidget->msg_queue_height / 2,
p_dispwidget->gfx_widgets_icons_textures[
msg->task_finished
(msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
? MENU_WIDGETS_ICON_CHECK
: MENU_WIDGETS_ICON_HOURGLASS],
p_dispwidget->msg_queue_task_hourglass_x,
@ -1361,8 +1367,8 @@ static void gfx_widgets_draw_regular_msg(
unsigned text_color;
static float last_alpha = 0.0f;
msg->unfolding = false;
msg->unfolded = true;
msg->flags &= ~DISPWIDG_FLAG_UNFOLDING;
msg->flags |= DISPWIDG_FLAG_UNFOLDED;
if (last_alpha != msg->alpha)
{
@ -1373,7 +1379,8 @@ static void gfx_widgets_draw_regular_msg(
last_alpha = msg->alpha;
}
if (!msg->unfolded || msg->unfolding)
if ( !(msg->flags & DISPWIDG_FLAG_UNFOLDED)
|| (msg->flags & DISPWIDG_FLAG_UNFOLDING))
{
gfx_widgets_flush_text(video_width, video_height,
&p_dispwidget->gfx_widget_fonts.regular);
@ -1437,7 +1444,8 @@ static void gfx_widgets_draw_regular_msg(
TEXT_ALIGN_LEFT,
true);
if (!msg->unfolded || msg->unfolding)
if ( !(msg->flags & DISPWIDG_FLAG_UNFOLDED)
|| (msg->flags & DISPWIDG_FLAG_UNFOLDING))
{
gfx_widgets_flush_text(video_width, video_height, &p_dispwidget->gfx_widget_fonts.regular);
gfx_widgets_flush_text(video_width, video_height, &p_dispwidget->gfx_widget_fonts.bold);

View File

@ -110,6 +110,21 @@ typedef struct
gfx_widget_font_data_t msg_queue;
} gfx_widget_fonts_t;
enum disp_widget_flags_enum
{
DISPWIDG_FLAG_TASK_FINISHED = (1 << 0),
DISPWIDG_FLAG_TASK_ERROR = (1 << 1),
DISPWIDG_FLAG_TASK_CANCELLED = (1 << 2),
DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED = (1 << 3),
/* Is it currently doing the fade out animation ? */
DISPWIDG_FLAG_DYING = (1 << 4),
/* Has the timer expired ? if so, should be set to dying */
DISPWIDG_FLAG_EXPIRED = (1 << 5),
/* Unfold animation */
DISPWIDG_FLAG_UNFOLDED = (1 << 6),
DISPWIDG_FLAG_UNFOLDING = (1 << 7)
};
typedef struct disp_widget_msg
{
char *msg;
@ -130,21 +145,10 @@ typedef struct disp_widget_msg
float hourglass_timer; /* float alignment */
float expiration_timer; /* float alignment */
uint16_t flags;
int8_t task_progress;
/* How many tasks have used this notification? */
uint8_t task_count;
bool task_finished;
bool task_error;
bool task_cancelled;
bool expiration_timer_started;
/* Is it currently doing the fade out animation ? */
bool dying;
/* Has the timer expired ? if so, should be set to dying */
bool expired;
/* Unfold animation */
bool unfolded;
bool unfolding;
} disp_widget_msg_t;
typedef struct dispgfx_widget

View File

@ -119,6 +119,19 @@ struct content_stream
uint32_t crc;
};
enum content_information_flags
{
CONTENT_INFO_FLAG_BLOCK_EXTRACT = (1 << 0),
CONTENT_INFO_FLAG_NEED_FULLPATH = (1 << 1),
CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE = (1 << 2),
CONTENT_INFO_FLAG_IS_IPS_PREF = (1 << 3),
CONTENT_INFO_FLAG_IS_BPS_PREF = (1 << 4),
CONTENT_INFO_FLAG_IS_UPS_PREF = (1 << 5),
CONTENT_INFO_FLAG_PATCH_IS_BLOCKED = (1 << 6),
CONTENT_INFO_FLAG_BIOS_IS_MISSING = (1 << 7),
CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING = (1 << 8)
};
struct content_information_ctx
{
char *name_ips;
@ -135,17 +148,7 @@ struct content_information_ctx
unsigned size;
} subsystem;
bool block_extract;
bool need_fullpath;
bool set_supports_no_game_enable;
#ifdef HAVE_PATCH
bool is_ips_pref;
bool is_bps_pref;
bool is_ups_pref;
bool patch_is_blocked;
#endif
bool bios_is_missing;
bool check_firmware_before_loading;
uint16_t flags;
};
/*************************************/
@ -724,11 +727,11 @@ static bool content_file_load_into_memory(
#ifdef HAVE_PATCH
/* Attempt to apply a patch. */
if (!content_ctx->patch_is_blocked)
if (!(content_ctx->flags & CONTENT_INFO_FLAG_PATCH_IS_BLOCKED))
has_patch = patch_content(
content_ctx->is_ips_pref,
content_ctx->is_bps_pref,
content_ctx->is_ups_pref,
content_ctx->flags & CONTENT_INFO_FLAG_IS_IPS_PREF,
content_ctx->flags & CONTENT_INFO_FLAG_IS_BPS_PREF,
content_ctx->flags & CONTENT_INFO_FLAG_IS_UPS_PREF,
content_ctx->name_ips,
content_ctx->name_bps,
content_ctx->name_ups,
@ -1257,8 +1260,10 @@ static void content_file_set_attributes(
content_get_status(&contentless, &is_inited);
CONTENT_FILE_ATTR_RESET(attr);
CONTENT_FILE_ATTR_SET_BLOCK_EXTRACT(attr, content_ctx->block_extract);
CONTENT_FILE_ATTR_SET_NEED_FULLPATH(attr, content_ctx->need_fullpath);
CONTENT_FILE_ATTR_SET_BLOCK_EXTRACT(attr, content_ctx->flags &
CONTENT_INFO_FLAG_BLOCK_EXTRACT);
CONTENT_FILE_ATTR_SET_NEED_FULLPATH(attr, content_ctx->flags &
CONTENT_INFO_FLAG_NEED_FULLPATH);
CONTENT_FILE_ATTR_SET_REQUIRED(attr, !contentless);
#if defined(HAVE_RUNAHEAD)
@ -1273,7 +1278,7 @@ static void content_file_set_attributes(
if (string_is_empty(content_path))
{
if (contentless &&
content_ctx->set_supports_no_game_enable)
content_ctx->flags & CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE)
string_list_append(content, "", attr);
}
else
@ -1888,8 +1893,8 @@ static bool firmware_update_status(
retroarch_ctl(RARCH_CTL_SET_MISSING_BIOS, NULL);
if (
content_ctx->bios_is_missing &&
content_ctx->check_firmware_before_loading)
(content_ctx->flags & CONTENT_INFO_FLAG_BIOS_IS_MISSING)
&& (content_ctx->flags & CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING))
{
runloop_msg_queue_push(
msg_hash_to_str(MSG_FIRMWARE),
@ -1918,23 +1923,28 @@ bool task_push_start_dummy_core(content_ctx_info_t *content_info)
if (!content_info)
return false;
content_ctx.check_firmware_before_loading = check_firmware_before_loading;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
#ifdef HAVE_PATCH
content_ctx.is_ips_pref = retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
content_ctx.is_bps_pref = retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
content_ctx.is_ups_pref = retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL);
content_ctx.patch_is_blocked = runloop_st->patch_blocked;
if (retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.bios_is_missing = retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL);
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
content_ctx.directory_system = NULL;
content_ctx.directory_cache = NULL;
content_ctx.name_ips = NULL;
content_ctx.name_bps = NULL;
content_ctx.name_ups = NULL;
content_ctx.valid_extensions = NULL;
content_ctx.block_extract = false;
content_ctx.need_fullpath = false;
content_ctx.set_supports_no_game_enable = false;
content_ctx.subsystem.data = NULL;
content_ctx.subsystem.size = 0;
@ -1998,24 +2008,30 @@ bool task_push_load_content_from_playlist_from_menu(
#ifndef HAVE_DYNAMIC
bool force_core_reload = settings->bools.always_reload_core_on_run_content;
#endif
bool check_firmware_before_loading = settings->bools.check_firmware_before_loading;
content_ctx.check_firmware_before_loading = settings->bools.check_firmware_before_loading;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
#ifdef HAVE_PATCH
content_ctx.is_ips_pref = retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
content_ctx.is_bps_pref = retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
content_ctx.is_ups_pref = retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL);
content_ctx.patch_is_blocked = runloop_st->patch_blocked;
if (retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.bios_is_missing = retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL);
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
content_ctx.directory_system = NULL;
content_ctx.directory_cache = NULL;
content_ctx.name_ips = NULL;
content_ctx.name_bps = NULL;
content_ctx.name_ups = NULL;
content_ctx.valid_extensions = NULL;
content_ctx.block_extract = false;
content_ctx.need_fullpath = false;
content_ctx.set_supports_no_game_enable = false;
content_ctx.subsystem.data = NULL;
content_ctx.subsystem.size = 0;
@ -2122,34 +2138,38 @@ end:
bool task_push_start_current_core(content_ctx_info_t *content_info)
{
content_information_ctx_t content_ctx;
content_state_t *p_content = content_state_get_ptr();
bool ret = true;
settings_t *settings = config_get_ptr();
runloop_state_t *runloop_st = runloop_state_get_ptr();
const char *path_dir_system = settings->paths.directory_system;
bool check_firmware_before_loading = settings->bools.check_firmware_before_loading;
bool ret = true;
content_state_t *p_content = content_state_get_ptr();
settings_t *settings = config_get_ptr();
runloop_state_t *runloop_st = runloop_state_get_ptr();
const char *path_dir_system = settings->paths.directory_system;
bool check_firmware_before_loading = settings->bools.check_firmware_before_loading;
if (!content_info)
return false;
content_ctx.check_firmware_before_loading = check_firmware_before_loading;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
#ifdef HAVE_PATCH
content_ctx.is_ips_pref = retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
content_ctx.is_bps_pref = retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
content_ctx.is_ups_pref = retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL);
content_ctx.patch_is_blocked = runloop_st->patch_blocked;
if (retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.bios_is_missing = retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL);
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
content_ctx.directory_system = NULL;
content_ctx.directory_cache = NULL;
content_ctx.name_ips = NULL;
content_ctx.name_bps = NULL;
content_ctx.name_ups = NULL;
content_ctx.valid_extensions = NULL;
content_ctx.block_extract = false;
content_ctx.need_fullpath = false;
content_ctx.set_supports_no_game_enable = false;
content_ctx.subsystem.data = NULL;
content_ctx.subsystem.size = 0;
@ -2261,8 +2281,12 @@ bool task_push_load_contentless_core_from_menu(
if (string_is_empty(core_path))
return false;
content_ctx.check_firmware_before_loading = check_firmware_before_loading;
content_ctx.bios_is_missing = retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL);
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
if (!string_is_empty(path_dir_system))
content_ctx.directory_system = strdup(path_dir_system);
@ -2358,23 +2382,28 @@ bool task_push_load_content_with_new_core_from_menu(
type, cb, user_data);
#endif
content_ctx.check_firmware_before_loading = check_firmware_before_loading;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
#ifdef HAVE_PATCH
content_ctx.is_ips_pref = retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
content_ctx.is_bps_pref = retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
content_ctx.is_ups_pref = retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL);
content_ctx.patch_is_blocked = runloop_st->patch_blocked;
if (retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.bios_is_missing = retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL);
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
content_ctx.directory_system = NULL;
content_ctx.directory_cache = NULL;
content_ctx.name_ips = NULL;
content_ctx.name_bps = NULL;
content_ctx.name_ups = NULL;
content_ctx.valid_extensions = NULL;
content_ctx.block_extract = false;
content_ctx.need_fullpath = false;
content_ctx.set_supports_no_game_enable = false;
content_ctx.subsystem.data = NULL;
content_ctx.subsystem.size = 0;
@ -2458,23 +2487,28 @@ static bool task_load_content_internal(
const char *path_dir_system = settings->paths.directory_system;
const char *path_dir_cache = settings->paths.directory_cache;
content_ctx.check_firmware_before_loading = check_firmware_before_loading;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
#ifdef HAVE_PATCH
content_ctx.is_ips_pref = retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
content_ctx.is_bps_pref = retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
content_ctx.is_ups_pref = retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL);
content_ctx.patch_is_blocked = runloop_st->patch_blocked;
if (retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.bios_is_missing = retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL);
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
content_ctx.directory_system = NULL;
content_ctx.directory_cache = NULL;
content_ctx.name_ips = NULL;
content_ctx.name_bps = NULL;
content_ctx.name_ups = NULL;
content_ctx.valid_extensions = NULL;
content_ctx.block_extract = false;
content_ctx.need_fullpath = false;
content_ctx.set_supports_no_game_enable = false;
content_ctx.subsystem.data = NULL;
content_ctx.subsystem.size = 0;
@ -2483,15 +2517,18 @@ static bool task_load_content_internal(
{
struct retro_system_info *system = &runloop_state_get_ptr()->system.info;
content_ctx.set_supports_no_game_enable = set_supports_no_game_enable;
if (set_supports_no_game_enable)
content_ctx.flags |= CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE;
if (!string_is_empty(path_dir_cache))
content_ctx.directory_cache = strdup(path_dir_cache);
if (!string_is_empty(system->valid_extensions))
content_ctx.valid_extensions = strdup(system->valid_extensions);
content_ctx.block_extract = system->block_extract;
content_ctx.need_fullpath = system->need_fullpath;
if (system->block_extract)
content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT;
if (system->need_fullpath)
content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH;
content_ctx.subsystem.data = sys_info->subsystem.data;
content_ctx.subsystem.size = sys_info->subsystem.size;
@ -2976,28 +3013,35 @@ bool content_init(void)
{
struct string_list content;
content_information_ctx_t content_ctx;
enum msg_hash_enums error_enum = MSG_UNKNOWN;
content_state_t *p_content = content_state_get_ptr();
enum msg_hash_enums error_enum = MSG_UNKNOWN;
content_state_t *p_content = content_state_get_ptr();
bool ret = true;
char *error_string = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
rarch_system_info_t *sys_info = &runloop_st->system;
settings_t *settings = config_get_ptr();
bool check_firmware_before_loading = settings->bools.check_firmware_before_loading;
bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable;
const char *path_dir_system = settings->paths.directory_system;
const char *path_dir_cache = settings->paths.directory_cache;
bool ret = true;
char *error_string = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
rarch_system_info_t *sys_info = &runloop_st->system;
settings_t *settings = config_get_ptr();
bool check_firmware_before_loading = settings->bools.check_firmware_before_loading;
bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable;
const char *path_dir_system = settings->paths.directory_system;
const char *path_dir_cache = settings->paths.directory_cache;
content_file_list_free(p_content->content_list);
p_content->content_list = NULL;
p_content->content_list = NULL;
content_ctx.check_firmware_before_loading = check_firmware_before_loading;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
#ifdef HAVE_PATCH
content_ctx.is_ips_pref = retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
content_ctx.is_bps_pref = retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
content_ctx.is_ups_pref = retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL);
content_ctx.patch_is_blocked = runloop_st->patch_blocked;
if (retroarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.directory_system = NULL;
content_ctx.directory_cache = NULL;
@ -3005,9 +3049,6 @@ bool content_init(void)
content_ctx.name_bps = NULL;
content_ctx.name_ups = NULL;
content_ctx.valid_extensions = NULL;
content_ctx.block_extract = false;
content_ctx.need_fullpath = false;
content_ctx.set_supports_no_game_enable = false;
content_ctx.subsystem.data = NULL;
content_ctx.subsystem.size = 0;
@ -3023,7 +3064,8 @@ bool content_init(void)
{
struct retro_system_info *system = &runloop_state_get_ptr()->system.info;
content_ctx.set_supports_no_game_enable = set_supports_no_game_enable;
if (set_supports_no_game_enable)
content_ctx.flags |= CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE;
if (!string_is_empty(path_dir_system))
content_ctx.directory_system = strdup(path_dir_system);
@ -3032,8 +3074,10 @@ bool content_init(void)
if (!string_is_empty(system->valid_extensions))
content_ctx.valid_extensions = strdup(system->valid_extensions);
content_ctx.block_extract = system->block_extract;
content_ctx.need_fullpath = system->need_fullpath;
if (system->block_extract)
content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT;
if (system->need_fullpath)
content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH;
content_ctx.subsystem.data = sys_info->subsystem.data;
content_ctx.subsystem.size = sys_info->subsystem.size;

View File

@ -57,6 +57,14 @@ typedef struct database_state_handle
char serial[4096];
} database_state_handle_t;
enum db_flags_enum
{
DB_HANDLE_FLAG_IS_DIRECTORY = (1 << 0),
DB_HANDLE_FLAG_SCAN_STARTED = (1 << 1),
DB_HANDLE_FLAG_SCAN_WITHOUT_CORE_MATCH = (1 << 2),
DB_HANDLE_FLAG_SHOW_HIDDEN_FILES = (1 << 3)
};
typedef struct db_handle
{
char *playlist_directory;
@ -66,10 +74,7 @@ typedef struct db_handle
database_state_handle_t state;
playlist_config_t playlist_config; /* size_t alignment */
unsigned status;
bool is_directory;
bool scan_started;
bool scan_without_core_match;
bool show_hidden_files;
uint8_t flags;
} db_handle_t;
static const char *database_info_get_current_name(
@ -853,7 +858,7 @@ static int task_database_iterate_crc_lookup(
query[0] = '\0';
if (!_db->scan_without_core_match)
if (!(_db->flags & DB_HANDLE_FLAG_SCAN_WITHOUT_CORE_MATCH))
{
/* don't scan files that can't be in this database.
*
@ -1111,16 +1116,16 @@ static void task_database_handler(retro_task_t *task)
if (!db)
goto task_finished;
if (!db->scan_started)
if (!(db->flags & DB_HANDLE_FLAG_SCAN_STARTED))
{
db->scan_started = true;
db->flags |= DB_HANDLE_FLAG_SCAN_STARTED;
if (!string_is_empty(db->fullpath))
{
if (db->is_directory)
if (db->flags & DB_HANDLE_FLAG_IS_DIRECTORY)
db->handle = database_info_dir_init(
db->fullpath, DATABASE_TYPE_ITERATE,
task, db->show_hidden_files);
task, db->flags & DB_HANDLE_FLAG_SHOW_HIDDEN_FILES);
else
db->handle = database_info_file_init(
db->fullpath, DATABASE_TYPE_ITERATE,
@ -1146,12 +1151,12 @@ static void task_database_handler(retro_task_t *task)
dbstate->list = dir_list_new(
db->content_database_path,
"rdb", false,
db->show_hidden_files,
db->flags & DB_HANDLE_FLAG_SHOW_HIDDEN_FILES,
false, false);
/* If the scan path matches a database path exactly then
* save time by only processing that database. */
if (dbstate->list && db->is_directory)
if (dbstate->list && (db->flags & DB_HANDLE_FLAG_IS_DIRECTORY))
{
size_t i;
char *dirname = NULL;
@ -1230,7 +1235,7 @@ static void task_database_handler(retro_task_t *task)
else
{
const char *msg = NULL;
if (db->is_directory)
if (db->flags & DB_HANDLE_FLAG_IS_DIRECTORY)
msg = msg_hash_to_str(MSG_SCANNING_OF_DIRECTORY_FINISHED);
else
msg = msg_hash_to_str(MSG_SCANNING_OF_FILE_FINISHED);
@ -1317,7 +1322,8 @@ bool task_push_dbscan(
#ifdef RARCH_INTERNAL
t->progress_cb = task_database_progress_cb;
db->scan_without_core_match = settings->bools.scan_without_core_match;
if (settings->bools.scan_without_core_match)
db->flags |= DB_HANDLE_FLAG_SCAN_WITHOUT_CORE_MATCH;
db->playlist_config.capacity = COLLECTION_SIZE;
db->playlist_config.old_format = settings->bools.playlist_use_old_format;
db->playlist_config.compress = settings->bools.playlist_compression;
@ -1330,8 +1336,10 @@ bool task_push_dbscan(
db->playlist_config.fuzzy_archive_match = false;
playlist_config_set_base_content_directory(&db->playlist_config, NULL);
#endif
db->show_hidden_files = db_dir_show_hidden_files;
db->is_directory = directory;
if (db_dir_show_hidden_files)
db->flags |= DB_HANDLE_FLAG_SHOW_HIDDEN_FILES;
if (directory)
db->flags |= DB_HANDLE_FLAG_IS_DIRECTORY;
db->fullpath = strdup(fullpath);
db->playlist_directory = strdup(playlist_directory);
db->content_database_path = strdup(content_database);

View File

@ -38,6 +38,13 @@ enum image_status_enum
IMAGE_STATUS_PROCESS_TRANSFER_PARSE
};
enum image_flags_enum
{
IMAGE_FLAG_IS_BLOCKING = (1 << 0),
IMAGE_FLAG_IS_BLOCKING_ON_PROCESSING = (1 << 1),
IMAGE_FLAG_IS_FINISHED = (1 << 2)
};
struct nbio_image_handle
{
void *handle;
@ -49,9 +56,7 @@ struct nbio_image_handle
unsigned upscale_threshold;
enum image_type_enum type;
enum image_status_enum status;
bool is_blocking;
bool is_blocking_on_processing;
bool is_finished;
uint8_t flags;
};
static int cb_image_upload_generic(void *data, size_t len)
@ -78,9 +83,9 @@ static int cb_image_upload_generic(void *data, size_t len)
image_texture_color_convert(r_shift, g_shift, b_shift,
a_shift, &image->ti);
image->is_blocking_on_processing = false;
image->is_blocking = true;
image->is_finished = true;
image->flags &= ~IMAGE_FLAG_IS_BLOCKING_ON_PROCESSING;
image->flags |= IMAGE_FLAG_IS_BLOCKING;
image->flags |= IMAGE_FLAG_IS_FINISHED;
nbio->is_finished = true;
return 0;
@ -121,8 +126,14 @@ static int cb_image_thumbnail(void *data, size_t len)
)
return -1;
image->is_blocking_on_processing = (retval != IMAGE_PROCESS_END);
image->is_finished = (retval == IMAGE_PROCESS_END);
if (retval != IMAGE_PROCESS_END)
image->flags |= IMAGE_FLAG_IS_BLOCKING_ON_PROCESSING;
else
image->flags &= ~IMAGE_FLAG_IS_BLOCKING_ON_PROCESSING;
if (retval == IMAGE_PROCESS_END)
image->flags |= IMAGE_FLAG_IS_FINISHED;
else
image->flags &= ~IMAGE_FLAG_IS_FINISHED;
image->cb = &cb_image_upload_generic;
return 0;
@ -218,8 +229,8 @@ static int cb_nbio_image_thumbnail(void *data, size_t len)
return -1;
}
image->is_blocking = false;
image->is_finished = false;
image->flags &= ~IMAGE_FLAG_IS_BLOCKING;
image->flags &= ~IMAGE_FLAG_IS_FINISHED;
nbio->is_finished = true;
return 0;
@ -288,11 +299,12 @@ bool task_image_load_handler(retro_task_t *task)
if (image->cb(nbio, len) == -1)
return false;
}
if (image->is_blocking_on_processing)
if (image->flags & IMAGE_FLAG_IS_BLOCKING_ON_PROCESSING)
image->status = IMAGE_STATUS_PROCESS_TRANSFER;
break;
case IMAGE_STATUS_TRANSFER:
if (!image->is_blocking && !image->is_finished)
if ( !(image->flags & IMAGE_FLAG_IS_BLOCKING)
&& !(image->flags & IMAGE_FLAG_IS_FINISHED))
{
retro_time_t start_time = cpu_features_get_time_usec();
do
@ -313,13 +325,13 @@ bool task_image_load_handler(retro_task_t *task)
if (image->cb(nbio, len) == -1)
return false;
}
if (!image->is_finished)
if (!(image->flags & IMAGE_FLAG_IS_FINISHED))
break;
}
}
if ( nbio->is_finished
&& (image && image->is_finished)
&& (image && (image->flags & IMAGE_FLAG_IS_FINISHED))
&& (!task_get_cancelled(task)))
{
struct texture_image *img = (struct texture_image*)malloc(sizeof(struct texture_image));
@ -414,9 +426,6 @@ bool task_push_image_load(const char *fullpath,
image->type = image_texture_get_type(fullpath);
image->status = IMAGE_STATUS_WAIT;
image->is_blocking = false;
image->is_blocking_on_processing = false;
image->is_finished = false;
image->processing_final_state = 0;
image->frame_duration = 0;
image->size = 0;

View File

@ -49,6 +49,14 @@ enum pl_thumb_status
PL_THUMB_END
};
enum pl_thumb_flags
{
PL_THUMB_FLAG_OVERWRITE = (1 << 0),
PL_THUMB_FLAG_RIGHT_THUMB_EXISTS = (1 << 1),
PL_THUMB_FLAG_LEFT_THUMB_EXISTS = (1 << 2),
PL_THUMB_FLAG_HTTP_TASK_COMPLETE = (1 << 3)
};
typedef struct pl_thumb_handle
{
char *system;
@ -66,10 +74,7 @@ typedef struct pl_thumb_handle
enum pl_thumb_status status;
bool overwrite;
bool right_thumbnail_exists;
bool left_thumbnail_exists;
bool http_task_complete;
uint8_t flags;
} pl_thumb_handle_t;
typedef struct pl_entry_id
@ -192,7 +197,7 @@ void cb_http_task_download_pl_thumbnail(
if (!(pl_thumb = (pl_thumb_handle_t*)transf->user_data))
goto finish;
pl_thumb->http_task_complete = true;
pl_thumb->flags |= PL_THUMB_FLAG_HTTP_TASK_COMPLETE;
/* Remaining sanity checks... */
if (!data || !data->data || string_is_empty(transf->path))
@ -242,14 +247,14 @@ static void download_pl_thumbnail(pl_thumb_handle_t *pl_thumb)
if (get_thumbnail_paths(pl_thumb, path, sizeof(path), url, sizeof(url)))
{
/* Only download missing thumbnails */
if (!path_is_valid(path) || pl_thumb->overwrite)
if (!path_is_valid(path) || (pl_thumb->flags & PL_THUMB_FLAG_OVERWRITE))
{
file_transfer_t *transf = (file_transfer_t*)malloc(sizeof(file_transfer_t));
if (!transf)
return; /* If this happens then everything is broken anyway... */
/* Initialise http task status */
pl_thumb->http_task_complete = false;
pl_thumb->flags &= ~PL_THUMB_FLAG_HTTP_TASK_COMPLETE;
transf->enum_idx = MSG_UNKNOWN;
transf->path[0] = '\0';
@ -265,7 +270,7 @@ static void download_pl_thumbnail(pl_thumb_handle_t *pl_thumb)
* signal that the task is 'complete' */
if (!(pl_thumb->http_task = (retro_task_t*)task_push_http_transfer_file(
url, true, NULL, cb_http_task_download_pl_thumbnail, transf)))
pl_thumb->http_task_complete = true;
pl_thumb->flags |= PL_THUMB_FLAG_HTTP_TASK_COMPLETE;
}
}
}
@ -386,10 +391,10 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
* or an error occurred - in either case,
* current task is 'complete' */
if (!pl_thumb->http_task)
pl_thumb->http_task_complete = true;
pl_thumb->flags |= PL_THUMB_FLAG_HTTP_TASK_COMPLETE;
/* > Wait for task_push_http_transfer_file()
* callback to trigger */
else if (!pl_thumb->http_task_complete)
else if (!(pl_thumb->flags & PL_THUMB_FLAG_HTTP_TASK_COMPLETE))
break;
pl_thumb->http_task = NULL;
@ -494,11 +499,9 @@ bool task_push_pl_thumbnail_download(
pl_thumb->playlist = NULL;
pl_thumb->thumbnail_path_data = NULL;
pl_thumb->http_task = NULL;
pl_thumb->http_task_complete = false;
pl_thumb->list_size = 0;
pl_thumb->list_index = 0;
pl_thumb->type_idx = 1;
pl_thumb->overwrite = false;
pl_thumb->status = PL_THUMB_BEGIN;
/* Configure task */
@ -601,13 +604,15 @@ static void cb_task_pl_entry_thumbnail_refresh_menu(
* (with the caveat that we must also refresh if existing
* files have been overwritten) */
if (!pl_thumb->right_thumbnail_exists || pl_thumb->overwrite)
if ( !(pl_thumb->flags & PL_THUMB_FLAG_RIGHT_THUMB_EXISTS)
||(pl_thumb->flags & PL_THUMB_FLAG_OVERWRITE))
if (gfx_thumbnail_update_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_RIGHT))
if (gfx_thumbnail_get_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_RIGHT, &thumbnail_path))
do_refresh = path_is_valid(thumbnail_path);
if (!do_refresh)
if (!pl_thumb->left_thumbnail_exists || pl_thumb->overwrite)
if ( !(pl_thumb->flags & PL_THUMB_FLAG_LEFT_THUMB_EXISTS)
|| (pl_thumb->flags & PL_THUMB_FLAG_OVERWRITE))
if (gfx_thumbnail_update_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_LEFT))
if (gfx_thumbnail_get_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_LEFT, &left_thumbnail_path))
do_refresh = path_is_valid(left_thumbnail_path);
@ -651,19 +656,37 @@ static void task_pl_entry_thumbnail_download_handler(retro_task_t *task)
/* Check whether current right/left thumbnails
* already exist (required for menu refresh callback) */
pl_thumb->right_thumbnail_exists = false;
if (gfx_thumbnail_update_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_RIGHT))
if (gfx_thumbnail_get_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_RIGHT, &right_thumbnail_path))
pl_thumb->right_thumbnail_exists = path_is_valid(right_thumbnail_path);
pl_thumb->flags &= ~PL_THUMB_FLAG_RIGHT_THUMB_EXISTS;
pl_thumb->flags &= ~PL_THUMB_FLAG_LEFT_THUMB_EXISTS;
if (gfx_thumbnail_update_path(
pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_RIGHT))
{
if (gfx_thumbnail_get_path(
pl_thumb->thumbnail_path_data,
GFX_THUMBNAIL_RIGHT, &right_thumbnail_path))
{
if (path_is_valid(right_thumbnail_path))
pl_thumb->flags |= PL_THUMB_FLAG_RIGHT_THUMB_EXISTS;
}
}
pl_thumb->left_thumbnail_exists = false;
if (gfx_thumbnail_update_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_LEFT))
if (gfx_thumbnail_get_path(pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_LEFT, &left_thumbnail_path))
pl_thumb->left_thumbnail_exists = path_is_valid(left_thumbnail_path);
if (gfx_thumbnail_update_path(
pl_thumb->thumbnail_path_data, GFX_THUMBNAIL_LEFT))
{
if (gfx_thumbnail_get_path(
pl_thumb->thumbnail_path_data,
GFX_THUMBNAIL_LEFT, &left_thumbnail_path))
{
if (path_is_valid(left_thumbnail_path))
pl_thumb->flags |= PL_THUMB_FLAG_LEFT_THUMB_EXISTS;
}
}
/* Set task title */
task_free_title(task);
if (gfx_thumbnail_get_label(pl_thumb->thumbnail_path_data, &label))
if (gfx_thumbnail_get_label(
pl_thumb->thumbnail_path_data, &label))
task_set_title(task, strdup(label));
else
task_set_title(task, strdup(""));
@ -682,11 +705,11 @@ static void task_pl_entry_thumbnail_download_handler(retro_task_t *task)
* or an error occurred - in either case,
* current task is 'complete' */
if (!pl_thumb->http_task)
pl_thumb->http_task_complete = true;
pl_thumb->flags |= PL_THUMB_FLAG_HTTP_TASK_COMPLETE;
/* > Wait for task_push_http_transfer_file()
* callback to trigger */
if (pl_thumb->http_task_complete)
if (pl_thumb->flags & PL_THUMB_FLAG_HTTP_TASK_COMPLETE)
pl_thumb->http_task = NULL;
else
break;
@ -819,12 +842,13 @@ bool task_push_pl_entry_thumbnail_download(
pl_thumb->playlist = NULL;
pl_thumb->thumbnail_path_data = thumbnail_path_data;
pl_thumb->http_task = NULL;
pl_thumb->http_task_complete = false;
pl_thumb->list_size = playlist_size(playlist);
pl_thumb->list_index = idx;
pl_thumb->type_idx = 1;
pl_thumb->overwrite = overwrite;
pl_thumb->status = PL_THUMB_BEGIN;
if (overwrite)
pl_thumb->flags = PL_THUMB_FLAG_OVERWRITE;
/* Configure task */
task->handler = task_pl_entry_thumbnail_download_handler;