Netplay netpacket connection flow improvements (#15986)

- Allow starting netplay host while a netpacket core is running without restart
- Allow connecting to a host while a netpacket core is running without restart
- Avoid clients getting stuck in connection loop if the host has the content paused while a client connects by automatically unpausing
This commit is contained in:
Bernhard Schelling 2023-12-09 21:48:36 +09:00 committed by GitHub
parent 26918b25e0
commit f029b41a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 8 deletions

View File

@ -7701,7 +7701,14 @@ static void action_ok_netplay_enable_client_hostname_cb(void *userdata,
{
if (!string_is_empty(line))
{
if (!task_push_netplay_content_reload(line))
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
command_event(CMD_EVENT_NETPLAY_INIT_DIRECT, (void*)line);
menu_input_dialog_end();
retroarch_menu_running_finished(false);
}
else if (!task_push_netplay_content_reload(line))
{
#ifdef HAVE_DYNAMIC
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);

View File

@ -76,7 +76,7 @@ enum rarch_netplay_ctl_state
RARCH_NETPLAY_CTL_KICK_CLIENT,
RARCH_NETPLAY_CTL_BAN_CLIENT,
RARCH_NETPLAY_CTL_SET_CORE_PACKET_INTERFACE,
RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS,
RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE,
RARCH_NETPLAY_CTL_ALLOW_TIMESKIP
};

View File

@ -9242,9 +9242,17 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
break;
case RARCH_NETPLAY_CTL_PAUSE:
if ( netplay
&& (!(netplay->local_paused)))
if (netplay && !netplay->local_paused)
netplay_frontend_paused(netplay, true);
if (netplay && netplay->modus == NETPLAY_MODUS_CORE_PACKET_INTERFACE)
{
/* handle new connections while paused, unpause on connect */
if (!netplay_sync_pre_frame(netplay))
netplay_disconnect(netplay);
else if (netplay_have_any_active_connection(netplay))
command_event(CMD_EVENT_UNPAUSE, NULL);
}
break;
case RARCH_NETPLAY_CTL_UNPAUSE:
@ -9372,7 +9380,7 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
}
break;
case RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS:
case RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE:
ret = (net_st->core_netpacket_interface != NULL);
break;

View File

@ -3958,7 +3958,12 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_NETPLAY_ENABLE_HOST:
{
if (!task_push_netplay_content_reload(NULL))
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL);
command_event(CMD_EVENT_NETPLAY_INIT, NULL);
}
else if (!task_push_netplay_content_reload(NULL))
{
#ifdef HAVE_DYNAMIC
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);

View File

@ -7445,7 +7445,7 @@ bool core_set_netplay_callbacks(void)
{
runloop_state_t *runloop_st = &runloop_state;
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS, NULL))
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
return true;
/* Force normal poll type for netplay. */
@ -8031,7 +8031,7 @@ void runloop_path_set_redirect(settings_t *settings,
/* Special save directory for netplay clients. */
if ( netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL)
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS, NULL))
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{
fill_pathname_join(new_savefile_dir, new_savefile_dir, ".netplay",
sizeof(new_savefile_dir));