From 712115ef9d7096f263577b5eeda8e9dd4c5b18cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 27 Feb 2019 17:02:33 +0100 Subject: [PATCH] (Wifi/Location/Camera) Get rid of 'own driver' mechanism --- camera/camera_driver.c | 10 ---------- camera/camera_driver.h | 3 --- location/location_driver.c | 10 ---------- location/location_driver.h | 3 --- retroarch.c | 35 ++++++++++++++++++++--------------- wifi/wifi_driver.c | 10 ---------- wifi/wifi_driver.h | 3 --- 7 files changed, 20 insertions(+), 54 deletions(-) diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 3f27a81c8d..fc8dbc9eb6 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -46,7 +46,6 @@ static struct retro_camera_callback camera_cb; static const camera_driver_t *camera_driver = NULL; static void *camera_data = NULL; static bool camera_driver_active = false; -static bool camera_driver_data_own = false; /** * camera_driver_find_handle: @@ -121,18 +120,9 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) { case RARCH_CAMERA_CTL_DESTROY: camera_driver_active = false; - camera_driver_data_own = false; camera_driver = NULL; camera_data = NULL; break; - case RARCH_CAMERA_CTL_SET_OWN_DRIVER: - camera_driver_data_own = true; - break; - case RARCH_CAMERA_CTL_UNSET_OWN_DRIVER: - camera_driver_data_own = false; - break; - case RARCH_CAMERA_CTL_OWNS_DRIVER: - return camera_driver_data_own; case RARCH_CAMERA_CTL_SET_ACTIVE: camera_driver_active = true; break; diff --git a/camera/camera_driver.h b/camera/camera_driver.h index 25bbc71d38..8166d5c720 100644 --- a/camera/camera_driver.h +++ b/camera/camera_driver.h @@ -30,9 +30,6 @@ enum rarch_camera_ctl_state RARCH_CAMERA_CTL_NONE = 0, RARCH_CAMERA_CTL_DESTROY, RARCH_CAMERA_CTL_DEINIT, - RARCH_CAMERA_CTL_SET_OWN_DRIVER, - RARCH_CAMERA_CTL_UNSET_OWN_DRIVER, - RARCH_CAMERA_CTL_OWNS_DRIVER, RARCH_CAMERA_CTL_SET_ACTIVE, RARCH_CAMERA_CTL_UNSET_ACTIVE, RARCH_CAMERA_CTL_IS_ACTIVE, diff --git a/location/location_driver.c b/location/location_driver.c index 13d0f22d99..5d8c62b445 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -243,26 +243,16 @@ static void uninit_location(void) bool location_driver_ctl(enum rarch_location_ctl_state state, void *data) { static bool location_driver_active = false; - static bool location_driver_data_own = false; switch (state) { case RARCH_LOCATION_CTL_DESTROY: location_driver_active = false; - location_driver_data_own = false; location_driver = NULL; break; case RARCH_LOCATION_CTL_DEINIT: uninit_location(); break; - case RARCH_LOCATION_CTL_SET_OWN_DRIVER: - location_driver_data_own = true; - break; - case RARCH_LOCATION_CTL_UNSET_OWN_DRIVER: - location_driver_data_own = false; - break; - case RARCH_LOCATION_CTL_OWNS_DRIVER: - return location_driver_data_own; case RARCH_LOCATION_CTL_SET_ACTIVE: location_driver_active = true; break; diff --git a/location/location_driver.h b/location/location_driver.h index f592967e42..3cfeda2dba 100644 --- a/location/location_driver.h +++ b/location/location_driver.h @@ -30,9 +30,6 @@ enum rarch_location_ctl_state RARCH_LOCATION_CTL_NONE = 0, RARCH_LOCATION_CTL_DESTROY, RARCH_LOCATION_CTL_DEINIT, - RARCH_LOCATION_CTL_SET_OWN_DRIVER, - RARCH_LOCATION_CTL_UNSET_OWN_DRIVER, - RARCH_LOCATION_CTL_OWNS_DRIVER, RARCH_LOCATION_CTL_SET_ACTIVE, RARCH_LOCATION_CTL_UNSET_ACTIVE, RARCH_LOCATION_CTL_IS_ACTIVE diff --git a/retroarch.c b/retroarch.c index 6bf4b9735c..6abcc73e78 100644 --- a/retroarch.c +++ b/retroarch.c @@ -575,12 +575,6 @@ void drivers_init(int flags) audio_driver_unset_own_driver(); if (flags & DRIVER_INPUT_MASK) input_driver_unset_own_driver(); - if (flags & DRIVER_CAMERA_MASK) - camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_OWN_DRIVER, NULL); - if (flags & DRIVER_LOCATION_MASK) - location_driver_ctl(RARCH_LOCATION_CTL_UNSET_OWN_DRIVER, NULL); - if (flags & DRIVER_WIFI_MASK) - wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_OWN_DRIVER, NULL); #ifdef HAVE_MENU /* By default, we want the menu to persist through driver reinits. */ @@ -590,6 +584,7 @@ void drivers_init(int flags) if (flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK)) driver_adjust_system_rates(); + /* Initialize video driver */ if (flags & DRIVER_VIDEO_MASK) { struct retro_hw_render_callback *hwr = @@ -606,19 +601,26 @@ void drivers_init(int flags) runloop_frame_time_last = 0; } + /* Initialize audio driver */ if (flags & DRIVER_AUDIO_MASK) { audio_driver_init(); audio_driver_new_devices_list(); } - /* Only initialize camera driver if we're ever going to use it. */ - if ((flags & DRIVER_CAMERA_MASK) && camera_driver_ctl(RARCH_CAMERA_CTL_IS_ACTIVE, NULL)) - camera_driver_ctl(RARCH_CAMERA_CTL_INIT, NULL); + if (flags & DRIVER_CAMERA_MASK) + { + /* Only initialize camera driver if we're ever going to use it. */ + if (camera_driver_ctl(RARCH_CAMERA_CTL_IS_ACTIVE, NULL)) + camera_driver_ctl(RARCH_CAMERA_CTL_INIT, NULL); + } - /* Only initialize location driver if we're ever going to use it. */ - if ((flags & DRIVER_LOCATION_MASK) && location_driver_ctl(RARCH_LOCATION_CTL_IS_ACTIVE, NULL)) - init_location(); + if (flags & DRIVER_LOCATION_MASK) + { + /* Only initialize location driver if we're ever going to use it. */ + if (location_driver_ctl(RARCH_LOCATION_CTL_IS_ACTIVE, NULL)) + init_location(); + } core_info_init_current_core(); @@ -633,6 +635,7 @@ void drivers_init(int flags) if (flags & DRIVER_VIDEO_MASK) { + /* Initialize menu driver */ if (flags & DRIVER_MENU_MASK) menu_driver_init(video_is_threaded); } @@ -649,9 +652,11 @@ void drivers_init(int flags) driver_set_nonblock_state(); } + /* Initialize LED driver */ if (flags & DRIVER_LED_MASK) led_driver_init(); + /* Initialize MIDI driver */ if (flags & DRIVER_MIDI_MASK) midi_driver_init(); } @@ -693,13 +698,13 @@ void driver_uninit(int flags) } #endif - if ((flags & DRIVER_LOCATION_MASK) && !location_driver_ctl(RARCH_LOCATION_CTL_OWNS_DRIVER, NULL)) + if ((flags & DRIVER_LOCATION_MASK)) location_driver_ctl(RARCH_LOCATION_CTL_DEINIT, NULL); - if ((flags & DRIVER_CAMERA_MASK) && !camera_driver_ctl(RARCH_CAMERA_CTL_OWNS_DRIVER, NULL)) + if ((flags & DRIVER_CAMERA_MASK)) camera_driver_ctl(RARCH_CAMERA_CTL_DEINIT, NULL); - if ((flags & DRIVER_WIFI_MASK) && !wifi_driver_ctl(RARCH_WIFI_CTL_OWNS_DRIVER, NULL)) + if ((flags & DRIVER_WIFI_MASK)) wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL); if (flags & DRIVER_LED) diff --git a/wifi/wifi_driver.c b/wifi/wifi_driver.c index 53222d571a..9bb63c48ee 100644 --- a/wifi/wifi_driver.c +++ b/wifi/wifi_driver.c @@ -32,7 +32,6 @@ static const wifi_driver_t *wifi_driver = NULL; static void *wifi_data = NULL; static bool wifi_driver_active = false; -static bool wifi_driver_data_own = false; static const wifi_driver_t *wifi_drivers[] = { #ifdef HAVE_LAKKA @@ -124,18 +123,9 @@ bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data) { case RARCH_WIFI_CTL_DESTROY: wifi_driver_active = false; - wifi_driver_data_own = false; wifi_driver = NULL; wifi_data = NULL; break; - case RARCH_WIFI_CTL_SET_OWN_DRIVER: - wifi_driver_data_own = true; - break; - case RARCH_WIFI_CTL_UNSET_OWN_DRIVER: - wifi_driver_data_own = false; - break; - case RARCH_WIFI_CTL_OWNS_DRIVER: - return wifi_driver_data_own; case RARCH_WIFI_CTL_SET_ACTIVE: wifi_driver_active = true; break; diff --git a/wifi/wifi_driver.h b/wifi/wifi_driver.h index 0477f0b435..586f9c4079 100644 --- a/wifi/wifi_driver.h +++ b/wifi/wifi_driver.h @@ -31,9 +31,6 @@ enum rarch_wifi_ctl_state RARCH_WIFI_CTL_NONE = 0, RARCH_WIFI_CTL_DESTROY, RARCH_WIFI_CTL_DEINIT, - RARCH_WIFI_CTL_SET_OWN_DRIVER, - RARCH_WIFI_CTL_UNSET_OWN_DRIVER, - RARCH_WIFI_CTL_OWNS_DRIVER, RARCH_WIFI_CTL_SET_ACTIVE, RARCH_WIFI_CTL_UNSET_ACTIVE, RARCH_WIFI_CTL_IS_ACTIVE,