From b5e97238ac83ae8f917d320b65fd991ac29e27f7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 29 Apr 2017 17:38:47 +0200 Subject: [PATCH] Optimize video_driver_threaded_{lock|unlock} --- gfx/video_driver.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3f31d61fb9..69a21825bc 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -94,19 +94,19 @@ #define video_driver_is_threaded() (false) #endif -#define video_driver_threaded_lock() \ - if (video_driver_is_threaded()) \ +#define video_driver_threaded_lock(is_threaded) \ + if (is_threaded) \ video_driver_lock() -#define video_driver_threaded_unlock() \ - if (video_driver_is_threaded()) \ +#define video_driver_threaded_unlock(is_threaded) \ + if (is_threaded) \ video_driver_unlock() #else #define video_driver_lock() ((void)0) #define video_driver_unlock() ((void)0) #define video_driver_lock_free() ((void)0) -#define video_driver_threaded_lock() ((void)0) -#define video_driver_threaded_unlock() ((void)0) +#define video_driver_threaded_lock(is_threaded) ((void)0) +#define video_driver_threaded_unlock(is_threaded) ((void)0) #define video_driver_context_lock() ((void)0) #define video_driver_context_unlock() ((void)0) #endif @@ -994,22 +994,26 @@ void video_driver_cached_frame_get(const void **data, unsigned *width, void video_driver_get_size(unsigned *width, unsigned *height) { - video_driver_threaded_lock(); + bool is_threaded = video_driver_is_threaded(); + + video_driver_threaded_lock(is_threaded); if (width) *width = video_driver_width; if (height) *height = video_driver_height; - video_driver_threaded_unlock(); + video_driver_threaded_unlock(is_threaded); } void video_driver_set_size(unsigned *width, unsigned *height) { - video_driver_threaded_lock(); + bool is_threaded = video_driver_is_threaded(); + + video_driver_threaded_lock(is_threaded); if (width) video_driver_width = *width; if (height) video_driver_height = *height; - video_driver_threaded_unlock(); + video_driver_threaded_unlock(is_threaded); } /** @@ -2241,8 +2245,9 @@ void video_driver_build_info(video_frame_info_t *video_info) bool is_paused = false; bool is_idle = false; bool is_slowmotion = false; + bool is_threaded = video_driver_is_threaded(); settings_t *settings = NULL; - video_driver_threaded_lock(); + video_driver_threaded_lock(is_threaded); settings = config_get_ptr(); video_info->refresh_rate = settings->floats.video_refresh_rate; video_info->black_frame_insertion = @@ -2317,7 +2322,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->runloop_is_paused = is_paused; video_info->runloop_is_idle = is_idle; video_info->runloop_is_slowmotion = is_slowmotion; - video_driver_threaded_unlock(); + video_driver_threaded_unlock(is_threaded); } /**