Start reimplementing audio/video/input driver deiniting

This commit is contained in:
twinaphex 2015-12-04 14:30:59 +01:00
parent 058e941d8a
commit 351077dc78
8 changed files with 42 additions and 19 deletions

View File

@ -269,11 +269,6 @@ static bool uninit_audio(void)
compute_audio_buffer_statistics();
current_audio = NULL;
if (!audio_driver_ctl(RARCH_AUDIO_CTL_OWNS_DRIVER, NULL))
audio_driver_context_audio_data = NULL;
return true;
}
@ -773,6 +768,12 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
break;
case RARCH_AUDIO_CTL_INIT:
return init_audio();
case RARCH_AUDIO_CTL_DESTROY:
current_audio = NULL;
break;
case RARCH_AUDIO_CTL_DESTROY_DATA:
audio_driver_context_audio_data = NULL;
break;
case RARCH_AUDIO_CTL_DEINIT:
return uninit_audio();
case RARCH_AUDIO_CTL_SETUP_REWIND:

View File

@ -77,6 +77,8 @@ enum rarch_audio_ctl_state
RARCH_AUDIO_CTL_NONE = 0,
RARCH_AUDIO_CTL_INIT,
RARCH_AUDIO_CTL_DEINIT,
RARCH_AUDIO_CTL_DESTROY,
RARCH_AUDIO_CTL_DESTROY_DATA,
RARCH_AUDIO_CTL_START,
RARCH_AUDIO_CTL_STOP,
RARCH_AUDIO_CTL_FIND_DRIVER,

View File

@ -41,6 +41,9 @@ driver_t *driver_get_ptr(void)
void driver_free(void)
{
driver_t *driver = driver_get_ptr();
video_driver_ctl(RARCH_DISPLAY_CTL_DESTROY, NULL);
audio_driver_ctl(RARCH_AUDIO_CTL_DESTROY, NULL);
input_driver_ctl(RARCH_INPUT_CTL_DESTROY, NULL);
memset(driver, 0, sizeof(driver_t));
}
@ -464,7 +467,22 @@ void uninit_drivers(int flags)
if (flags & DRIVERS_VIDEO_INPUT)
video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT, NULL);
if (flags & DRIVER_VIDEO)
{
const struct retro_hw_render_callback *hw_render =
(const struct retro_hw_render_callback*)video_driver_callback();
if (hw_render->context_destroy && !video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
hw_render->context_destroy();
}
if ((flags & DRIVER_VIDEO) && !video_driver_ctl(RARCH_DISPLAY_CTL_OWNS_DRIVER, NULL))
video_driver_ctl(RARCH_DISPLAY_CTL_DESTROY_DATA, NULL);
if ((flags & DRIVER_INPUT) && !input_driver_ctl(RARCH_INPUT_CTL_OWNS_DRIVER, NULL))
input_driver_ctl(RARCH_INPUT_CTL_DESTROY, NULL);
input_driver_ctl(RARCH_INPUT_CTL_DESTROY_DATA, NULL);
if ((flags & DRIVER_AUDIO) && !audio_driver_ctl(RARCH_AUDIO_CTL_OWNS_DRIVER, NULL))
audio_driver_ctl(RARCH_AUDIO_CTL_DESTROY_DATA, NULL);
}

View File

@ -511,9 +511,6 @@ static void deinit_pixel_converter(void)
static bool uninit_video_input(void)
{
const struct retro_hw_render_callback *hw_render =
(const struct retro_hw_render_callback*)video_driver_callback();
event_command(EVENT_CMD_OVERLAY_DEINIT);
if (
@ -537,14 +534,7 @@ static bool uninit_video_input(void)
event_command(EVENT_CMD_SHADER_DIR_DEINIT);
video_monitor_compute_fps_statistics();
if (hw_render->context_destroy && !video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
hw_render->context_destroy();
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_RGBA, NULL);
current_video = NULL;
if (!video_driver_ctl(RARCH_DISPLAY_CTL_OWNS_DRIVER, NULL))
video_driver_data = NULL;
return true;
}
@ -1490,6 +1480,13 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
return gfx_ctx_get_video_output_next(gfx_ctx_data_get_ptr());
case RARCH_DISPLAY_CTL_INIT:
return init_video();
case RARCH_DISPLAY_CTL_DESTROY:
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_RGBA, NULL);
current_video = NULL;
break;
case RARCH_DISPLAY_CTL_DESTROY_DATA:
video_driver_data = NULL;
break;
case RARCH_DISPLAY_CTL_DEINIT:
return uninit_video_input();
case RARCH_DISPLAY_CTL_MONITOR_RESET:

View File

@ -279,6 +279,8 @@ enum rarch_display_ctl_state
RARCH_DISPLAY_CTL_NONE = 0,
RARCH_DISPLAY_CTL_INIT,
RARCH_DISPLAY_CTL_DEINIT,
RARCH_DISPLAY_CTL_DESTROY,
RARCH_DISPLAY_CTL_DESTROY_DATA,
RARCH_DISPLAY_CTL_SUPPORTS_RGBA,
RARCH_DISPLAY_CTL_SET_RGBA,
RARCH_DISPLAY_CTL_UNSET_RGBA,

View File

@ -712,13 +712,16 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
return false;
current_input->free(current_input_data);
return true;
case RARCH_INPUT_CTL_DESTROY_DATA:
current_input_data = NULL;
break;
case RARCH_INPUT_CTL_DESTROY:
input_driver_flushing_input = false;
input_driver_block_hotkey = false;
input_driver_nonblock_state = false;
memset(&input_driver_turbo_btns, 0, sizeof(turbo_buttons_t));
current_input = NULL;
current_input_data = NULL;
input_driver_ctl(RARCH_INPUT_CTL_DESTROY_DATA, NULL);
return true;
case RARCH_INPUT_CTL_GRAB_STDIN:
if (current_input->grab_stdin)

View File

@ -52,6 +52,7 @@ enum rarch_input_ctl_state
RARCH_INPUT_CTL_INIT,
RARCH_INPUT_CTL_DEINIT,
RARCH_INPUT_CTL_DESTROY,
RARCH_INPUT_CTL_DESTROY_DATA,
RARCH_INPUT_CTL_HAS_CAPABILITIES,
RARCH_INPUT_CTL_POLL,
RARCH_INPUT_CTL_FIND_DRIVER,

View File

@ -187,7 +187,6 @@ static bool netplay_can_poll(netplay_t *netplay)
static bool send_chunk(netplay_t *netplay)
{
bool check_where_to_send = false;
const struct sockaddr *addr = NULL;
if (netplay->addr)
@ -304,7 +303,7 @@ static bool netplay_get_cmd(netplay_t *netplay)
if (!socket_receive_all_blocking(netplay->fd, &cmd, sizeof(cmd)))
return false;
cmd = ntohl(cmd);
cmd = ntohl(cmd);
cmd_size = cmd & 0xffff;
cmd = cmd >> 16;