From 9b6598868243fe46b3d33887b17ea36770fe7cb0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 6 Dec 2015 21:34:39 +0100 Subject: [PATCH] Create rarch_threaded_video_send_and_wait --- gfx/font_driver.c | 2 +- gfx/video_texture_c.c | 2 +- gfx/video_thread_wrapper.c | 82 ++++++++++++++++++++++++++++++++++++++ gfx/video_thread_wrapper.h | 75 +--------------------------------- 4 files changed, 86 insertions(+), 75 deletions(-) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index b04ececcb4..fcade29a54 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -284,7 +284,7 @@ bool font_driver_init_first(const void **font_driver, void **font_handle, pkt.data.font_init.font_size = font_size; pkt.data.font_init.api = api; - thr->send_and_wait(thr, &pkt); + rarch_threaded_video_send_and_wait(thr, &pkt); return pkt.data.font_init.return_value; } diff --git a/gfx/video_texture_c.c b/gfx/video_texture_c.c index a6f1e02b6a..b1733c714f 100644 --- a/gfx/video_texture_c.c +++ b/gfx/video_texture_c.c @@ -226,7 +226,7 @@ unsigned video_texture_load(void *data, pkt.data.custom_command.data = (void*)data; - thr->send_and_wait(thr, &pkt); + rarch_threaded_video_send_and_wait(thr, &pkt); return pkt.data.custom_command.return_value; } diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 9bdda16a22..d9784fe834 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -23,6 +23,81 @@ #include "../runloop.h" #include "../verbosity.h" +struct thread_video +{ + slock_t *lock; + scond_t *cond_cmd; + scond_t *cond_thread; + sthread_t *thread; + + video_info_t info; + const video_driver_t *driver; + +#ifdef HAVE_OVERLAY + const video_overlay_interface_t *overlay; +#endif + const video_poke_interface_t *poke; + + void *driver_data; + const input_driver_t **input; + void **input_data; + +#if defined(HAVE_MENU) + struct + { + void *frame; + size_t frame_cap; + unsigned width; + unsigned height; + float alpha; + bool frame_updated; + bool rgb32; + bool enable; + bool full_screen; + } texture; +#endif + bool apply_state_changes; + + bool alive; + bool focus; + bool suppress_screensaver; + bool has_windowed; + bool nonblock; + + retro_time_t last_time; + unsigned hit_count; + unsigned miss_count; + + float *alpha_mod; + unsigned alpha_mods; + bool alpha_update; + slock_t *alpha_lock; + + void (*send_and_wait)(struct thread_video *, thread_packet_t*); + enum thread_cmd send_cmd; + enum thread_cmd reply_cmd; + thread_packet_t cmd_data; + + struct video_viewport vp; + struct video_viewport read_vp; /* Last viewport reported to caller. */ + + struct + { + slock_t *lock; + uint8_t *buffer; + unsigned width; + unsigned height; + unsigned pitch; + bool updated; + bool within_thread; + uint64_t count; + char msg[PATH_MAX_LENGTH]; + } frame; + + video_driver_t video_thread; + +}; + static void *thread_init_never_call(const video_info_t *video, const input_driver_t **input, void **input_data) { @@ -1142,3 +1217,10 @@ const char *rarch_threaded_video_get_ident(void) return NULL; return thr->driver->ident; } + +void rarch_threaded_video_send_and_wait(thread_video_t *thr, thread_packet_t *pkt) +{ + if (!thr || !pkt) + return; + thr->send_and_wait(thr, pkt); +} diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 70d332411c..81f0ef7b26 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -150,80 +150,9 @@ typedef struct } data; } thread_packet_t; -typedef struct thread_video -{ - slock_t *lock; - scond_t *cond_cmd; - scond_t *cond_thread; - sthread_t *thread; +typedef struct thread_video thread_video_t; - video_info_t info; - const video_driver_t *driver; - -#ifdef HAVE_OVERLAY - const video_overlay_interface_t *overlay; -#endif - const video_poke_interface_t *poke; - - void *driver_data; - const input_driver_t **input; - void **input_data; - -#if defined(HAVE_MENU) - struct - { - void *frame; - size_t frame_cap; - unsigned width; - unsigned height; - float alpha; - bool frame_updated; - bool rgb32; - bool enable; - bool full_screen; - } texture; -#endif - bool apply_state_changes; - - bool alive; - bool focus; - bool suppress_screensaver; - bool has_windowed; - bool nonblock; - - retro_time_t last_time; - unsigned hit_count; - unsigned miss_count; - - float *alpha_mod; - unsigned alpha_mods; - bool alpha_update; - slock_t *alpha_lock; - - void (*send_and_wait)(struct thread_video *, thread_packet_t*); - enum thread_cmd send_cmd; - enum thread_cmd reply_cmd; - thread_packet_t cmd_data; - - struct video_viewport vp; - struct video_viewport read_vp; /* Last viewport reported to caller. */ - - struct - { - slock_t *lock; - uint8_t *buffer; - unsigned width; - unsigned height; - unsigned pitch; - bool updated; - bool within_thread; - uint64_t count; - char msg[PATH_MAX_LENGTH]; - } frame; - - video_driver_t video_thread; - -} thread_video_t; +void rarch_threaded_video_send_and_wait(thread_video_t *thr, thread_packet_t *pkt); /** * rarch_threaded_video_init: