In spectator mode, we should never be ahead of our peer.

This commit is contained in:
Gregor Richards 2017-02-22 23:19:22 -05:00
parent 3e0bc5acdc
commit e495671563
2 changed files with 27 additions and 0 deletions

View File

@ -303,6 +303,11 @@ static bool netplay_poll(void)
break;
}
case NETPLAY_STALL_SPECTATOR_WAIT:
if (netplay_data->unread_frame_count > netplay_data->self_frame_count)
netplay_data->stall = NETPLAY_STALL_NONE;
break;
case NETPLAY_STALL_INPUT_LATENCY:
/* Just let it recalculate momentarily */
netplay_data->stall = NETPLAY_STALL_NONE;
@ -374,6 +379,16 @@ static bool netplay_poll(void)
}
}
/* If we're a spectator, are we ahead at all? */
if (!netplay_data->is_server &&
(netplay_data->self_mode == NETPLAY_CONNECTION_SPECTATING ||
netplay_data->self_mode == NETPLAY_CONNECTION_SLAVE) &&
netplay_data->unread_frame_count <= netplay_data->self_frame_count)
{
netplay_data->stall = NETPLAY_STALL_SPECTATOR_WAIT;
netplay_data->stall_time = cpu_features_get_time_usec();
}
}
/* If we're stalling, consider disconnection */

View File

@ -215,9 +215,21 @@ enum rarch_netplay_connection_mode
enum rarch_netplay_stall_reason
{
NETPLAY_STALL_NONE = 0,
/* We're so far ahead that we can't read more data without overflowing the
* buffer */
NETPLAY_STALL_RUNNING_FAST,
/* We're in spectator or slave mode and are running ahead at all */
NETPLAY_STALL_SPECTATOR_WAIT,
/* Our actual execution is catching up with latency-adjusted input frames */
NETPLAY_STALL_INPUT_LATENCY,
/* The server asked us to stall */
NETPLAY_STALL_SERVER_REQUESTED,
/* We have no connection and must have one to proceed */
NETPLAY_STALL_NO_CONNECTION
};