mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-07 02:40:23 +00:00
45d732a014
The idea: * Use a fixed number of delay_frames (eventually to be fixed at 120, currently still uses the config variable, 0 will still be an option) * Determine how long it takes to simulate a frame. * Stall only if resimulating the intervening frames would be sufficiently annoying (currently fixed at three frames worth of time) Because clients always try to catch up, the actual frame delay works out automatically to be minimally zero and maximally the latency. If one client is underpowered but the other is fine, the powerful one will automatically take up the slack. Seems like the most reasonable system.
82 lines
2.5 KiB
C
82 lines
2.5 KiB
C
/* RetroArch - A frontend for libretro.
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
|
* Copyright (C) 2016 - Gregor Richards
|
|
*
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
|
|
#ifndef __RARCH_NETPLAY_H
|
|
#define __RARCH_NETPLAY_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#include <boolean.h>
|
|
#include <libretro.h>
|
|
|
|
#include "../../core.h"
|
|
|
|
typedef struct netplay netplay_t;
|
|
|
|
enum rarch_netplay_ctl_state
|
|
{
|
|
RARCH_NETPLAY_CTL_NONE = 0,
|
|
RARCH_NETPLAY_CTL_FLIP_PLAYERS,
|
|
RARCH_NETPLAY_CTL_GAME_WATCH,
|
|
RARCH_NETPLAY_CTL_POST_FRAME,
|
|
RARCH_NETPLAY_CTL_PRE_FRAME,
|
|
RARCH_NETPLAY_CTL_ENABLE_SERVER,
|
|
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
|
|
RARCH_NETPLAY_CTL_DISABLE,
|
|
RARCH_NETPLAY_CTL_IS_ENABLED,
|
|
RARCH_NETPLAY_CTL_IS_DATA_INITED,
|
|
RARCH_NETPLAY_CTL_PAUSE,
|
|
RARCH_NETPLAY_CTL_UNPAUSE,
|
|
RARCH_NETPLAY_CTL_LOAD_SAVESTATE,
|
|
RARCH_NETPLAY_CTL_DISCONNECT
|
|
};
|
|
|
|
int16_t input_state_net(unsigned port, unsigned device,
|
|
unsigned idx, unsigned id);
|
|
|
|
void video_frame_net(const void *data, unsigned width,
|
|
unsigned height, size_t pitch);
|
|
|
|
void audio_sample_net(int16_t left, int16_t right);
|
|
|
|
size_t audio_sample_batch_net(const int16_t *data, size_t frames);
|
|
|
|
/**
|
|
* init_netplay
|
|
* @direct_host : Host to connect to directly, if applicable (client only)
|
|
* @server : server address to connect to (client only)
|
|
* @port : TCP port to host on/connect to
|
|
* @play_password : Password required to play (server only)
|
|
* @spectate_password : Password required to connect (server only)
|
|
*
|
|
* Initializes netplay.
|
|
*
|
|
* If netplay is already initialized, will return false (0).
|
|
*
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
**/
|
|
bool init_netplay(void *direct_host, const char *server, unsigned port,
|
|
const char *play_password, const char *spectate_password);
|
|
|
|
void deinit_netplay(void);
|
|
|
|
bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data);
|
|
|
|
#endif
|