mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 06:40:18 +00:00
Pass flags to init_drivers/uninit_drivers
Allow init/uninit of specific drivers instead of all.
This commit is contained in:
parent
623e19edd5
commit
63741eeb57
117
driver.c
117
driver.c
@ -1299,54 +1299,73 @@ static void init_video_input(void)
|
||||
|
||||
}
|
||||
|
||||
void init_drivers(void)
|
||||
void init_drivers(int flags)
|
||||
{
|
||||
driver.video_data_own = false;
|
||||
driver.audio_data_own = false;
|
||||
driver.input_data_own = false;
|
||||
driver.camera_data_own = false;
|
||||
driver.location_data_own = false;
|
||||
driver.osk_data_own = false;
|
||||
if (flags & DRIVER_VIDEO)
|
||||
driver.video_data_own = false;
|
||||
if (flags & DRIVER_AUDIO)
|
||||
driver.audio_data_own = false;
|
||||
if (flags & DRIVER_INPUT)
|
||||
driver.input_data_own = false;
|
||||
if (flags & DRIVER_CAMERA)
|
||||
driver.camera_data_own = false;
|
||||
if (flags & DRIVER_LOCATION)
|
||||
driver.location_data_own = false;
|
||||
if (flags & DRIVER_OSK)
|
||||
driver.osk_data_own = false;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
/* By default, we want the menu to persist through driver reinits. */
|
||||
driver.menu_data_own = true;
|
||||
#endif
|
||||
|
||||
adjust_system_rates();
|
||||
if (flags & (DRIVER_VIDEO | DRIVER_AUDIO))
|
||||
adjust_system_rates();
|
||||
|
||||
g_extern.frame_count = 0;
|
||||
if (flags & DRIVER_VIDEO)
|
||||
{
|
||||
g_extern.frame_count = 0;
|
||||
|
||||
init_video_input();
|
||||
init_video_input();
|
||||
|
||||
if (!driver.video_cache_context_ack
|
||||
&& g_extern.system.hw_render_callback.context_reset)
|
||||
g_extern.system.hw_render_callback.context_reset();
|
||||
driver.video_cache_context_ack = false;
|
||||
if (!driver.video_cache_context_ack
|
||||
&& g_extern.system.hw_render_callback.context_reset)
|
||||
g_extern.system.hw_render_callback.context_reset();
|
||||
driver.video_cache_context_ack = false;
|
||||
|
||||
init_audio();
|
||||
g_extern.system.frame_time_last = 0;
|
||||
}
|
||||
|
||||
if (flags & DRIVER_AUDIO)
|
||||
init_audio();
|
||||
|
||||
/* Only initialize camera driver if we're ever going to use it. */
|
||||
if (driver.camera_active)
|
||||
if ((flags & DRIVER_CAMERA) && driver.camera_active)
|
||||
init_camera();
|
||||
|
||||
/* Only initialize location driver if we're ever going to use it. */
|
||||
if (driver.location_active)
|
||||
if ((flags & DRIVER_LOCATION) && driver.location_active)
|
||||
init_location();
|
||||
|
||||
init_osk();
|
||||
if (flags & DRIVER_OSK)
|
||||
init_osk();
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
init_menu();
|
||||
if (flags & DRIVER_MENU)
|
||||
{
|
||||
init_menu();
|
||||
|
||||
if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_reset)
|
||||
driver.menu_ctx->context_reset(driver.menu);
|
||||
if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_reset)
|
||||
driver.menu_ctx->context_reset(driver.menu);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Keep non-throttled state as good as possible. */
|
||||
if (driver.nonblock_state)
|
||||
driver_set_nonblock_state(driver.nonblock_state);
|
||||
|
||||
g_extern.system.frame_time_last = 0;
|
||||
if (flags & (DRIVER_VIDEO | DRIVER_AUDIO))
|
||||
{
|
||||
/* Keep non-throttled state as good as possible. */
|
||||
if (driver.nonblock_state)
|
||||
driver_set_nonblock_state(driver.nonblock_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1482,53 +1501,61 @@ static void uninit_video_input(void)
|
||||
compute_monitor_fps_statistics();
|
||||
}
|
||||
|
||||
void uninit_drivers(void)
|
||||
void uninit_drivers(int flags)
|
||||
{
|
||||
uninit_audio();
|
||||
if (flags & DRIVER_AUDIO)
|
||||
uninit_audio();
|
||||
|
||||
if (g_extern.system.hw_render_callback.context_destroy &&
|
||||
!driver.video_cache_context)
|
||||
g_extern.system.hw_render_callback.context_destroy();
|
||||
if (flags & DRIVER_VIDEO)
|
||||
{
|
||||
if (g_extern.system.hw_render_callback.context_destroy &&
|
||||
!driver.video_cache_context)
|
||||
g_extern.system.hw_render_callback.context_destroy();
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_destroy)
|
||||
driver.menu_ctx->context_destroy(driver.menu);
|
||||
|
||||
if (!driver.menu_data_own)
|
||||
if (flags & DRIVER_MENU)
|
||||
{
|
||||
menu_free_list(driver.menu);
|
||||
menu_free(driver.menu);
|
||||
driver.menu = NULL;
|
||||
if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_destroy)
|
||||
driver.menu_ctx->context_destroy(driver.menu);
|
||||
|
||||
if (!driver.menu_data_own)
|
||||
{
|
||||
menu_free_list(driver.menu);
|
||||
menu_free(driver.menu);
|
||||
driver.menu = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uninit_video_input();
|
||||
if (flags & DRIVERS_VIDEO_INPUT)
|
||||
uninit_video_input();
|
||||
|
||||
if (!driver.video_data_own)
|
||||
if ((flags & DRIVER_VIDEO) && !driver.video_data_own)
|
||||
driver.video_data = NULL;
|
||||
|
||||
if (!driver.camera_data_own)
|
||||
if ((flags & DRIVER_CAMERA) && !driver.camera_data_own)
|
||||
{
|
||||
uninit_camera();
|
||||
driver.camera_data = NULL;
|
||||
}
|
||||
|
||||
if (!driver.location_data_own)
|
||||
if ((flags & DRIVER_LOCATION) && !driver.location_data_own)
|
||||
{
|
||||
uninit_location();
|
||||
driver.location_data = NULL;
|
||||
}
|
||||
|
||||
if (!driver.osk_data_own)
|
||||
if ((flags & DRIVER_OSK) && !driver.osk_data_own)
|
||||
{
|
||||
uninit_osk();
|
||||
driver.osk_data = NULL;
|
||||
}
|
||||
|
||||
if (!driver.input_data_own)
|
||||
if ((flags & DRIVER_INPUT) && !driver.input_data_own)
|
||||
driver.input_data = NULL;
|
||||
|
||||
if (!driver.audio_data_own)
|
||||
if ((flags & DRIVER_AUDIO) && !driver.audio_data_own)
|
||||
driver.audio_data = NULL;
|
||||
}
|
||||
|
||||
|
28
driver.h
28
driver.h
@ -440,6 +440,30 @@ enum rarch_display_type
|
||||
RARCH_DISPLAY_OSX
|
||||
};
|
||||
|
||||
/* Flags for init_drivers/uninit_drivers */
|
||||
enum
|
||||
{
|
||||
DRIVER_AUDIO = 1 << 0,
|
||||
DRIVER_VIDEO = 1 << 1,
|
||||
DRIVER_INPUT = 1 << 2,
|
||||
DRIVER_OSK = 1 << 3,
|
||||
DRIVER_CAMERA = 1 << 4,
|
||||
DRIVER_LOCATION = 1 << 5,
|
||||
DRIVER_MENU = 1 << 6,
|
||||
DRIVERS_VIDEO_INPUT = 1 << 7 /* note multiple drivers */
|
||||
};
|
||||
|
||||
/* Drivers for RARCH_CMD_DRIVERS_DEINIT and RARCH_CMD_DRIVERS_INIT */
|
||||
#define DRIVERS_CMD_ALL \
|
||||
( DRIVER_AUDIO \
|
||||
| DRIVER_VIDEO \
|
||||
| DRIVER_INPUT \
|
||||
| DRIVER_OSK \
|
||||
| DRIVER_CAMERA \
|
||||
| DRIVER_LOCATION \
|
||||
| DRIVER_MENU \
|
||||
| DRIVERS_VIDEO_INPUT )
|
||||
|
||||
typedef struct driver
|
||||
{
|
||||
const frontend_ctx_driver_t *frontend_ctx;
|
||||
@ -550,9 +574,9 @@ typedef struct driver
|
||||
const char *current_msg;
|
||||
} driver_t;
|
||||
|
||||
void init_drivers(void);
|
||||
void init_drivers(int flags);
|
||||
void init_drivers_pre(void);
|
||||
void uninit_drivers(void);
|
||||
void uninit_drivers(int flags);
|
||||
|
||||
void find_prev_driver(const char *label, char *str, size_t sizeof_str);
|
||||
void find_next_driver(const char *label, char *str, size_t sizeof_str);
|
||||
|
@ -2451,10 +2451,10 @@ bool rarch_main_command(unsigned cmd)
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CMD_DRIVERS_DEINIT:
|
||||
uninit_drivers();
|
||||
uninit_drivers(DRIVERS_CMD_ALL);
|
||||
break;
|
||||
case RARCH_CMD_DRIVERS_INIT:
|
||||
init_drivers();
|
||||
init_drivers(DRIVERS_CMD_ALL);
|
||||
break;
|
||||
case RARCH_CMD_RESET_CONTEXT:
|
||||
rarch_main_command(RARCH_CMD_DRIVERS_DEINIT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user