mirror of
https://github.com/libretro/RetroArch
synced 2025-04-24 06:02:36 +00:00
menu_widgets: fix screenshot notification data race
This commit is contained in:
parent
90fb11cb9a
commit
a253fac207
@ -890,7 +890,6 @@ void menu_widgets_iterate(void)
|
|||||||
/* Load screenshot and start its animation */
|
/* Load screenshot and start its animation */
|
||||||
if (screenshot_filename[0] != '\0')
|
if (screenshot_filename[0] != '\0')
|
||||||
{
|
{
|
||||||
menu_animation_ctx_entry_t entry;
|
|
||||||
menu_timer_ctx_entry_t timer;
|
menu_timer_ctx_entry_t timer;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
|
|
||||||
@ -912,17 +911,7 @@ void menu_widgets_iterate(void)
|
|||||||
|
|
||||||
screenshot_shotname_length = (width - screenshot_thumbnail_width - simple_widget_padding*2) / glyph_width;
|
screenshot_shotname_length = (width - screenshot_thumbnail_width - simple_widget_padding*2) / glyph_width;
|
||||||
|
|
||||||
screenshot_y = -((float)screenshot_height);
|
screenshot_y = 0.0f;
|
||||||
|
|
||||||
entry.cb = NULL;
|
|
||||||
entry.duration = MSG_QUEUE_ANIMATION_DURATION;
|
|
||||||
entry.easing_enum = EASING_OUT_QUAD;
|
|
||||||
entry.subject = &screenshot_y;
|
|
||||||
entry.tag = generic_tag;
|
|
||||||
entry.target_value = 0.0f;
|
|
||||||
entry.userdata = NULL;
|
|
||||||
|
|
||||||
menu_animation_push(&entry);
|
|
||||||
|
|
||||||
timer.cb = menu_widgets_screenshot_end;
|
timer.cb = menu_widgets_screenshot_end;
|
||||||
timer.duration = SCREENSHOT_NOTIFICATION_DURATION;
|
timer.duration = SCREENSHOT_NOTIFICATION_DURATION;
|
||||||
@ -2037,7 +2026,7 @@ static void menu_widgets_screenshot_fadeout(void *userdata)
|
|||||||
if (!menu_widgets_inited)
|
if (!menu_widgets_inited)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
entry.cb = menu_widgets_screenshot_fadeout;
|
entry.cb = NULL;
|
||||||
entry.duration = SCREENSHOT_DURATION_OUT;
|
entry.duration = SCREENSHOT_DURATION_OUT;
|
||||||
entry.easing_enum = EASING_OUT_QUAD;
|
entry.easing_enum = EASING_OUT_QUAD;
|
||||||
entry.subject = &screenshot_alpha;
|
entry.subject = &screenshot_alpha;
|
||||||
@ -2068,6 +2057,9 @@ static void menu_widgets_play_screenshot_flash(void)
|
|||||||
|
|
||||||
void menu_widgets_screenshot_taken(const char *shotname, const char *filename)
|
void menu_widgets_screenshot_taken(const char *shotname, const char *filename)
|
||||||
{
|
{
|
||||||
|
if (!menu_widgets_inited)
|
||||||
|
return;
|
||||||
|
|
||||||
menu_widgets_play_screenshot_flash();
|
menu_widgets_play_screenshot_flash();
|
||||||
strlcpy(screenshot_filename, filename, sizeof(screenshot_filename));
|
strlcpy(screenshot_filename, filename, sizeof(screenshot_filename));
|
||||||
strlcpy(screenshot_shotname, shotname, sizeof(screenshot_shotname));
|
strlcpy(screenshot_shotname, shotname, sizeof(screenshot_shotname));
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#define VOLUME_DURATION 3000
|
#define VOLUME_DURATION 3000
|
||||||
#define SCREENSHOT_DURATION_IN 66
|
#define SCREENSHOT_DURATION_IN 66
|
||||||
#define SCREENSHOT_DURATION_OUT SCREENSHOT_DURATION_IN*10
|
#define SCREENSHOT_DURATION_OUT SCREENSHOT_DURATION_IN*10
|
||||||
#define SCREENSHOT_NOTIFICATION_DURATION 4000
|
#define SCREENSHOT_NOTIFICATION_DURATION 6000
|
||||||
#define CHEEVO_NOTIFICATION_DURATION 4000
|
#define CHEEVO_NOTIFICATION_DURATION 4000
|
||||||
#define TASK_FINISHED_DURATION 3000
|
#define TASK_FINISHED_DURATION 3000
|
||||||
#define HOURGLASS_INTERVAL 5000
|
#define HOURGLASS_INTERVAL 5000
|
||||||
|
@ -129,11 +129,6 @@ static bool screenshot_dump_direct(screenshot_task_state_t *state)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
|
||||||
if (!state->silence)
|
|
||||||
menu_widgets_screenshot_taken(state->shotname, state->filename);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +153,13 @@ static void task_screenshot_handler(retro_task_t *task)
|
|||||||
if (state->userbuf)
|
if (state->userbuf)
|
||||||
free(state->userbuf);
|
free(state->userbuf);
|
||||||
|
|
||||||
free(state);
|
#ifdef HAVE_MENU_WIDGETS
|
||||||
|
/* If menu widgets are enabled, state is freed
|
||||||
|
in the callback after the notification
|
||||||
|
is displayed */
|
||||||
|
if (!video_driver_has_widgets())
|
||||||
|
#endif
|
||||||
|
free(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +195,23 @@ static void task_screenshot_handler(retro_task_t *task)
|
|||||||
task_free_title(task);
|
task_free_title(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MENU_WIDGETS
|
||||||
|
static void task_screenshot_callback(retro_task_t *task,
|
||||||
|
void *task_data,
|
||||||
|
void *user_data, const char *error)
|
||||||
|
{
|
||||||
|
screenshot_task_state_t *state = (screenshot_task_state_t*)task->state;
|
||||||
|
|
||||||
|
if (!video_driver_has_widgets())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (state && !state->silence)
|
||||||
|
menu_widgets_screenshot_taken(state->shotname, state->filename);
|
||||||
|
|
||||||
|
free(state);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Take frame bottom-up. */
|
/* Take frame bottom-up. */
|
||||||
static bool screenshot_dump(
|
static bool screenshot_dump(
|
||||||
const char *name_base,
|
const char *name_base,
|
||||||
@ -295,6 +313,9 @@ static bool screenshot_dump(
|
|||||||
task->type = TASK_TYPE_BLOCKING;
|
task->type = TASK_TYPE_BLOCKING;
|
||||||
task->state = state;
|
task->state = state;
|
||||||
task->handler = task_screenshot_handler;
|
task->handler = task_screenshot_handler;
|
||||||
|
#ifdef HAVE_MENU_WIDGETS
|
||||||
|
task->callback = task_screenshot_callback;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (use_thread)
|
if (use_thread)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user