Merge remote-tracking branch 'refs/remotes/libretro/master' into wiiu_controller_patcher

This commit is contained in:
Maschell 2017-05-20 19:27:13 +02:00
commit 2da8a18086
21 changed files with 529 additions and 287 deletions

View File

@ -172,6 +172,7 @@ OBJ += frontend/frontend.o \
$(LIBRETRO_COMM_DIR)/lists/file_list.o \
$(LIBRETRO_COMM_DIR)/lists/dir_list.o \
$(LIBRETRO_COMM_DIR)/file/retro_dirent.o \
$(LIBRETRO_COMM_DIR)/streams/stdin_stream.o \
$(LIBRETRO_COMM_DIR)/streams/file_stream.o \
$(LIBRETRO_COMM_DIR)/streams/interface_stream.o \
$(LIBRETRO_COMM_DIR)/streams/memory_stream.o \

177
command.c
View File

@ -18,27 +18,22 @@
#include <string.h>
#include <ctype.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <file/file_path.h>
#include <lists/dir_list.h>
#include <string/stdstring.h>
#include <streams/stdin_stream.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_COMMAND
#ifdef HAVE_NETWORKING
#include <net/net_compat.h>
#include <net/net_socket.h>
#endif
#ifdef HAVE_NETWORKING
#include <net/net_compat.h>
#include <net/net_socket.h>
#endif
#include <string/stdstring.h>
#endif
@ -424,60 +419,6 @@ error:
return false;
}
static bool send_udp_packet(const char *host,
uint16_t port, const char *msg)
{
char port_buf[16] = {0};
struct addrinfo hints = {0};
struct addrinfo *res = NULL;
const struct addrinfo *tmp = NULL;
int fd = -1;
bool ret = true;
hints.ai_socktype = SOCK_DGRAM;
snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port);
if (getaddrinfo_retro(host, port_buf, &hints, &res) < 0)
return false;
/* Send to all possible targets.
* "localhost" might resolve to several different IPs. */
tmp = (const struct addrinfo*)res;
while (tmp)
{
ssize_t len, ret_len;
fd = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol);
if (fd < 0)
{
ret = false;
goto end;
}
len = strlen(msg);
ret_len = sendto(fd, msg, len, 0, tmp->ai_addr, tmp->ai_addrlen);
if (ret_len < len)
{
ret = false;
goto end;
}
socket_close(fd);
fd = -1;
tmp = tmp->ai_next;
}
end:
freeaddrinfo_retro(res);
if (fd >= 0)
socket_close(fd);
return ret;
}
static bool command_verify(const char *cmd)
{
unsigned i;
@ -536,7 +477,7 @@ bool command_network_send(const char *cmd_)
msg_hash_to_str(MSG_SENDING_COMMAND),
cmd, host, (unsigned short)port);
ret = command_verify(cmd) && send_udp_packet(host, port, cmd);
ret = command_verify(cmd) && udp_send_packet(host, port, cmd);
}
free(command);
@ -643,112 +584,6 @@ error:
#ifdef HAVE_STDIN_CMD
#ifdef _WIN32
static size_t read_stdin(char *buf, size_t size)
{
DWORD i;
DWORD has_read = 0;
DWORD avail = 0;
bool echo = false;
HANDLE hnd = GetStdHandle(STD_INPUT_HANDLE);
if (hnd == INVALID_HANDLE_VALUE)
return 0;
/* Check first if we're a pipe
* (not console). */
/* If not a pipe, check if we're running in a console. */
if (!PeekNamedPipe(hnd, NULL, 0, NULL, &avail, NULL))
{
INPUT_RECORD recs[256];
bool has_key = false;
DWORD mode = 0;
DWORD has_read = 0;
if (!GetConsoleMode(hnd, &mode))
return 0;
if ((mode & (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT))
&& !SetConsoleMode(hnd,
mode & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT)))
return 0;
/* Win32, Y U NO SANE NONBLOCK READ!? */
if (!PeekConsoleInput(hnd, recs,
sizeof(recs) / sizeof(recs[0]), &has_read))
return 0;
for (i = 0; i < has_read; i++)
{
/* Very crude, but should get the job done. */
if (recs[i].EventType == KEY_EVENT &&
recs[i].Event.KeyEvent.bKeyDown &&
(isgraph(recs[i].Event.KeyEvent.wVirtualKeyCode) ||
recs[i].Event.KeyEvent.wVirtualKeyCode == VK_RETURN))
{
has_key = true;
echo = true;
avail = size;
break;
}
}
if (!has_key)
{
FlushConsoleInputBuffer(hnd);
return 0;
}
}
if (!avail)
return 0;
if (avail > size)
avail = size;
if (!ReadFile(hnd, buf, avail, &has_read, NULL))
return 0;
for (i = 0; i < has_read; i++)
if (buf[i] == '\r')
buf[i] = '\n';
/* Console won't echo for us while in non-line mode,
* so do it manually ... */
if (echo)
{
HANDLE hnd_out = GetStdHandle(STD_OUTPUT_HANDLE);
if (hnd_out != INVALID_HANDLE_VALUE)
{
DWORD has_written;
WriteConsole(hnd_out, buf, has_read, &has_written, NULL);
}
}
return has_read;
}
#else
static size_t read_stdin(char *buf, size_t size)
{
size_t has_read = 0;
while (size)
{
ssize_t ret = read(STDIN_FILENO, buf, size);
if (ret <= 0)
break;
buf += ret;
has_read += ret;
size -= ret;
}
return has_read;
}
#endif
static void command_stdin_poll(command_t *handle)
{

View File

@ -133,6 +133,7 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
#include <assert.h>
#include <compat/strl.h>
#include <net/net_compat.h>
/* clock_gettime is not implemented on OSX */
int clock_gettime(int clk_id, struct timespec *t);
@ -5727,7 +5728,7 @@ mg_inet_pton(int af, const char *src, void *dst, size_t dstlen)
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = af;
if (getaddrinfo(src, NULL, &hints, &res) != 0) {
if (getaddrinfo_retro(src, NULL, &hints, &res) != 0) {
/* bad src string or bad address family */
return 0;
}

View File

@ -53,6 +53,8 @@
#define herror(A) printf("%s\n", A)
#endif
#include <net/net_compat.h>
#include "connecthostport.h"
#ifndef MAXHOSTNAMELEN
@ -173,7 +175,7 @@ int connecthostport(const char * host, unsigned short port,
strncpy(tmp_host, host, MAXHOSTNAMELEN);
}
tmp_host[MAXHOSTNAMELEN] = '\0';
n = getaddrinfo(tmp_host, port_str, &hints, &ai);
n = getaddrinfo_retro(tmp_host, port_str, &hints, &ai);
if(n != 0)
{
#ifdef _WIN32

View File

@ -98,6 +98,8 @@ struct ip_mreqn
#include "miniupnpc.h"
#include "receivedata.h"
#include <net/net_compat.h>
#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__))
#include "codelength.h"
@ -757,7 +759,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
hints.ai_family = AF_UNSPEC; /* AF_INET6 or AF_INET */
hints.ai_socktype = SOCK_DGRAM;
/*hints.ai_flags = */
if ((rv = getaddrinfo(ipv6
if ((rv = getaddrinfo_retro(ipv6
? (linklocal ? UPNP_MCAST_LL_ADDR : UPNP_MCAST_SL_ADDR)
: UPNP_MCAST_ADDR,
XSTR(SSDP_PORT), &hints, &servinfo)) != 0) {

View File

@ -406,15 +406,15 @@ static void uninit_drivers(int flags)
if ((flags & DRIVER_CAMERA_MASK) && !camera_driver_ctl(RARCH_CAMERA_CTL_OWNS_DRIVER, NULL))
camera_driver_ctl(RARCH_CAMERA_CTL_DEINIT, NULL);
if (flags & DRIVER_AUDIO_MASK)
audio_driver_deinit();
if ((flags & DRIVER_WIFI_MASK) && !wifi_driver_ctl(RARCH_WIFI_CTL_OWNS_DRIVER, NULL))
wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL);
if (flags & DRIVERS_VIDEO_INPUT)
video_driver_free();
if (flags & DRIVER_AUDIO_MASK)
audio_driver_deinit();
if ((flags & DRIVER_VIDEO_MASK) && !video_driver_owns_driver())
video_driver_destroy_data();

View File

@ -28,6 +28,8 @@
#include <windows.h>
#include <commdlg.h>
#include <string/stdstring.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
@ -217,11 +219,22 @@ static void gfx_ctx_gdi_input_driver(void *data,
const input_driver_t **input, void **input_data)
{
(void)data;
settings_t *settings = config_get_ptr();
dinput_gdi = input_dinput.init(joypad_name);
if (string_is_equal_fast(settings->arrays.input_driver, "raw", 4))
{
*input_data = input_winraw.init(joypad_name);
if (*input_data)
{
*input = &input_winraw;
dinput_gdi = NULL;
return;
}
}
*input = dinput_gdi ? &input_dinput : NULL;
*input_data = dinput_gdi;
dinput_gdi = input_dinput.init(joypad_name);
*input = dinput_gdi ? &input_dinput : NULL;
*input_data = dinput_gdi;
}
static bool gfx_ctx_gdi_has_focus(void *data)

View File

@ -123,6 +123,7 @@ typedef struct video_pixel_scaler
static void (*video_driver_cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
static bool (*video_driver_cb_shader_set_mvp)(void *data, void *shader_data, const math_matrix_4x4 *mat);
bool (*video_driver_cb_has_focus)(void);
/* Opaque handles to currently running window.
* Used by e.g. input drivers which bind to a window.
@ -162,8 +163,8 @@ static uint64_t video_driver_frame_count = 0;
static video_viewport_t video_viewport_custom;
void *video_driver_data = NULL;
video_driver_t *current_video = NULL;
static void *video_driver_data = NULL;
static video_driver_t *current_video = NULL;
/* Interface for "poking". */
static const video_poke_interface_t *video_driver_poke = NULL;
@ -204,9 +205,9 @@ static slock_t *display_lock = NULL;
static slock_t *context_lock = NULL;
#endif
gfx_ctx_driver_t current_video_context;
static gfx_ctx_driver_t current_video_context;
void *video_context_data = NULL;
static void *video_context_data = NULL;
shader_backend_t *current_shader = NULL;
void *shader_data = NULL;
@ -512,6 +513,21 @@ const video_poke_interface_t *video_driver_get_poke(void)
return video_driver_poke;
}
static bool video_context_has_focus(void)
{
return current_video_context.has_focus(video_context_data);
}
static bool video_driver_has_focus(void)
{
return current_video->focus(video_driver_data);
}
static bool null_driver_has_focus(void)
{
return true;
}
static void video_context_driver_reset(void)
{
if (!current_video_context.get_metrics)
@ -525,6 +541,9 @@ static void video_context_driver_reset(void)
if (!current_video_context.swap_buffers)
current_video_context.swap_buffers = swap_buffers_null;
if (current_video_context.has_focus)
video_driver_cb_has_focus = video_context_has_focus;
}
bool video_context_driver_set(const gfx_ctx_driver_t *data)
@ -1007,6 +1026,9 @@ static bool video_driver_init_internal(bool *video_is_threaded)
goto error;
}
if (current_video->focus)
video_driver_cb_has_focus = video_driver_has_focus;
video_driver_poke = NULL;
if (current_video->poke_interface)
current_video->poke_interface(video_driver_data, &video_driver_poke);
@ -1512,6 +1534,7 @@ static void video_driver_lock_new(void)
void video_driver_destroy(void)
{
video_driver_cb_has_focus = null_driver_has_focus;
video_driver_use_rgba = false;
video_driver_data_own = false;
video_driver_active = false;
@ -2586,13 +2609,12 @@ void video_driver_get_window_title(char *buf, unsigned len)
}
}
void video_driver_get_status(uint64_t *frame_count, bool * is_alive,
bool *is_focused)
{
*frame_count = video_driver_frame_count;
*is_alive = video_driver_is_alive();
*is_focused = video_driver_is_focused();
*is_alive = current_video ? current_video->alive(video_driver_data) : true;
*is_focused = video_driver_cb_has_focus();
}
/**
@ -2993,11 +3015,7 @@ bool video_context_driver_set_flags(gfx_ctx_flags_t *flags)
bool video_driver_is_focused(void)
{
if (video_context_data && current_video_context.has_focus)
return current_video_context.has_focus(video_context_data);
else if (current_video->focus)
return current_video->focus(video_driver_data);
return true;
return video_driver_cb_has_focus();
}
bool video_driver_has_windowed(void)

View File

@ -181,9 +181,6 @@ struct uniform_info
} result;
};
typedef struct shader_backend
{
void *(*init)(void *data, const char *path);
@ -779,10 +776,6 @@ struct aspect_ratio_elem
extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
#define video_driver_is_alive() ((current_video) ? current_video->alive(video_driver_data) : true)
bool video_driver_is_focused(void);
bool video_driver_has_windowed(void);
bool video_driver_cached_frame_has_valid_framebuffer(void);
@ -1120,9 +1113,6 @@ extern const gfx_ctx_driver_t gfx_ctx_khr_display;
extern const gfx_ctx_driver_t gfx_ctx_gdi;
extern const gfx_ctx_driver_t gfx_ctx_null;
extern void *video_driver_data;
extern video_driver_t *current_video;
/**
* video_context_driver_init_first:
* @data : Input data.
@ -1194,10 +1184,6 @@ bool video_context_driver_input_driver(gfx_ctx_input_t *inp);
void video_context_driver_free(void);
extern gfx_ctx_driver_t current_video_context;
extern void *video_context_data;
bool video_shader_driver_get_prev_textures(video_shader_ctx_texture_t *texture);
bool video_shader_driver_get_ident(video_shader_ctx_ident_t *ident);
@ -1244,6 +1230,8 @@ bool video_shader_driver_compile_program(struct shader_program_info *program_inf
bool video_shader_driver_wrap_type(video_shader_ctx_wrap_t *wrap);
extern bool (*video_driver_cb_has_focus)(void);
extern shader_backend_t *current_shader;
extern void *shader_data;

View File

@ -65,6 +65,7 @@ ARCHIVE FILE
/*============================================================
COMPRESSION
============================================================ */
#include "../libretro-common/streams/stdin_stream.c"
#include "../libretro-common/streams/trans_stream.c"
#include "../libretro-common/streams/trans_stream_pipe.c"

View File

@ -310,7 +310,7 @@ static void x_input_poll_mouse(x11_input_t *x11)
x11->mouse_r = mask & Button3Mask;
/* Somewhat hacky, but seem to do the job. */
if (x11->grab_mouse && video_driver_is_focused())
if (x11->grab_mouse && video_driver_cb_has_focus())
{
int mid_w, mid_h;
struct video_viewport vp;
@ -345,7 +345,7 @@ static void x_input_poll(void *data)
{
x11_input_t *x11 = (x11_input_t*)data;
if (video_driver_is_focused())
if (video_driver_cb_has_focus())
XQueryKeymap(x11->display, x11->state);
else
memset(x11->state, 0, sizeof(x11->state));

View File

@ -131,8 +131,6 @@ typedef struct rarch_sinc_resampler
* are created in a single calloc().
* Ensure that we get as good cache locality as we can hope for. */
float *main_buffer;
bool neon_enabled;
} rarch_sinc_resampler_t;
#if defined(__ARM_NEON__) && !defined(SINC_COEFF_LERP)
@ -141,7 +139,8 @@ void process_sinc_neon_asm(float *out, const float *left,
const float *right, const float *coeff, unsigned taps);
#endif
static void resampler_sinc_process(void *re_, struct resampler_data *data)
#if defined(__ARM_NEON__)
static void resampler_sinc_process_neon(void *re_, struct resampler_data *data)
{
rarch_sinc_resampler_t *resamp = (rarch_sinc_resampler_t*)re_;
@ -184,7 +183,62 @@ static void resampler_sinc_process(void *re_, struct resampler_data *data)
const float *phase_table = resamp->phase_table + phase * taps;
#endif
process_sinc_neon_asm(output, buffer_l, buffer_r, phase_table, taps);
output += 2;
out_frames++;
resamp->time += ratio;
}
}
data->output_frames = out_frames;
}
#endif
#if defined(__AVX__) && ENABLE_AVX
static void resampler_sinc_process_avx(void *re_, struct resampler_data *data)
{
rarch_sinc_resampler_t *resamp = (rarch_sinc_resampler_t*)re_;
uint32_t ratio = PHASES / data->ratio;
const float *input = data->data_in;
float *output = data->data_out;
size_t frames = data->input_frames;
size_t out_frames = 0;
while (frames)
{
while (frames && resamp->time >= PHASES)
{
/* Push in reverse to make filter more obvious. */
if (!resamp->ptr)
resamp->ptr = resamp->taps;
resamp->ptr--;
resamp->buffer_l[resamp->ptr + resamp->taps] =
resamp->buffer_l[resamp->ptr] = *input++;
resamp->buffer_r[resamp->ptr + resamp->taps] =
resamp->buffer_r[resamp->ptr] = *input++;
resamp->time -= PHASES;
frames--;
}
while (resamp->time < PHASES)
{
unsigned i;
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
__m256 sum_l = _mm256_setzero_ps();
__m256 sum_r = _mm256_setzero_ps();
#if SINC_COEFF_LERP
@ -221,7 +275,61 @@ static void resampler_sinc_process(void *re_, struct resampler_data *data)
* There doesn't seem to be any _mm256_store_ss intrinsic. */
_mm_store_ss(output + 0, _mm256_extractf128_ps(res_l, 0));
_mm_store_ss(output + 1, _mm256_extractf128_ps(res_r, 0));
#elif defined(__SSE__)
output += 2;
out_frames++;
resamp->time += ratio;
}
}
data->output_frames = out_frames;
}
#endif
#if defined(__SSE__)
static void resampler_sinc_process_sse(void *re_, struct resampler_data *data)
{
rarch_sinc_resampler_t *resamp = (rarch_sinc_resampler_t*)re_;
uint32_t ratio = PHASES / data->ratio;
const float *input = data->data_in;
float *output = data->data_out;
size_t frames = data->input_frames;
size_t out_frames = 0;
while (frames)
{
while (frames && resamp->time >= PHASES)
{
/* Push in reverse to make filter more obvious. */
if (!resamp->ptr)
resamp->ptr = resamp->taps;
resamp->ptr--;
resamp->buffer_l[resamp->ptr + resamp->taps] =
resamp->buffer_l[resamp->ptr] = *input++;
resamp->buffer_r[resamp->ptr + resamp->taps] =
resamp->buffer_r[resamp->ptr] = *input++;
resamp->time -= PHASES;
frames--;
}
while (resamp->time < PHASES)
{
unsigned i;
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
__m128 sum;
__m128 sum_l = _mm_setzero_ps();
__m128 sum_r = _mm_setzero_ps();
@ -270,41 +378,6 @@ static void resampler_sinc_process(void *re_, struct resampler_data *data)
/* movehl { X, R, X, L } == { X, R, X, R } */
_mm_store_ss(output + 1, _mm_movehl_ps(sum, sum));
#elif defined(__ARM_NEON__) && !defined(SINC_COEFF_LERP)
if (resamp->neon_enabled)
{
process_sinc_neon_asm(output, buffer_l, buffer_r, phase_table, taps);
output += 2;
out_frames++;
resamp->time += ratio;
continue;
}
#else
{
/* Plain ol' C */
float sum_l = 0.0f;
float sum_r = 0.0f;
#if SINC_COEFF_LERP
float delta = (float)
(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD;
#endif
for (i = 0; i < taps; i++)
{
#if SINC_COEFF_LERP
float sinc_val = phase_table[i] + delta_table[i] * delta;
#else
float sinc_val = phase_table[i];
#endif
sum_l += buffer_l[i] * sinc_val;
sum_r += buffer_r[i] * sinc_val;
}
output[0] = sum_l;
output[1] = sum_r;
}
#endif
output += 2;
out_frames++;
@ -314,6 +387,79 @@ static void resampler_sinc_process(void *re_, struct resampler_data *data)
data->output_frames = out_frames;
}
#endif
static void resampler_sinc_process_c(void *re_, struct resampler_data *data)
{
rarch_sinc_resampler_t *resamp = (rarch_sinc_resampler_t*)re_;
uint32_t ratio = PHASES / data->ratio;
const float *input = data->data_in;
float *output = data->data_out;
size_t frames = data->input_frames;
size_t out_frames = 0;
while (frames)
{
while (frames && resamp->time >= PHASES)
{
/* Push in reverse to make filter more obvious. */
if (!resamp->ptr)
resamp->ptr = resamp->taps;
resamp->ptr--;
resamp->buffer_l[resamp->ptr + resamp->taps] =
resamp->buffer_l[resamp->ptr] = *input++;
resamp->buffer_r[resamp->ptr + resamp->taps] =
resamp->buffer_r[resamp->ptr] = *input++;
resamp->time -= PHASES;
frames--;
}
while (resamp->time < PHASES)
{
unsigned i;
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
float sum_l = 0.0f;
float sum_r = 0.0f;
#if SINC_COEFF_LERP
float delta = (float)
(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD;
#endif
for (i = 0; i < taps; i++)
{
#if SINC_COEFF_LERP
float sinc_val = phase_table[i] + delta_table[i] * delta;
#else
float sinc_val = phase_table[i];
#endif
sum_l += buffer_l[i] * sinc_val;
sum_r += buffer_r[i] * sinc_val;
}
output[0] = sum_l;
output[1] = sum_r;
}
output += 2;
out_frames++;
resamp->time += ratio;
}
data->output_frames = out_frames;
}
static void sinc_init_table(rarch_sinc_resampler_t *resamp, double cutoff,
float *phase_table, int phases, int taps, bool calculate_delta)
@ -428,9 +574,17 @@ static void *resampler_sinc_new(const struct resampler_config *config,
sinc_init_table(re, cutoff, re->phase_table,
1 << PHASE_BITS, re->taps, SINC_COEFF_LERP);
#if defined(__ARM_NEON__)
sinc_resampler.process = resampler_sinc_process_c;
#if defined(__AVX__) && ENABLE_AVX
if (mask & RESAMPLER_SIMD_AVX)
sinc_resampler.process = resampler_sinc_process_avx;
#elif defined(__SSE__)
if (mask & RESAMPLER_SIMD_SSE)
sinc_resampler.process = resampler_sinc_process_sse;
#elif defined(__ARM_NEON__) && !defined(SINC_COEFF_LERP)
if (mask & RESAMPLER_SIMD_NEON)
re->neon_enabled = true;
sinc_resampler.process = resampler_sinc_process_neon;
#endif
return re;
@ -442,7 +596,7 @@ error:
retro_resampler_t sinc_resampler = {
resampler_sinc_new,
resampler_sinc_process,
resampler_sinc_process_c,
resampler_sinc_free,
RESAMPLER_API_VERSION,
"sinc",

View File

@ -240,4 +240,6 @@ void network_deinit(void);
const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt);
bool udp_send_packet(const char *host, uint16_t port, const char *msg);
#endif

View File

@ -0,0 +1,40 @@
/* Copyright (C) 2010-2017 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (stdin_stream.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBRETRO_SDK_STDIN_STREAM_H__
#define LIBRETRO_SDK_STDIN_STREAM_H__
#include <stdint.h>
#include <stddef.h>
#include <retro_miscellaneous.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
size_t read_stdin(char *buf, size_t size);
RETRO_END_DECLS
#endif

View File

@ -20,6 +20,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
@ -391,3 +392,55 @@ const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt)
return NULL;
#endif
}
bool udp_send_packet(const char *host,
uint16_t port, const char *msg)
{
char port_buf[16] = {0};
struct addrinfo hints = {0};
struct addrinfo *res = NULL;
const struct addrinfo *tmp = NULL;
int fd = -1;
bool ret = true;
hints.ai_socktype = SOCK_DGRAM;
snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port);
if (getaddrinfo_retro(host, port_buf, &hints, &res) < 0)
return false;
/* Send to all possible targets.
* "localhost" might resolve to several different IPs. */
tmp = (const struct addrinfo*)res;
while (tmp)
{
ssize_t len, ret_len;
fd = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol);
if (fd < 0)
{
ret = false;
goto end;
}
len = strlen(msg);
ret_len = sendto(fd, msg, len, 0, tmp->ai_addr, tmp->ai_addrlen);
if (ret_len < len)
{
ret = false;
goto end;
}
socket_close(fd);
fd = -1;
tmp = tmp->ai_next;
}
end:
freeaddrinfo_retro(res);
if (fd >= 0)
socket_close(fd);
return ret;
}

View File

@ -0,0 +1,145 @@
/* Copyright (C) 2010-2017 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (stdin_stream.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifdef _WIN32
#ifndef _XBOX
#include <windows.h>
#endif
#include <direct.h>
#else
#include <unistd.h>
#endif
#if defined(_WIN32) && defined(_XBOX)
size_t read_stdin(char *buf, size_t size)
{
/* Not implemented. */
return 0;
}
#elif defined(_WIN32)
size_t read_stdin(char *buf, size_t size)
{
DWORD i;
DWORD has_read = 0;
DWORD avail = 0;
bool echo = false;
HANDLE hnd = GetStdHandle(STD_INPUT_HANDLE);
if (hnd == INVALID_HANDLE_VALUE)
return 0;
/* Check first if we're a pipe
* (not console). */
/* If not a pipe, check if we're running in a console. */
if (!PeekNamedPipe(hnd, NULL, 0, NULL, &avail, NULL))
{
INPUT_RECORD recs[256];
bool has_key = false;
DWORD mode = 0;
DWORD has_read = 0;
if (!GetConsoleMode(hnd, &mode))
return 0;
if ((mode & (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT))
&& !SetConsoleMode(hnd,
mode & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT)))
return 0;
/* Win32, Y U NO SANE NONBLOCK READ!? */
if (!PeekConsoleInput(hnd, recs,
sizeof(recs) / sizeof(recs[0]), &has_read))
return 0;
for (i = 0; i < has_read; i++)
{
/* Very crude, but should get the job done. */
if (recs[i].EventType == KEY_EVENT &&
recs[i].Event.KeyEvent.bKeyDown &&
(isgraph(recs[i].Event.KeyEvent.wVirtualKeyCode) ||
recs[i].Event.KeyEvent.wVirtualKeyCode == VK_RETURN))
{
has_key = true;
echo = true;
avail = size;
break;
}
}
if (!has_key)
{
FlushConsoleInputBuffer(hnd);
return 0;
}
}
if (!avail)
return 0;
if (avail > size)
avail = size;
if (!ReadFile(hnd, buf, avail, &has_read, NULL))
return 0;
for (i = 0; i < has_read; i++)
if (buf[i] == '\r')
buf[i] = '\n';
/* Console won't echo for us while in non-line mode,
* so do it manually ... */
if (echo)
{
HANDLE hnd_out = GetStdHandle(STD_OUTPUT_HANDLE);
if (hnd_out != INVALID_HANDLE_VALUE)
{
DWORD has_written;
WriteConsole(hnd_out, buf, has_read, &has_written, NULL);
}
}
return has_read;
}
#else
size_t read_stdin(char *buf, size_t size)
{
size_t has_read = 0;
while (size)
{
ssize_t ret = read(STDIN_FILENO, buf, size);
if (ret <= 0)
break;
buf += ret;
has_read += ret;
size -= ret;
}
return has_read;
}
#endif

View File

@ -162,8 +162,7 @@ enum
enum runloop_state
{
RUNLOOP_STATE_NONE = 0,
RUNLOOP_STATE_ITERATE,
RUNLOOP_STATE_ITERATE = 0,
RUNLOOP_STATE_SLEEP,
RUNLOOP_STATE_MENU_ITERATE,
RUNLOOP_STATE_END,
@ -280,6 +279,23 @@ static void retroarch_msg_queue_init(void)
#endif
}
static void retroarch_override_setting_free_state(void)
{
unsigned i;
for (i = 0; i < RARCH_OVERRIDE_SETTING_LAST; i++)
{
if (i == RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE)
{
unsigned j;
for (j = 0; j < MAX_USERS; j++)
retroarch_override_setting_unset((enum rarch_override_setting)(i), &j);
}
else
retroarch_override_setting_unset((enum rarch_override_setting)(i), NULL);
}
}
static void global_free(void)
{
global_t *global = NULL;
@ -308,7 +324,6 @@ static void global_free(void)
retroarch_override_setting_free_state();
}
static void retroarch_print_features(void)
{
puts("");
@ -2013,22 +2028,6 @@ void retroarch_override_setting_unset(enum rarch_override_setting enum_idx, void
}
}
void retroarch_override_setting_free_state(void)
{
unsigned i;
for (i = 0; i < RARCH_OVERRIDE_SETTING_LAST; i++)
{
if (i == RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE)
{
unsigned j;
for (j = 0; j < MAX_USERS; j++)
retroarch_override_setting_unset((enum rarch_override_setting)(i), &j);
}
else
retroarch_override_setting_unset((enum rarch_override_setting)(i), NULL);
}
}
int retroarch_get_capabilities(enum rarch_capabilities type,
char *s, size_t len)
{
@ -2269,8 +2268,10 @@ static enum runloop_state runloop_check_state(
video_driver_get_status(&frame_count, &is_alive, &is_focused);
#ifdef HAVE_OVERLAY
if (runloop_cmd_triggered(trigger_input, RARCH_OVERLAY_NEXT))
command_event(CMD_EVENT_OVERLAY_NEXT, NULL);
#endif
if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
{
@ -2736,7 +2737,6 @@ int runloop_iterate(unsigned *sleep_ms)
runloop_netplay_pause();
return 0;
case RUNLOOP_STATE_ITERATE:
case RUNLOOP_STATE_NONE:
break;
}

View File

@ -277,8 +277,6 @@ void retroarch_override_setting_set(enum rarch_override_setting enum_idx, void *
void retroarch_override_setting_unset(enum rarch_override_setting enum_idx, void *data);
void retroarch_override_setting_free_state(void);
bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx, void *data);
bool retroarch_validate_game_options(char *s, size_t len, bool mkdir);

View File

@ -30,9 +30,6 @@ static int task_file_transfer_iterate_transfer(nbio_handle_t *nbio)
{
size_t i;
if (!nbio)
return -1;
nbio->pos_increment = 5;
if (nbio->is_finished)
@ -49,9 +46,6 @@ static int task_file_transfer_iterate_transfer(nbio_handle_t *nbio)
static int task_file_transfer_iterate_parse(nbio_handle_t *nbio)
{
if (!nbio)
return -1;
if (nbio->cb)
{
int len = 0;
@ -88,12 +82,12 @@ void task_file_load_handler(retro_task_t *task)
}
break;
case NBIO_STATUS_TRANSFER_PARSE:
if (task_file_transfer_iterate_parse(nbio) == -1)
if (!nbio || task_file_transfer_iterate_parse(nbio) == -1)
task_set_cancelled(task, true);
nbio->status = NBIO_STATUS_TRANSFER_FINISHED;
break;
case NBIO_STATUS_TRANSFER:
if (task_file_transfer_iterate_transfer(nbio) == -1)
if (!nbio || task_file_transfer_iterate_transfer(nbio) == -1)
nbio->status = NBIO_STATUS_TRANSFER_PARSE;
break;
case NBIO_STATUS_TRANSFER_FINISHED:

View File

@ -27,8 +27,7 @@
enum http_status_enum
{
HTTP_STATUS_POLL = 0,
HTTP_STATUS_CONNECTION_TRANSFER,
HTTP_STATUS_CONNECTION_TRANSFER = 0,
HTTP_STATUS_CONNECTION_TRANSFER_PARSE,
HTTP_STATUS_TRANSFER,
HTTP_STATUS_TRANSFER_PARSE,
@ -155,7 +154,6 @@ static void task_http_transfer_handler(retro_task_t *task)
goto task_finished;
break;
case HTTP_STATUS_TRANSFER_PARSE:
case HTTP_STATUS_POLL:
goto task_finished;
default:
break;

View File

@ -31,8 +31,7 @@
enum image_status_enum
{
IMAGE_STATUS_NONE = 0,
IMAGE_STATUS_TRANSFER,
IMAGE_STATUS_TRANSFER = 0,
IMAGE_STATUS_TRANSFER_PARSE,
IMAGE_STATUS_PROCESS_TRANSFER,
IMAGE_STATUS_PROCESS_TRANSFER_PARSE
@ -258,8 +257,6 @@ bool task_image_load_handler(retro_task_t *task)
}
if (!image->is_finished)
break;
case IMAGE_STATUS_NONE:
break;
}
}