From e3077ac0783bf5e7317f76cb019f1689971ea64c Mon Sep 17 00:00:00 2001 From: Mahyar Koshkouei Date: Sun, 29 Apr 2018 15:29:19 +0100 Subject: [PATCH] libretro-common: update Signed-off-by: Mahyar Koshkouei --- libretro-common/audio/audio_mix.c | 4 +- libretro-common/audio/audio_mixer.c | 405 +++++++++++++++++- .../audio/conversion/float_to_s16.c | 2 +- .../audio/conversion/float_to_s16_neon.S | 2 +- .../audio/conversion/float_to_s16_neon.c | 2 +- .../audio/conversion/s16_to_float.c | 2 +- .../audio/conversion/s16_to_float_neon.S | 2 +- .../audio/conversion/s16_to_float_neon.c | 2 +- libretro-common/audio/dsp_filter.c | 2 +- libretro-common/audio/dsp_filters/Tremolo.dsp | 7 + libretro-common/audio/dsp_filters/Vibrato.dsp | 7 + libretro-common/audio/dsp_filters/fft/fft.c | 2 +- libretro-common/audio/dsp_filters/fft/fft.h | 2 +- libretro-common/audio/dsp_filters/reverb.c | 82 ++-- libretro-common/audio/dsp_filters/tremolo.c | 133 ++++++ libretro-common/audio/dsp_filters/vibrato.c | 169 ++++++++ .../audio/resampler/audio_resampler.c | 2 +- .../resampler/drivers/nearest_resampler.c | 2 +- .../audio/resampler/drivers/null_resampler.c | 2 +- .../audio/resampler/drivers/sinc_resampler.c | 2 +- .../resampler/drivers/sinc_resampler_neon.S | 2 +- libretro-common/compat/compat_fnmatch.c | 2 +- libretro-common/compat/compat_getopt.c | 2 +- libretro-common/compat/compat_posix_string.c | 2 +- libretro-common/compat/compat_snprintf.c | 7 +- libretro-common/compat/compat_strcasestr.c | 2 +- libretro-common/compat/compat_strl.c | 2 +- libretro-common/compat/fopen_utf8.c | 25 +- libretro-common/dynamic/dylib.c | 2 +- libretro-common/encodings/encoding_crc32.c | 2 +- libretro-common/encodings/encoding_utf.c | 2 +- libretro-common/features/features_cpu.c | 10 +- libretro-common/file/archive_file.c | 6 +- libretro-common/file/archive_file_7z.c | 2 +- libretro-common/file/archive_file_zlib.c | 22 +- libretro-common/file/config_file.c | 4 +- libretro-common/file/config_file_userdata.c | 2 +- libretro-common/file/file_path.c | 12 +- libretro-common/file/nbio/nbio_intf.c | 2 +- libretro-common/file/nbio/nbio_linux.c | 2 +- libretro-common/file/nbio/nbio_stdio.c | 2 +- libretro-common/file/nbio/nbio_unixmmap.c | 2 +- libretro-common/file/nbio/nbio_windowsmmap.c | 2 +- libretro-common/file/retro_dirent.c | 10 +- libretro-common/formats/bmp/rbmp.c | 2 +- libretro-common/formats/bmp/rbmp_encode.c | 2 +- libretro-common/formats/image_texture.c | 2 +- libretro-common/formats/image_transfer.c | 2 +- libretro-common/formats/jpeg/rjpeg.c | 2 +- libretro-common/formats/json/jsonsax.c | 2 +- .../{bitstream.c => libchdr_bitstream.c} | 0 .../libchdr/{cdrom.c => libchdr_cdrom.c} | 0 .../formats/libchdr/{chd.c => libchdr_chd.c} | 202 ++++++--- .../libchdr/{flac.c => libchdr_flac.c} | 3 +- .../libchdr/{huffman.c => libchdr_huffman.c} | 3 + libretro-common/formats/png/rpng.c | 2 +- libretro-common/formats/png/rpng_encode.c | 2 +- libretro-common/formats/png/rpng_internal.h | 2 +- libretro-common/formats/tga/rtga.c | 2 +- libretro-common/formats/wav/rwav.c | 2 +- libretro-common/formats/xml/rxml.c | 2 +- libretro-common/formats/xml/test/rxml_test.c | 2 +- libretro-common/gfx/gl_capabilities.c | 2 +- libretro-common/gfx/scaler/pixconv.c | 2 +- libretro-common/gfx/scaler/scaler.c | 6 +- libretro-common/gfx/scaler/scaler_filter.c | 2 +- libretro-common/gfx/scaler/scaler_int.c | 2 +- libretro-common/glsm/glsm.c | 4 +- libretro-common/glsym/glsym_gl.c | 2 +- libretro-common/glsym/rglgen.c | 2 +- libretro-common/hash/rhash.c | 2 +- libretro-common/include/audio/audio_mix.h | 2 +- libretro-common/include/audio/audio_mixer.h | 8 +- .../include/audio/audio_resampler.h | 2 +- .../include/audio/conversion/float_to_s16.h | 2 +- .../include/audio/conversion/s16_to_float.h | 2 +- libretro-common/include/audio/dsp_filter.h | 2 +- libretro-common/include/boolean.h | 2 +- libretro-common/include/clamping.h | 2 +- libretro-common/include/compat/apple_compat.h | 2 +- libretro-common/include/compat/fnmatch.h | 2 +- libretro-common/include/compat/fopen_utf8.h | 30 +- libretro-common/include/compat/getopt.h | 2 +- libretro-common/include/compat/intrinsics.h | 2 +- libretro-common/include/compat/msvc.h | 2 +- libretro-common/include/compat/posix_string.h | 2 +- libretro-common/include/compat/strcasestr.h | 2 +- libretro-common/include/compat/strl.h | 2 +- libretro-common/include/dynamic/dylib.h | 2 +- libretro-common/include/encodings/crc32.h | 2 +- libretro-common/include/encodings/utf.h | 2 +- libretro-common/include/encodings/win32.h | 2 +- libretro-common/include/fastcpy.h | 2 +- .../include/features/features_cpu.h | 2 +- libretro-common/include/file/archive_file.h | 4 +- libretro-common/include/file/config_file.h | 2 +- .../include/file/config_file_userdata.h | 2 +- libretro-common/include/file/file_path.h | 8 +- libretro-common/include/file/nbio.h | 2 +- libretro-common/include/filters.h | 2 +- libretro-common/include/formats/image.h | 2 +- libretro-common/include/formats/jsonsax.h | 2 +- libretro-common/include/formats/rbmp.h | 2 +- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rpng.h | 2 +- libretro-common/include/formats/rtga.h | 2 +- libretro-common/include/formats/rwav.h | 2 +- libretro-common/include/formats/rxml.h | 2 +- libretro-common/include/gfx/gl_capabilities.h | 2 +- libretro-common/include/gfx/math/matrix_3x3.h | 2 +- libretro-common/include/gfx/math/matrix_4x4.h | 2 +- libretro-common/include/gfx/math/vector_2.h | 2 +- libretro-common/include/gfx/math/vector_3.h | 2 +- libretro-common/include/gfx/math/vector_4.h | 2 +- libretro-common/include/gfx/scaler/filter.h | 2 +- libretro-common/include/gfx/scaler/pixconv.h | 2 +- libretro-common/include/gfx/scaler/scaler.h | 2 +- .../include/gfx/scaler/scaler_int.h | 2 +- libretro-common/include/gfx/video_frame.h | 10 +- libretro-common/include/glsm/glsm.h | 2 +- libretro-common/include/glsm/glsmsym.h | 2 +- libretro-common/include/glsym/glsym.h | 2 +- libretro-common/include/glsym/glsym_gl.h | 2 +- libretro-common/include/glsym/rglgen.h | 2 +- .../include/glsym/rglgen_headers.h | 2 +- libretro-common/include/libchdr/chd.h | 8 +- libretro-common/include/libchdr/coretypes.h | 10 +- libretro-common/include/libco.h | 2 +- libretro-common/include/libretro.h | 66 ++- libretro-common/include/libretro_d3d.h | 60 +++ libretro-common/include/libretro_dspfilter.h | 2 +- libretro-common/include/libretro_vulkan.h | 2 +- libretro-common/include/lists/dir_list.h | 2 +- libretro-common/include/lists/file_list.h | 2 +- libretro-common/include/lists/string_list.h | 2 +- libretro-common/include/math/complex.h | 2 +- libretro-common/include/math/float_minmax.h | 2 +- libretro-common/include/math/fxp.h | 2 +- libretro-common/include/memalign.h | 2 +- libretro-common/include/memmap.h | 2 +- libretro-common/include/net/net_compat.h | 2 +- libretro-common/include/net/net_http.h | 8 +- libretro-common/include/net/net_http_parse.h | 2 +- libretro-common/include/net/net_ifinfo.h | 2 +- libretro-common/include/net/net_natt.h | 2 +- libretro-common/include/net/net_socket.h | 2 +- libretro-common/include/net/net_socket_ssl.h | 2 +- libretro-common/include/queues/fifo_queue.h | 2 +- .../include/queues/message_queue.h | 2 +- libretro-common/include/queues/task_queue.h | 2 +- libretro-common/include/retro_assert.h | 2 +- libretro-common/include/retro_common.h | 2 +- libretro-common/include/retro_common_api.h | 2 +- libretro-common/include/retro_dirent.h | 12 +- libretro-common/include/retro_endianness.h | 2 +- libretro-common/include/retro_environment.h | 2 +- libretro-common/include/retro_inline.h | 2 +- libretro-common/include/retro_math.h | 2 +- libretro-common/include/retro_miscellaneous.h | 2 +- libretro-common/include/retro_stat.h | 65 --- libretro-common/include/retro_timers.h | 2 +- libretro-common/include/rhash.h | 2 +- libretro-common/include/rthreads/rthreads.h | 2 +- libretro-common/include/streams/chd_stream.h | 8 +- libretro-common/include/streams/file_stream.h | 14 +- .../include/streams/file_stream_transforms.h | 17 +- .../include/streams/interface_stream.h | 22 +- .../include/streams/memory_stream.h | 14 +- .../include/streams/stdin_stream.h | 2 +- .../include/streams/trans_stream.h | 2 +- libretro-common/include/string/stdstring.h | 23 +- .../include/vfs/vfs_implementation.h | 2 +- libretro-common/lists/dir_list.c | 9 +- libretro-common/lists/file_list.c | 2 +- libretro-common/lists/string_list.c | 2 +- libretro-common/lists/vector_list.c | 2 +- libretro-common/memmap/memalign.c | 2 +- libretro-common/memmap/memmap.c | 2 +- libretro-common/net/net_compat.c | 4 +- libretro-common/net/net_http.c | 42 +- libretro-common/net/net_http_parse.c | 2 +- libretro-common/net/net_ifinfo.c | 2 +- libretro-common/net/net_natt.c | 2 +- libretro-common/net/net_socket.c | 2 +- libretro-common/net/net_socket_ssl.c | 2 +- libretro-common/queues/fifo_queue.c | 2 +- libretro-common/queues/message_queue.c | 2 +- libretro-common/queues/task_queue.c | 2 +- libretro-common/rthreads/ctr_pthread.h | 2 +- libretro-common/rthreads/gx_pthread.h | 2 +- libretro-common/rthreads/rthreads.c | 18 +- libretro-common/rthreads/xenon_sdl_threads.c | 2 +- libretro-common/samples/net/Makefile | 20 + libretro-common/samples/net/net_http_test.c | 2 +- libretro-common/streams/chd_stream.c | 16 +- libretro-common/streams/file_stream.c | 26 +- .../streams/file_stream_transforms.c | 10 +- libretro-common/streams/interface_stream.c | 43 +- libretro-common/streams/memory_stream.c | 38 +- libretro-common/streams/stdin_stream.c | 2 +- libretro-common/streams/trans_stream.c | 2 +- libretro-common/streams/trans_stream_pipe.c | 2 +- libretro-common/streams/trans_stream_zlib.c | 2 +- libretro-common/string/stdstring.c | 4 +- libretro-common/vfs/vfs_implementation.c | 6 +- 205 files changed, 1512 insertions(+), 538 deletions(-) create mode 100644 libretro-common/audio/dsp_filters/Tremolo.dsp create mode 100644 libretro-common/audio/dsp_filters/Vibrato.dsp create mode 100644 libretro-common/audio/dsp_filters/tremolo.c create mode 100644 libretro-common/audio/dsp_filters/vibrato.c rename libretro-common/formats/libchdr/{bitstream.c => libchdr_bitstream.c} (100%) rename libretro-common/formats/libchdr/{cdrom.c => libchdr_cdrom.c} (100%) rename libretro-common/formats/libchdr/{chd.c => libchdr_chd.c} (94%) rename libretro-common/formats/libchdr/{flac.c => libchdr_flac.c} (99%) rename libretro-common/formats/libchdr/{huffman.c => libchdr_huffman.c} (99%) create mode 100644 libretro-common/include/libretro_d3d.h delete mode 100644 libretro-common/include/retro_stat.h diff --git a/libretro-common/audio/audio_mix.c b/libretro-common/audio/audio_mix.c index 776a9f2..15879ab 100644 --- a/libretro-common/audio/audio_mix.c +++ b/libretro-common/audio/audio_mix.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_mix.c). @@ -111,7 +111,7 @@ void audio_mix_free_chunk(audio_chunk_t *chunk) audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate) { int sample_size; - ssize_t len = 0; + int64_t len = 0; void *buf = NULL; audio_chunk_t *chunk = (audio_chunk_t*)calloc(1, sizeof(*chunk)); diff --git a/libretro-common/audio/audio_mixer.c b/libretro-common/audio/audio_mixer.c index c781297..d7a99a4 100644 --- a/libretro-common/audio/audio_mixer.c +++ b/libretro-common/audio/audio_mixer.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_mixer.c). @@ -44,7 +44,18 @@ #define STB_VORBIS_NO_STDIO #define STB_VORBIS_NO_CRT -#include +#include +#endif + +#ifdef HAVE_DR_FLAC +#define DR_FLAC_IMPLEMENTATION +#include +#endif + + +#ifdef HAVE_DR_MP3 +#define DR_MP3_IMPLEMENTATION +#include #endif #ifdef HAVE_IBXM @@ -52,7 +63,7 @@ #endif #define AUDIO_MIXER_MAX_VOICES 8 -#define AUDIO_MIXER_TEMP_OGG_BUFFER 8192 +#define AUDIO_MIXER_TEMP_BUFFER 8192 struct audio_mixer_sound { @@ -75,6 +86,24 @@ struct audio_mixer_sound const void* data; } ogg; #endif + +#ifdef HAVE_DR_FLAC + struct + { + /* flac */ + unsigned size; + const void* data; + } flac; +#endif + +#ifdef HAVE_DR_MP3 + struct + { + /* mp */ + unsigned size; + const void* data; + } mp3; +#endif #ifdef HAVE_IBXM struct @@ -116,6 +145,34 @@ struct audio_mixer_voice } ogg; #endif +#ifdef HAVE_DR_FLAC + struct + { + unsigned position; + unsigned samples; + unsigned buf_samples; + float* buffer; + float ratio; + drflac *stream; + void *resampler_data; + const retro_resampler_t *resampler; + } flac; +#endif + +#ifdef HAVE_DR_MP3 + struct + { + unsigned position; + unsigned samples; + unsigned buf_samples; + float* buffer; + float ratio; + drmp3 stream; + void *resampler_data; + const retro_resampler_t *resampler; + } mp3; +#endif + #ifdef HAVE_IBXM struct { @@ -343,6 +400,43 @@ audio_mixer_sound_t* audio_mixer_load_ogg(void *buffer, int32_t size) #endif } + +audio_mixer_sound_t* audio_mixer_load_flac(void *buffer, int32_t size) +{ +#ifdef HAVE_DR_FLAC + audio_mixer_sound_t* sound = (audio_mixer_sound_t*)calloc(1, sizeof(*sound)); + + if (!sound) + return NULL; + + sound->type = AUDIO_MIXER_TYPE_FLAC; + sound->types.flac.size = size; + sound->types.flac.data = buffer; + + return sound; +#else + return NULL; +#endif +} + +audio_mixer_sound_t* audio_mixer_load_mp3(void *buffer, int32_t size) +{ +#ifdef HAVE_DR_MP3 + audio_mixer_sound_t* sound = (audio_mixer_sound_t*)calloc(1, sizeof(*sound)); + + if (!sound) + return NULL; + + sound->type = AUDIO_MIXER_TYPE_MP3; + sound->types.mp3.size = size; + sound->types.mp3.data = buffer; + + return sound; +#else + return NULL; +#endif +} + audio_mixer_sound_t* audio_mixer_load_mod(void *buffer, int32_t size) { #ifdef HAVE_IBXM @@ -386,6 +480,20 @@ void audio_mixer_destroy(audio_mixer_sound_t* sound) handle = (void*)sound->types.mod.data; if (handle) free(handle); +#endif + break; + case AUDIO_MIXER_TYPE_FLAC: +#ifdef HAVE_DR_FLAC + handle = (void*)sound->types.flac.data; + if (handle) + free(handle); +#endif + break; + case AUDIO_MIXER_TYPE_MP3: +#ifdef HAVE_DR_MP3 + handle = (void*)sound->types.mp3.data; + if (handle) + free(handle); #endif break; case AUDIO_MIXER_TYPE_NONE: @@ -412,7 +520,7 @@ static bool audio_mixer_play_ogg( { stb_vorbis_info info; int res = 0; - float ratio = 0.0f; + float ratio = 1.0f; unsigned samples = 0; void *ogg_buffer = NULL; void *resampler_data = NULL; @@ -436,7 +544,7 @@ static bool audio_mixer_play_ogg( goto error; } - samples = (unsigned)(AUDIO_MIXER_TEMP_OGG_BUFFER * ratio); + samples = (unsigned)(AUDIO_MIXER_TEMP_BUFFER * ratio); ogg_buffer = (float*)memalign_alloc(16, ((samples + 15) & ~15) * sizeof(float)); @@ -531,6 +639,113 @@ error: } #endif + +#ifdef HAVE_DR_FLAC +static bool audio_mixer_play_flac( + audio_mixer_sound_t* sound, + audio_mixer_voice_t* voice, + bool repeat, float volume, + audio_mixer_stop_cb_t stop_cb) +{ + float ratio = 1.0f; + unsigned samples = 0; + void *flac_buffer = NULL; + void *resampler_data = NULL; + const retro_resampler_t* resamp = NULL; + drflac *dr_flac = drflac_open_memory((const unsigned char*)sound->types.flac.data,sound->types.flac.size); + + + if (!dr_flac) + return false; + if (dr_flac->sampleRate != s_rate) + { + ratio = (double)s_rate / (double)(dr_flac->sampleRate); + + if (!retro_resampler_realloc(&resampler_data, + &resamp, NULL, RESAMPLER_QUALITY_DONTCARE, + ratio)) + goto error; + } + + samples = (unsigned)(AUDIO_MIXER_TEMP_BUFFER * ratio); + flac_buffer = (float*)memalign_alloc(16, + ((samples + 15) & ~15) * sizeof(float)); + + if (!flac_buffer) + { + resamp->free(resampler_data); + goto error; + } + + voice->types.flac.resampler = resamp; + voice->types.flac.resampler_data = resampler_data; + voice->types.flac.buffer = (float*)flac_buffer; + voice->types.flac.buf_samples = samples; + voice->types.flac.ratio = ratio; + voice->types.flac.stream = dr_flac; + voice->types.flac.position = 0; + voice->types.flac.samples = 0; + + return true; + +error: + drflac_close(dr_flac); + return false; +} +#endif + +#ifdef HAVE_DR_MP3 +static bool audio_mixer_play_mp3( + audio_mixer_sound_t* sound, + audio_mixer_voice_t* voice, + bool repeat, float volume, + audio_mixer_stop_cb_t stop_cb) +{ + float ratio = 1.0f; + unsigned samples = 0; + void *mp3_buffer = NULL; + void *resampler_data = NULL; + const retro_resampler_t* resamp = NULL; + bool res =drmp3_init_memory(&voice->types.mp3.stream,(const unsigned char*)sound->types.mp3.data,sound->types.mp3.size,NULL); + if (!res) + return false; + if (voice->types.mp3.stream.sampleRate != s_rate) + { + ratio = (double)s_rate / (double)(voice->types.mp3.stream.sampleRate); + + if (!retro_resampler_realloc(&resampler_data, + &resamp, NULL, RESAMPLER_QUALITY_DONTCARE, + ratio)) + goto error; + } + + samples = (unsigned)(AUDIO_MIXER_TEMP_BUFFER * ratio); + mp3_buffer = (float*)memalign_alloc(16, + ((samples + 15) & ~15) * sizeof(float)); + + if (!mp3_buffer) + { + resamp->free(resampler_data); + goto error; + } + + voice->types.mp3.resampler = resamp; + voice->types.mp3.resampler_data = resampler_data; + voice->types.mp3.buffer = (float*)mp3_buffer; + voice->types.mp3.buf_samples = samples; + voice->types.mp3.ratio = ratio; + voice->types.mp3.position = 0; + voice->types.mp3.samples = 0; + + return true; + +error: + drmp3_uninit(&voice->types.mp3.stream); + return false; +} +#endif + + audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, float volume, audio_mixer_stop_cb_t stop_cb) { @@ -563,6 +778,16 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, case AUDIO_MIXER_TYPE_MOD: #ifdef HAVE_IBXM res = audio_mixer_play_mod(sound, voice, repeat, volume, stop_cb); +#endif + break; + case AUDIO_MIXER_TYPE_FLAC: +#ifdef HAVE_DR_FLAC + res = audio_mixer_play_flac(sound, voice, repeat, volume, stop_cb); +#endif + break; + case AUDIO_MIXER_TYPE_MP3: +#ifdef HAVE_DR_MP3 + res = audio_mixer_play_mp3(sound, voice, repeat, volume, stop_cb); #endif break; case AUDIO_MIXER_TYPE_NONE: @@ -665,9 +890,9 @@ static void audio_mixer_mix_ogg(float* buffer, size_t num_frames, float volume) { int i; - struct resampler_data info; - float temp_buffer[AUDIO_MIXER_TEMP_OGG_BUFFER]; - unsigned buf_free = num_frames * 2; + struct resampler_data info = { 0 }; + float temp_buffer[AUDIO_MIXER_TEMP_BUFFER] = { 0 }; + unsigned buf_free = (unsigned)(num_frames * 2); unsigned temp_samples = 0; float* pcm = NULL; @@ -676,7 +901,7 @@ static void audio_mixer_mix_ogg(float* buffer, size_t num_frames, again: temp_samples = stb_vorbis_get_samples_float_interleaved( voice->types.ogg.stream, 2, temp_buffer, - AUDIO_MIXER_TEMP_OGG_BUFFER) * 2; + AUDIO_MIXER_TEMP_BUFFER) * 2; if (temp_samples == 0) { @@ -704,7 +929,10 @@ again: info.output_frames = 0; info.ratio = voice->types.ogg.ratio; - voice->types.ogg.resampler->process(voice->types.ogg.resampler_data, &info); + if (voice->types.ogg.resampler) + voice->types.ogg.resampler->process(voice->types.ogg.resampler_data, &info); + else + memcpy(voice->types.ogg.buffer, temp_buffer, temp_samples * sizeof(float)); voice->types.ogg.position = 0; voice->types.ogg.samples = voice->types.ogg.buf_samples; } @@ -740,7 +968,7 @@ static void audio_mixer_mix_mod(float* buffer, size_t num_frames, float samplef = 0.0f; int samplei = 0; unsigned temp_samples = 0; - unsigned buf_free = num_frames * 2; + unsigned buf_free = (unsigned)(num_frames * 2); int* pcm = NULL; if (voice->types.mod.position == voice->types.mod.samples) @@ -806,6 +1034,151 @@ again: } #endif +#ifdef HAVE_DR_FLAC +static void audio_mixer_mix_flac(float* buffer, size_t num_frames, + audio_mixer_voice_t* voice, + float volume) +{ + int i; + struct resampler_data info = { 0 }; + float temp_buffer[AUDIO_MIXER_TEMP_BUFFER] = { 0 }; + unsigned buf_free = (unsigned)(num_frames * 2); + unsigned temp_samples = 0; + float* pcm = NULL; + + if (voice->types.flac.position == voice->types.flac.samples) + { +again: + temp_samples = drflac_read_f32( voice->types.flac.stream, AUDIO_MIXER_TEMP_BUFFER, temp_buffer); + if (temp_samples == 0) + { + if (voice->repeat) + { + if (voice->stop_cb) + voice->stop_cb(voice->sound, AUDIO_MIXER_SOUND_REPEATED); + + drflac_seek_to_sample(voice->types.flac.stream,0); + goto again; + } + else + { + if (voice->stop_cb) + voice->stop_cb(voice->sound, AUDIO_MIXER_SOUND_FINISHED); + + voice->type = AUDIO_MIXER_TYPE_NONE; + return; + } + } + + info.data_in = temp_buffer; + info.data_out = voice->types.flac.buffer; + info.input_frames = temp_samples / 2; + info.output_frames = 0; + info.ratio = voice->types.flac.ratio; + + if (voice->types.flac.resampler) + voice->types.flac.resampler->process(voice->types.flac.resampler_data, &info); + else + memcpy(voice->types.flac.buffer, temp_buffer, temp_samples * sizeof(float)); + voice->types.flac.position = 0; + voice->types.flac.samples = voice->types.flac.buf_samples; + } + + pcm = voice->types.flac.buffer + voice->types.flac.position; + + if (voice->types.flac.samples < buf_free) + { + for (i = voice->types.flac.samples; i != 0; i--) + *buffer++ += *pcm++ * volume; + + buf_free -= voice->types.flac.samples; + goto again; + } + else + { + int i; + for (i = buf_free; i != 0; --i ) + *buffer++ += *pcm++ * volume; + + voice->types.flac.position += buf_free; + voice->types.flac.samples -= buf_free; + } +} +#endif + +#ifdef HAVE_DR_MP3 +static void audio_mixer_mix_mp3(float* buffer, size_t num_frames, + audio_mixer_voice_t* voice, + float volume) +{ + int i; + struct resampler_data info = { 0 }; + float temp_buffer[AUDIO_MIXER_TEMP_BUFFER] = { 0 }; + unsigned buf_free = (unsigned)(num_frames * 2); + unsigned temp_samples = 0; + float* pcm = NULL; + + if (voice->types.mp3.position == voice->types.mp3.samples) + { +again: + temp_samples = drmp3_read_f32(&voice->types.mp3.stream, AUDIO_MIXER_TEMP_BUFFER/2, temp_buffer) * 2; + + if (temp_samples == 0) + { + if (voice->repeat) + { + if (voice->stop_cb) + voice->stop_cb(voice->sound, AUDIO_MIXER_SOUND_REPEATED); + + drmp3_seek_to_frame(&voice->types.mp3.stream,0); + goto again; + } + else + { + if (voice->stop_cb) + voice->stop_cb(voice->sound, AUDIO_MIXER_SOUND_FINISHED); + + voice->type = AUDIO_MIXER_TYPE_NONE; + return; + } + } + + info.data_in = temp_buffer; + info.data_out = voice->types.mp3.buffer; + info.input_frames = temp_samples / 2; + info.output_frames = 0; + info.ratio = voice->types.mp3.ratio; + + if (voice->types.mp3.resampler) + voice->types.mp3.resampler->process(voice->types.mp3.resampler_data, &info); + else + memcpy(voice->types.mp3.buffer, temp_buffer, temp_samples * sizeof(float)); + voice->types.mp3.position = 0; + voice->types.mp3.samples = voice->types.mp3.buf_samples; + } + + pcm = voice->types.mp3.buffer + voice->types.mp3.position; + + if (voice->types.mp3.samples < buf_free) + { + for (i = voice->types.mp3.samples; i != 0; i--) + *buffer++ += *pcm++ * volume; + + buf_free -= voice->types.mp3.samples; + goto again; + } + else + { + int i; + for (i = buf_free; i != 0; --i ) + *buffer++ += *pcm++ * volume; + + voice->types.mp3.position += buf_free; + voice->types.mp3.samples -= buf_free; + } +} +#endif + void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bool override) { unsigned i; @@ -834,6 +1207,16 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo case AUDIO_MIXER_TYPE_MOD: #ifdef HAVE_IBXM audio_mixer_mix_mod(buffer, num_frames, voice, volume); +#endif + break; + case AUDIO_MIXER_TYPE_FLAC: +#ifdef HAVE_DR_FLAC + audio_mixer_mix_flac(buffer, num_frames, voice, volume); +#endif + break; + case AUDIO_MIXER_TYPE_MP3: +#ifdef HAVE_DR_MP3 + audio_mixer_mix_mp3(buffer, num_frames, voice, volume); #endif break; case AUDIO_MIXER_TYPE_NONE: diff --git a/libretro-common/audio/conversion/float_to_s16.c b/libretro-common/audio/conversion/float_to_s16.c index bb97945..baf8b4f 100644 --- a/libretro-common/audio/conversion/float_to_s16.c +++ b/libretro-common/audio/conversion/float_to_s16.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (float_to_s16.c). diff --git a/libretro-common/audio/conversion/float_to_s16_neon.S b/libretro-common/audio/conversion/float_to_s16_neon.S index aa9e565..352c4d3 100644 --- a/libretro-common/audio/conversion/float_to_s16_neon.S +++ b/libretro-common/audio/conversion/float_to_s16_neon.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (float_to_s16_neon.S). diff --git a/libretro-common/audio/conversion/float_to_s16_neon.c b/libretro-common/audio/conversion/float_to_s16_neon.c index 342f497..a5d10e0 100644 --- a/libretro-common/audio/conversion/float_to_s16_neon.c +++ b/libretro-common/audio/conversion/float_to_s16_neon.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (float_to_s16_neon.S). diff --git a/libretro-common/audio/conversion/s16_to_float.c b/libretro-common/audio/conversion/s16_to_float.c index 814ddd8..c8042ea 100644 --- a/libretro-common/audio/conversion/s16_to_float.c +++ b/libretro-common/audio/conversion/s16_to_float.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (s16_to_float.c). diff --git a/libretro-common/audio/conversion/s16_to_float_neon.S b/libretro-common/audio/conversion/s16_to_float_neon.S index b744924..3cc47e9 100644 --- a/libretro-common/audio/conversion/s16_to_float_neon.S +++ b/libretro-common/audio/conversion/s16_to_float_neon.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (s16_to_float_neon.S). diff --git a/libretro-common/audio/conversion/s16_to_float_neon.c b/libretro-common/audio/conversion/s16_to_float_neon.c index 464e40f..9912c0d 100644 --- a/libretro-common/audio/conversion/s16_to_float_neon.c +++ b/libretro-common/audio/conversion/s16_to_float_neon.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (s16_to_float_neon.S). diff --git a/libretro-common/audio/dsp_filter.c b/libretro-common/audio/dsp_filter.c index 7f428ee..c7bb2dc 100644 --- a/libretro-common/audio/dsp_filter.c +++ b/libretro-common/audio/dsp_filter.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (dsp_filter.c). diff --git a/libretro-common/audio/dsp_filters/Tremolo.dsp b/libretro-common/audio/dsp_filters/Tremolo.dsp new file mode 100644 index 0000000..5052333 --- /dev/null +++ b/libretro-common/audio/dsp_filters/Tremolo.dsp @@ -0,0 +1,7 @@ +filters = 1 +filter0 = tremolo + +# Defaults. +#tremolo_frequency = 4.0 +#tremolo_depth = 0.9 + diff --git a/libretro-common/audio/dsp_filters/Vibrato.dsp b/libretro-common/audio/dsp_filters/Vibrato.dsp new file mode 100644 index 0000000..b1ea8e1 --- /dev/null +++ b/libretro-common/audio/dsp_filters/Vibrato.dsp @@ -0,0 +1,7 @@ +filters = 1 +filter0 = vibrato + +# Defaults. +#vibrato_frequency = 5.0 +#vibrato_depth = 0.5 + diff --git a/libretro-common/audio/dsp_filters/fft/fft.c b/libretro-common/audio/dsp_filters/fft/fft.c index e8c80f4..7bafefa 100644 --- a/libretro-common/audio/dsp_filters/fft/fft.c +++ b/libretro-common/audio/dsp_filters/fft/fft.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fft.c). diff --git a/libretro-common/audio/dsp_filters/fft/fft.h b/libretro-common/audio/dsp_filters/fft/fft.h index 8a16c6c..e5bcdf7 100644 --- a/libretro-common/audio/dsp_filters/fft/fft.h +++ b/libretro-common/audio/dsp_filters/fft/fft.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fft.h). diff --git a/libretro-common/audio/dsp_filters/reverb.c b/libretro-common/audio/dsp_filters/reverb.c index e81d859..e9bc817 100644 --- a/libretro-common/audio/dsp_filters/reverb.c +++ b/libretro-common/audio/dsp_filters/reverb.c @@ -91,37 +91,13 @@ static const float initialwidth = 1; static const float initialmode = 0; static const float freezemode = 0.5f; -#define combtuningL1 1116 -#define combtuningL2 1188 -#define combtuningL3 1277 -#define combtuningL4 1356 -#define combtuningL5 1422 -#define combtuningL6 1491 -#define combtuningL7 1557 -#define combtuningL8 1617 -#define allpasstuningL1 556 -#define allpasstuningL2 441 -#define allpasstuningL3 341 -#define allpasstuningL4 225 - struct revmodel { struct comb combL[numcombs]; struct allpass allpassL[numallpasses]; - float bufcombL1[combtuningL1]; - float bufcombL2[combtuningL2]; - float bufcombL3[combtuningL3]; - float bufcombL4[combtuningL4]; - float bufcombL5[combtuningL5]; - float bufcombL6[combtuningL6]; - float bufcombL7[combtuningL7]; - float bufcombL8[combtuningL8]; - - float bufallpassL1[allpasstuningL1]; - float bufallpassL2[allpasstuningL2]; - float bufallpassL3[allpasstuningL3]; - float bufallpassL4[allpasstuningL4]; + float **bufcomb; + float **bufallpass; float gain; float roomsize, roomsize1; @@ -210,21 +186,29 @@ static void revmodel_setmode(struct revmodel *rev, float value) revmodel_update(rev); } -static void revmodel_init(struct revmodel *rev) +static void revmodel_init(struct revmodel *rev,int srate) { - rev->combL[0].buffer = rev->bufcombL1; rev->combL[0].bufsize = combtuningL1; - rev->combL[1].buffer = rev->bufcombL2; rev->combL[1].bufsize = combtuningL2; - rev->combL[2].buffer = rev->bufcombL3; rev->combL[2].bufsize = combtuningL3; - rev->combL[3].buffer = rev->bufcombL4; rev->combL[3].bufsize = combtuningL4; - rev->combL[4].buffer = rev->bufcombL5; rev->combL[4].bufsize = combtuningL5; - rev->combL[5].buffer = rev->bufcombL6; rev->combL[5].bufsize = combtuningL6; - rev->combL[6].buffer = rev->bufcombL7; rev->combL[6].bufsize = combtuningL7; - rev->combL[7].buffer = rev->bufcombL8; rev->combL[7].bufsize = combtuningL8; - rev->allpassL[0].buffer = rev->bufallpassL1; rev->allpassL[0].bufsize = allpasstuningL1; - rev->allpassL[1].buffer = rev->bufallpassL2; rev->allpassL[1].bufsize = allpasstuningL2; - rev->allpassL[2].buffer = rev->bufallpassL3; rev->allpassL[2].bufsize = allpasstuningL3; - rev->allpassL[3].buffer = rev->bufallpassL4; rev->allpassL[3].bufsize = allpasstuningL4; + static const int comb_lengths[8] = { 1116,1188,1277,1356,1422,1491,1557,1617 }; + static const int allpass_lengths[4] = { 225,341,441,556 }; + double r = srate * (1 / 44100.0); + unsigned c; + + rev->bufcomb=malloc(numcombs*sizeof(float*)); + for (c = 0; c < numcombs; ++c) + { + rev->bufcomb[c] = malloc(r*comb_lengths[c]*sizeof(float)); + rev->combL[c].buffer = rev->bufcomb[c]; + rev->combL[c].bufsize=r*comb_lengths[c]; + } + + rev->bufallpass=malloc(numallpasses*sizeof(float*)); + for (c = 0; c < numallpasses; ++c) + { + rev->bufallpass[c] = malloc(r*allpass_lengths[c]*sizeof(float)); + rev->allpassL[c].buffer = rev->bufallpass[c]; + rev->allpassL[c].bufsize=r*allpass_lengths[c]; + } rev->allpassL[0].feedback = 0.5f; rev->allpassL[1].feedback = 0.5f; @@ -246,6 +230,22 @@ struct reverb_data static void reverb_free(void *data) { + struct reverb_data *rev = (struct reverb_data*)data; + unsigned i; + + for (i = 0; i < numcombs; i++) { + free(rev->left.bufcomb[i]); + free(rev->right.bufcomb[i]); + } + free(rev->left.bufcomb); + free(rev->right.bufcomb); + + for (i = 0; i < numallpasses; i++) { + free(rev->left.bufallpass[i]); + free(rev->right.bufallpass[i]); + } + free(rev->left.bufallpass); + free(rev->right.bufallpass); free(data); } @@ -284,8 +284,8 @@ static void *reverb_init(const struct dspfilter_info *info, config->get_float(userdata, "roomwidth", &roomwidth, 0.56f); config->get_float(userdata, "roomsize", &roomsize, 0.56f); - revmodel_init(&rev->left); - revmodel_init(&rev->right); + revmodel_init(&rev->left,info->input_rate); + revmodel_init(&rev->right,info->input_rate); revmodel_setdamp(&rev->left, damping); revmodel_setdry(&rev->left, drytime); diff --git a/libretro-common/audio/dsp_filters/tremolo.c b/libretro-common/audio/dsp_filters/tremolo.c new file mode 100644 index 0000000..38b5357 --- /dev/null +++ b/libretro-common/audio/dsp_filters/tremolo.c @@ -0,0 +1,133 @@ +/* Copyright (C) 2010-2017 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (tremolo.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 +#include +#include + +#include +#include +#include + +#define sqr(a) ((a) * (a)) + +struct tremolo_core +{ + float freq; + float depth; + float* wavetable; + int index; + int maxindex; +}; + +struct tremolo +{ + struct tremolo_core left, right; +}; + +static void tremolo_free(void *data) +{ + struct tremolo *tre = (struct tremolo*)data; + free(tre->left.wavetable); + free(tre->right.wavetable); + free(data); +} + +static void tremolocore_init(struct tremolo_core *core,float depth,int samplerate,float freq) +{ + const double offset = 1. - depth / 2.; + unsigned i; + double env; + core->index = 0; + core->maxindex = samplerate/freq; + core->wavetable = malloc(core->maxindex*sizeof(float)); + memset(core->wavetable, 0, core->maxindex * sizeof(float)); + for (i = 0; i < core->maxindex; i++) { + env = freq * i / samplerate; + env = sin((M_PI*2) * fmod(env + 0.25, 1.0)); + core->wavetable[i] = env * (1 - fabs(offset)) + offset; + } +} + +float tremolocore_core(struct tremolo_core *core,float in) +{ + core->index = core->index % core->maxindex; + return in * core->wavetable[core->index++]; +} + +static void tremolo_process(void *data, struct dspfilter_output *output, + const struct dspfilter_input *input) +{ + unsigned i; + float *out; + struct tremolo *tre = (struct tremolo*)data; + + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; + + for (i = 0; i < input->frames; i++, out += 2) + { + float in[2] = { out[0], out[1] }; + + out[0] = tremolocore_core(&tre->left, in[0]); + out[1] = tremolocore_core(&tre->right, in[1]); + } +} + +static void *tremolo_init(const struct dspfilter_info *info, + const struct dspfilter_config *config, void *userdata) +{ + float freq, depth; + struct tremolo *tre = (struct tremolo*)calloc(1, sizeof(*tre)); + if (!tre) + return NULL; + + config->get_float(userdata, "freq", &freq,4.0f); + config->get_float(userdata, "depth", &depth, 0.9f); + tremolocore_init(&tre->left,depth,info->input_rate,freq); + tremolocore_init(&tre->right,depth,info->input_rate,freq); + return tre; +} + +static const struct dspfilter_implementation tremolo_plug = { + tremolo_init, + tremolo_process, + tremolo_free, + + DSPFILTER_API_VERSION, + "Tremolo", + "tremolo", +}; + +#ifdef HAVE_FILTERS_BUILTIN +#define dspfilter_get_implementation tremolo_dspfilter_get_implementation +#endif + +const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) +{ + (void)mask; + return &tremolo_plug; +} + +#undef dspfilter_get_implementation + diff --git a/libretro-common/audio/dsp_filters/vibrato.c b/libretro-common/audio/dsp_filters/vibrato.c new file mode 100644 index 0000000..6e79d2f --- /dev/null +++ b/libretro-common/audio/dsp_filters/vibrato.c @@ -0,0 +1,169 @@ +/* Copyright (C) 2010-2017 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (vibrato.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 +#include +#include + +#include +#include +#include + +#define sqr(a) ((a) * (a)) + + +const float BASE_DELAY_SEC = 0.002; // 2 ms +const float VIBRATO_FREQUENCY_DEFAULT_HZ = 2; +const float VIBRATO_FREQUENCY_MAX_HZ = 14; +const float VIBRATO_DEPTH_DEFAULT_PERCENT = 50; +const int add_delay = 3; + +float hermite_interp(float x, float *y) +{ + float c0, c1, c2, c3; + c0 = y[1]; + c1 = (1.0 / 2.0)*(y[2] - y[0]); + c2 = (y[0] - (5.0 / 2.0)*y[1]) + (2.0*y[2] - (1.0 / 2.0)*y[3]); + c3 = (1.0 / 2.0)*(y[3] - y[0]) + (3.0 / 2.0)*(y[1] - y[2]); + return ((c3*x + c2)*x + c1)*x + c0; +} + +struct vibrato_core +{ + float freq; + float samplerate; + int phase; + float depth; + float* buffer; + int writeindex; + int size; +}; + +struct vibrato +{ + struct vibrato_core left, right; +}; + +static void vibrato_free(void *data) +{ + struct vibrato *vib = (struct vibrato*)data; + free(vib->left.buffer); + free(vib->right.buffer); + free(data); +} + +static void vibratocore_init(struct vibrato_core *core,float depth,int samplerate,float freq) +{ + core->size = BASE_DELAY_SEC * samplerate * 2; + core->buffer = malloc((core->size + add_delay)*sizeof(float)); + memset(core->buffer, 0, (core->size + add_delay) * sizeof(float)); + core->samplerate = samplerate; + core->freq = freq; + core->depth = depth; + core->phase = 0; + core->writeindex = 0; +} + +float vibratocore_core(struct vibrato_core *core,float in) +{ + float M = core->freq / core->samplerate; + int maxphase = core->samplerate / core->freq; + float lfo = sin(M * 2. * M_PI * core->phase++); + core->phase = core->phase % maxphase; + lfo = (lfo + 1) * 1.; // transform from [-1; 1] to [0; 1] + int maxdelay = BASE_DELAY_SEC * core->samplerate; + float delay = lfo * core->depth * maxdelay; + delay += add_delay; + float readindex = core->writeindex - 1 - delay; + while (readindex < 0)readindex += core->size; + while (readindex >= core->size)readindex -= core->size; + int ipart = (int)readindex; // integer part of the delay + float fpart = readindex - ipart; // fractional part of the delay + float value = hermite_interp(fpart, &(core->buffer[ipart])); + core->buffer[core->writeindex] = in; + if (core->writeindex < add_delay){ + core->buffer[core->size + core->writeindex] = in; + } + core->writeindex++; + if (core->writeindex == core->size) { + core->writeindex = 0; + } + return value; +} + +static void vibrato_process(void *data, struct dspfilter_output *output, + const struct dspfilter_input *input) +{ + unsigned i; + float *out; + struct vibrato *vib = (struct vibrato*)data; + + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; + + for (i = 0; i < input->frames; i++, out += 2) + { + float in[2] = { out[0], out[1] }; + + out[0] = vibratocore_core(&vib->left, in[0]); + out[1] = vibratocore_core(&vib->right, in[1]); + } +} + +static void *vibrato_init(const struct dspfilter_info *info, + const struct dspfilter_config *config, void *userdata) +{ + float freq, depth; + struct vibrato *vib = (struct vibrato*)calloc(1, sizeof(*vib)); + if (!vib) + return NULL; + + config->get_float(userdata, "freq", &freq,5.0f); + config->get_float(userdata, "depth", &depth, 0.5f); + vibratocore_init(&vib->left,depth,info->input_rate,freq); + vibratocore_init(&vib->right,depth,info->input_rate,freq); + return vib; +} + +static const struct dspfilter_implementation vibrato_plug = { + vibrato_init, + vibrato_process, + vibrato_free, + + DSPFILTER_API_VERSION, + "Vibrato", + "vibrato", +}; + +#ifdef HAVE_FILTERS_BUILTIN +#define dspfilter_get_implementation vibrato_dspfilter_get_implementation +#endif + +const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) +{ + (void)mask; + return &vibrato_plug; +} + +#undef dspfilter_get_implementation + diff --git a/libretro-common/audio/resampler/audio_resampler.c b/libretro-common/audio/resampler/audio_resampler.c index 3cf4660..8d27f06 100644 --- a/libretro-common/audio/resampler/audio_resampler.c +++ b/libretro-common/audio/resampler/audio_resampler.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_resampler.c). diff --git a/libretro-common/audio/resampler/drivers/nearest_resampler.c b/libretro-common/audio/resampler/drivers/nearest_resampler.c index 1083c85..982d4fe 100644 --- a/libretro-common/audio/resampler/drivers/nearest_resampler.c +++ b/libretro-common/audio/resampler/drivers/nearest_resampler.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nearest_resampler.c). diff --git a/libretro-common/audio/resampler/drivers/null_resampler.c b/libretro-common/audio/resampler/drivers/null_resampler.c index e750269..b970dfe 100644 --- a/libretro-common/audio/resampler/drivers/null_resampler.c +++ b/libretro-common/audio/resampler/drivers/null_resampler.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (null_resampler.c). diff --git a/libretro-common/audio/resampler/drivers/sinc_resampler.c b/libretro-common/audio/resampler/drivers/sinc_resampler.c index b5754f6..c400ab1 100644 --- a/libretro-common/audio/resampler/drivers/sinc_resampler.c +++ b/libretro-common/audio/resampler/drivers/sinc_resampler.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (sinc_resampler.c). diff --git a/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S b/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S index 033104e..15a3773 100644 --- a/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S +++ b/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (sinc_resampler_neon.S). diff --git a/libretro-common/compat/compat_fnmatch.c b/libretro-common/compat/compat_fnmatch.c index 81beb3e..19f87cc 100644 --- a/libretro-common/compat/compat_fnmatch.c +++ b/libretro-common/compat/compat_fnmatch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (compat_fnmatch.c). diff --git a/libretro-common/compat/compat_getopt.c b/libretro-common/compat/compat_getopt.c index 632f67e..81978b8 100644 --- a/libretro-common/compat/compat_getopt.c +++ b/libretro-common/compat/compat_getopt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (compat_getopt.c). diff --git a/libretro-common/compat/compat_posix_string.c b/libretro-common/compat/compat_posix_string.c index 4bddf11..33a30e5 100644 --- a/libretro-common/compat/compat_posix_string.c +++ b/libretro-common/compat/compat_posix_string.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (compat_posix_string.c). diff --git a/libretro-common/compat/compat_snprintf.c b/libretro-common/compat/compat_snprintf.c index 03bfba6..7cfd2d7 100644 --- a/libretro-common/compat/compat_snprintf.c +++ b/libretro-common/compat/compat_snprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (compat_snprintf.c). @@ -24,8 +24,9 @@ #ifdef _MSC_VER #include - -#include +#if _MSC_VER >= 1800 +#include /* added for _vsnprintf_s and _vscprintf on VS2015 and VS2017 */ +#endif #include #if _MSC_VER < 1800 diff --git a/libretro-common/compat/compat_strcasestr.c b/libretro-common/compat/compat_strcasestr.c index 82ce5ac..54c93a4 100644 --- a/libretro-common/compat/compat_strcasestr.c +++ b/libretro-common/compat/compat_strcasestr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (compat_strcasestr.c). diff --git a/libretro-common/compat/compat_strl.c b/libretro-common/compat/compat_strl.c index d42fca3..94cb39b 100644 --- a/libretro-common/compat/compat_strl.c +++ b/libretro-common/compat/compat_strl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (compat_strl.c). diff --git a/libretro-common/compat/fopen_utf8.c b/libretro-common/compat/fopen_utf8.c index abd50cf..52b481e 100644 --- a/libretro-common/compat/fopen_utf8.c +++ b/libretro-common/compat/fopen_utf8.c @@ -1,5 +1,28 @@ +/* Copyright (C) 2010-2018 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (fopen_utf8.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 #include +#include #include #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) @@ -11,7 +34,7 @@ #ifdef _WIN32 #undef fopen -FILE* fopen_utf8(const char * filename, const char * mode) +void *fopen_utf8(const char * filename, const char * mode) { #if defined(_XBOX) return fopen(filename, mode); diff --git a/libretro-common/dynamic/dylib.c b/libretro-common/dynamic/dylib.c index d4864a7..bc6be9f 100644 --- a/libretro-common/dynamic/dylib.c +++ b/libretro-common/dynamic/dylib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (dylib.c). diff --git a/libretro-common/encodings/encoding_crc32.c b/libretro-common/encodings/encoding_crc32.c index 0c1895a..4775e76 100644 --- a/libretro-common/encodings/encoding_crc32.c +++ b/libretro-common/encodings/encoding_crc32.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (encoding_crc32.c). diff --git a/libretro-common/encodings/encoding_utf.c b/libretro-common/encodings/encoding_utf.c index d6c4ff4..f7c533f 100644 --- a/libretro-common/encodings/encoding_utf.c +++ b/libretro-common/encodings/encoding_utf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (encoding_utf.c). diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 07ee344..3a32a46 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (features_cpu.c). @@ -219,6 +219,8 @@ retro_time_t cpu_features_get_time_usec(void) return sys_time_get_system_time(); #elif defined(GEKKO) return ticks_to_microsecs(gettime()); +#elif defined(SWITCH) + return (svcGetSystemTick() * 10) / 192; #elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) struct timespec tv = {0}; if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) < 0) @@ -236,8 +238,6 @@ retro_time_t cpu_features_get_time_usec(void) return sceKernelGetProcessTimeWide(); #elif defined(WIIU) return ticks_to_us(OSGetSystemTime()); -#elif defined(SWITCH) - return (svcGetSystemTick() * 10) / 192; #else #error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue." #endif @@ -649,6 +649,10 @@ uint64_t cpu_features_get(void) if (sysctlbyname("hw.optional.neon", NULL, &len, NULL, 0) == 0) cpu |= RETRO_SIMD_NEON; +#elif defined(_XBOX1) + cpu |= RETRO_SIMD_MMX; + cpu |= RETRO_SIMD_SSE; + cpu |= RETRO_SIMD_MMXEXT; #elif defined(CPU_X86) (void)avx_flags; diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index ca39050..b2f3551 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (archive_file.c). @@ -129,7 +129,7 @@ static void file_archive_free(file_archive_file_data_t *data) static file_archive_file_data_t* file_archive_open(const char *path) { - ssize_t ret = -1; + int64_t ret = -1; bool read_from_file = false; file_archive_file_data_t *data = (file_archive_file_data_t*) calloc(1, sizeof(*data)); @@ -722,7 +722,7 @@ error: */ int file_archive_compressed_read( const char * path, void **buf, - const char* optional_filename, ssize_t *length) + const char* optional_filename, int64_t *length) { const struct file_archive_file_backend *backend = NULL; int ret = 0; diff --git a/libretro-common/file/archive_file_7z.c b/libretro-common/file/archive_file_7z.c index 1afd5d4..0f00c07 100644 --- a/libretro-common/file/archive_file_7z.c +++ b/libretro-common/file/archive_file_7z.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (archive_file_sevenzip.c). diff --git a/libretro-common/file/archive_file_zlib.c b/libretro-common/file/archive_file_zlib.c index 4716ba9..07fec55 100644 --- a/libretro-common/file/archive_file_zlib.c +++ b/libretro-common/file/archive_file_zlib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (archive_file_zlib.c). @@ -240,22 +240,22 @@ static int zip_file_read( const char *needle, void **buf, const char *optional_outfile) { - file_archive_transfer_t zlib; + file_archive_transfer_t zlib = {0}; struct archive_extract_userdata userdata = {{0}}; - bool returnerr = true; - int ret = 0; + bool returnerr = true; + int ret = 0; - zlib.type = ARCHIVE_TRANSFER_INIT; + zlib.type = ARCHIVE_TRANSFER_INIT; - userdata.decomp_state.needle = NULL; - userdata.decomp_state.opt_file = NULL; - userdata.decomp_state.found = false; - userdata.decomp_state.buf = buf; + userdata.decomp_state.needle = NULL; + userdata.decomp_state.opt_file = NULL; + userdata.decomp_state.found = false; + userdata.decomp_state.buf = buf; if (needle) - userdata.decomp_state.needle = strdup(needle); + userdata.decomp_state.needle = strdup(needle); if (optional_outfile) - userdata.decomp_state.opt_file = strdup(optional_outfile); + userdata.decomp_state.opt_file = strdup(optional_outfile); do { diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 455d3aa..a8f8cfa 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (config_file.c). @@ -862,7 +862,7 @@ bool config_file_write(config_file_t *conf, const char *path) if (!string_is_empty(path)) { void* buf = NULL; - FILE *file = fopen_utf8(path, "wb"); + FILE *file = (FILE*)fopen_utf8(path, "wb"); if (!file) return false; diff --git a/libretro-common/file/config_file_userdata.c b/libretro-common/file/config_file_userdata.c index 8490fda..e91fb8b 100644 --- a/libretro-common/file/config_file_userdata.c +++ b/libretro-common/file/config_file_userdata.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (config_file_userdata.c). diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 4830898..7c79b0b 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_path.c). @@ -392,7 +392,7 @@ char *path_remove_extension(char *path) return NULL; if (*last) *last = '\0'; - return last; + return path; } /** @@ -793,7 +793,7 @@ bool path_is_absolute(const char *path) **/ void path_resolve_realpath(char *buf, size_t size) { -#ifndef RARCH_CONSOLE +#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) char tmp[PATH_MAX_LENGTH]; tmp[0] = '\0'; @@ -971,7 +971,7 @@ void fill_short_pathname_representation_noext(char* out_rep, void fill_pathname_expand_special(char *out_path, const char *in_path, size_t size) { -#if !defined(RARCH_CONSOLE) +#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) if (*in_path == '~') { const char *home = getenv("HOME"); @@ -1020,7 +1020,7 @@ void fill_pathname_expand_special(char *out_path, void fill_pathname_abbreviate_special(char *out_path, const char *in_path, size_t size) { -#if !defined(RARCH_CONSOLE) +#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) unsigned i; const char *candidates[3]; const char *notations[3]; @@ -1107,7 +1107,7 @@ void path_basedir_wrapper(char *path) snprintf(path, 3, ".%s", path_default_slash()); } -#if !defined(RARCH_CONSOLE) +#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) void fill_pathname_application_path(char *s, size_t len) { size_t i; diff --git a/libretro-common/file/nbio/nbio_intf.c b/libretro-common/file/nbio/nbio_intf.c index cfcef60..d6254ef 100644 --- a/libretro-common/file/nbio/nbio_intf.c +++ b/libretro-common/file/nbio/nbio_intf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nbio_intf.c). diff --git a/libretro-common/file/nbio/nbio_linux.c b/libretro-common/file/nbio/nbio_linux.c index 8ef3f2b..8644bb9 100644 --- a/libretro-common/file/nbio/nbio_linux.c +++ b/libretro-common/file/nbio/nbio_linux.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nbio_linux.c). diff --git a/libretro-common/file/nbio/nbio_stdio.c b/libretro-common/file/nbio/nbio_stdio.c index aa9d3cc..f80e91a 100644 --- a/libretro-common/file/nbio/nbio_stdio.c +++ b/libretro-common/file/nbio/nbio_stdio.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nbio_stdio.c). diff --git a/libretro-common/file/nbio/nbio_unixmmap.c b/libretro-common/file/nbio/nbio_unixmmap.c index 672b556..29b5747 100644 --- a/libretro-common/file/nbio/nbio_unixmmap.c +++ b/libretro-common/file/nbio/nbio_unixmmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nbio_unixmmap.c). diff --git a/libretro-common/file/nbio/nbio_windowsmmap.c b/libretro-common/file/nbio/nbio_windowsmmap.c index ff9d9d4..2bfd834 100644 --- a/libretro-common/file/nbio/nbio_windowsmmap.c +++ b/libretro-common/file/nbio/nbio_windowsmmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nbio_windowsmmap.c). diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 9c53504..0b6ecad 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_dirent.c). @@ -106,8 +106,14 @@ struct RDIR *retro_opendir(const char *name) wchar_t *path_wide = NULL; unsigned path_len; #endif - struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir)); + struct RDIR *rdir; + /*Reject null or empty string paths*/ + if (!name||(*name==0)) + return NULL; + + /*Allocate RDIR struct. Tidied later with retro_closedir*/ + rdir = (struct RDIR*)calloc(1, sizeof(*rdir)); if (!rdir) return NULL; diff --git a/libretro-common/formats/bmp/rbmp.c b/libretro-common/formats/bmp/rbmp.c index ee2b06f..1e7eaa9 100644 --- a/libretro-common/formats/bmp/rbmp.c +++ b/libretro-common/formats/bmp/rbmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rbmp.c). diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index 8b22f5c..50798b0 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rbmp_encode.c). diff --git a/libretro-common/formats/image_texture.c b/libretro-common/formats/image_texture.c index c531335..e2f3c3d 100644 --- a/libretro-common/formats/image_texture.c +++ b/libretro-common/formats/image_texture.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (image_texture.c). diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index 4c2bb5d..3f78b53 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (image_transfer.c). diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 49490e8..0b1f7ea 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rjpeg.c). diff --git a/libretro-common/formats/json/jsonsax.c b/libretro-common/formats/json/jsonsax.c index fec8a7d..ec57c00 100644 --- a/libretro-common/formats/json/jsonsax.c +++ b/libretro-common/formats/json/jsonsax.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (jsonsax.c). diff --git a/libretro-common/formats/libchdr/bitstream.c b/libretro-common/formats/libchdr/libchdr_bitstream.c similarity index 100% rename from libretro-common/formats/libchdr/bitstream.c rename to libretro-common/formats/libchdr/libchdr_bitstream.c diff --git a/libretro-common/formats/libchdr/cdrom.c b/libretro-common/formats/libchdr/libchdr_cdrom.c similarity index 100% rename from libretro-common/formats/libchdr/cdrom.c rename to libretro-common/formats/libchdr/libchdr_cdrom.c diff --git a/libretro-common/formats/libchdr/chd.c b/libretro-common/formats/libchdr/libchdr_chd.c similarity index 94% rename from libretro-common/formats/libchdr/chd.c rename to libretro-common/formats/libchdr/libchdr_chd.c index 78cac09..93e4fbc 100644 --- a/libretro-common/formats/libchdr/chd.c +++ b/libretro-common/formats/libchdr/libchdr_chd.c @@ -38,6 +38,7 @@ ***************************************************************************/ #include +#include #include #include #include @@ -49,7 +50,9 @@ #include #include #include + #include +#include #define TRUE 1 #define FALSE 0 @@ -253,7 +256,7 @@ struct _chd_file { UINT32 cookie; /* cookie, should equal COOKIE_VALUE */ - core_file * file; /* handle to the open core file */ + RFILE * file; /* handle to the open core file */ UINT8 owns_file; /* flag indicating if this file should be closed on chd_close() */ chd_header header; /* header, extracted from file */ @@ -280,6 +283,7 @@ struct _chd_file #ifdef NEED_CACHE_HUNK UINT32 maxhunk; /* maximum hunk accessed */ #endif + UINT8 * file_cache; /* cache of underlying file */ }; /*************************************************************************** @@ -405,9 +409,10 @@ void *lzma_fast_alloc(void *p, size_t size) } /* alloc a new one and put it into the list */ - addr = (uint32_t *)malloc(sizeof(uint8_t) * (size + sizeof(uint32_t))); - if (addr==NULL) + addr = (uint32_t *)malloc(sizeof(uint32_t) * (size + sizeof(uint32_t))); + if (!addr) return NULL; + for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++) { if (codec->allocptr[scan] == NULL) @@ -465,7 +470,7 @@ chd_error lzma_codec_init(void* codec, uint32_t hunkbytes) { CLzmaEncProps encoder_props; CLzmaEncHandle enc; - Byte decoder_props[LZMA_PROPS_SIZE]; + uint8_t decoder_props[LZMA_PROPS_SIZE]; lzma_allocator* alloc; size_t props_size; lzma_codec_data* lzma_codec = (lzma_codec_data*) codec; @@ -1146,8 +1151,8 @@ static chd_error decompress_v5_map(chd_file* chd, chd_header* header) } /* read the reader */ - core_fseek(chd->file, header->mapoffset, SEEK_SET); - core_fread(chd->file, rawbuf, sizeof(rawbuf)); + filestream_seek(chd->file, header->mapoffset, SEEK_SET); + filestream_read(chd->file, rawbuf, sizeof(rawbuf)); mapbytes = get_bigendian_uint32(&rawbuf[0]); firstoffs = get_bigendian_uint48(&rawbuf[4]); mapcrc = get_bigendian_uint16(&rawbuf[10]); @@ -1160,8 +1165,8 @@ static chd_error decompress_v5_map(chd_file* chd, chd_header* header) if (compressed == NULL) return CHDERR_OUT_OF_MEMORY; - core_fseek(chd->file, header->mapoffset + 16, SEEK_SET); - core_fread(chd->file, compressed, mapbytes); + filestream_seek(chd->file, header->mapoffset + 16, SEEK_SET); + filestream_read(chd->file, compressed, mapbytes); bitbuf = create_bitstream(compressed, sizeof(uint8_t) * mapbytes); if (bitbuf == NULL) { @@ -1313,7 +1318,7 @@ static INLINE void map_extract_old(const UINT8 *base, map_entry *entry, UINT32 h chd_open_file - open a CHD file for access -------------------------------------------------*/ -chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd) +chd_error chd_open_file(RFILE *file, int mode, chd_file *parent, chd_file **chd) { chd_file *newchd = NULL; chd_error err; @@ -1405,13 +1410,13 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file ** /* find the codec interface */ if (newchd->header.version < 5) { - for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++) + for (intfnum = 0; intfnum < ARRAY_SIZE(codec_interfaces); intfnum++) if (codec_interfaces[intfnum].compression == newchd->header.compression[0]) { newchd->codecintf[0] = &codec_interfaces[intfnum]; break; } - if (intfnum == ARRAY_LENGTH(codec_interfaces)) + if (intfnum == ARRAY_SIZE(codec_interfaces)) EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT); /* initialize the codec */ @@ -1425,9 +1430,9 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file ** { int i, decompnum; /* verify the compression types and initialize the codecs */ - for (decompnum = 0; decompnum < ARRAY_LENGTH(newchd->header.compression); decompnum++) + for (decompnum = 0; decompnum < ARRAY_SIZE(newchd->header.compression); decompnum++) { - for (i = 0 ; i < ARRAY_LENGTH(codec_interfaces) ; i++) + for (i = 0 ; i < ARRAY_SIZE(codec_interfaces) ; i++) { if (codec_interfaces[i].compression == newchd->header.compression[decompnum]) { @@ -1492,7 +1497,7 @@ cleanup: chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd) { chd_error err; - core_file *file = NULL; + RFILE *file = NULL; /* choose the proper mode */ switch(mode) @@ -1506,8 +1511,11 @@ chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file ** } /* open the file */ - file = core_fopen(filename); - if (file == 0) + file = filestream_open(filename, + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); + + if (!file) { err = CHDERR_FILE_NOT_FOUND; goto cleanup; @@ -1523,10 +1531,36 @@ chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file ** cleanup: if ((err != CHDERR_NONE) && (file != NULL)) - core_fclose(file); + filestream_close(file); return err; } +chd_error chd_precache(chd_file *chd) +{ + int64_t size, count; + + if (!chd->file_cache) + { + filestream_seek(chd->file, 0, SEEK_END); + size = filestream_tell(chd->file); + if (size <= 0) + return CHDERR_INVALID_DATA; + chd->file_cache = malloc(size); + if (chd->file_cache == NULL) + return CHDERR_OUT_OF_MEMORY; + filestream_seek(chd->file, 0, SEEK_SET); + count = filestream_read(chd->file, chd->file_cache, size); + if (count != size) + { + free(chd->file_cache); + chd->file_cache = NULL; + return CHDERR_READ_ERROR; + } + } + + return CHDERR_NONE; +} + /*------------------------------------------------- chd_close - close a CHD file for access -------------------------------------------------*/ @@ -1593,12 +1627,15 @@ void chd_close(chd_file *chd) /* close the file */ if (chd->owns_file && chd->file != NULL) - core_fclose(chd->file); + filestream_close(chd->file); #ifdef NEED_CACHE_HUNK if (PRINTF_MAX_HUNK) printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks); #endif + if (chd->file_cache) + free(chd->file_cache); + /* free our memory */ free(chd); } @@ -1608,7 +1645,7 @@ void chd_close(chd_file *chd) core_file -------------------------------------------------*/ -core_file *chd_core_file(chd_file *chd) +RFILE *chd_core_file(chd_file *chd) { return chd->file; } @@ -1704,7 +1741,7 @@ chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, { metadata_entry metaentry; chd_error err; - UINT32 count; + int64_t count; /* if we didn't find it, just return */ err = metadata_find_entry(chd, searchtag, searchindex, &metaentry); @@ -1735,8 +1772,8 @@ chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, /* read the metadata */ outputlen = MIN(outputlen, metaentry.length); - core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET); - count = core_fread(chd->file, output, outputlen); + filestream_seek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET); + count = filestream_read(chd->file, output, outputlen); if (count != outputlen) return CHDERR_READ_ERROR; @@ -1807,11 +1844,11 @@ static chd_error header_validate(const chd_header *header) return CHDERR_INVALID_PARAMETER; /* require a supported compression mechanism */ - for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++) + for (intfnum = 0; intfnum < ARRAY_SIZE(codec_interfaces); intfnum++) if (codec_interfaces[intfnum].compression == header->compression[0]) break; - if (intfnum == ARRAY_LENGTH(codec_interfaces)) + if (intfnum == ARRAY_SIZE(codec_interfaces)) return CHDERR_INVALID_PARAMETER; /* require a valid hunksize */ @@ -1875,7 +1912,7 @@ static UINT32 header_guess_unitbytes(chd_file *chd) static chd_error header_read(chd_file *chd, chd_header *header) { UINT8 rawheader[CHD_MAX_HEADER_SIZE]; - UINT32 count; + int64_t count; /* punt if NULL */ if (header == NULL) @@ -1886,8 +1923,8 @@ static chd_error header_read(chd_file *chd, chd_header *header) return CHDERR_INVALID_FILE; /* seek and read */ - core_fseek(chd->file, 0, SEEK_SET); - count = core_fread(chd->file, rawheader, sizeof(rawheader)); + filestream_seek(chd->file, 0, SEEK_SET); + count = filestream_read(chd->file, rawheader, sizeof(rawheader)); if (count != sizeof(rawheader)) return CHDERR_READ_ERROR; @@ -2034,6 +2071,35 @@ static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum) } #endif +static UINT8* read_compressed(chd_file *chd, UINT64 offset, size_t size) +{ + int64_t bytes; + if (chd->file_cache) + return chd->file_cache + offset; + filestream_seek(chd->file, offset, SEEK_SET); + bytes = filestream_read(chd->file, chd->compressed, size); + if (bytes != size) + return NULL; + return chd->compressed; +} + +static chd_error read_uncompressed(chd_file *chd, UINT64 offset, size_t size, UINT8 *dest) +{ + int64_t bytes; + if (chd->file_cache) + { + memcpy(dest, chd->file_cache + offset, size); + return CHDERR_NONE; + } + filestream_seek(chd->file, offset, SEEK_SET); + bytes = filestream_read(chd->file, dest, size); + if (bytes != size) + return CHDERR_READ_ERROR; + return CHDERR_NONE; +} + + + /*------------------------------------------------- hunk_read_into_memory - read a hunk into memory at the given location @@ -2065,30 +2131,28 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des { /* compressed data */ case V34_MAP_ENTRY_TYPE_COMPRESSED: + { + void *codec; + UINT8 *bytes = read_compressed(chd, entry->offset, + entry->length); + if (bytes == NULL) + return CHDERR_READ_ERROR; - /* read it into the decompression buffer */ - if (core_fseek(chd->file, entry->offset, SEEK_SET) != 0) - return CHDERR_READ_ERROR; - bytes = core_fread(chd->file, chd->compressed, entry->length); - if (bytes != entry->length) - return CHDERR_READ_ERROR; - - /* now decompress using the codec */ - err = CHDERR_NONE; - codec = &chd->zlib_codec_data; - if (chd->codecintf[0]->decompress != NULL) - err = (*chd->codecintf[0]->decompress)(codec, chd->compressed, entry->length, dest, chd->header.hunkbytes); - if (err != CHDERR_NONE) - return err; + /* now decompress using the codec */ + err = CHDERR_NONE; + codec = &chd->zlib_codec_data; + if (chd->codecintf[0]->decompress != NULL) + err = (*chd->codecintf[0]->decompress)(codec, chd->compressed, entry->length, dest, chd->header.hunkbytes); + if (err != CHDERR_NONE) + return err; + } break; /* uncompressed data */ case V34_MAP_ENTRY_TYPE_UNCOMPRESSED: - if (core_fseek(chd->file, entry->offset, SEEK_SET) != 0) - return CHDERR_READ_ERROR; - bytes = core_fread(chd->file, dest, chd->header.hunkbytes); - if (bytes != chd->header.hunkbytes) - return CHDERR_READ_ERROR; + err = read_uncompressed(chd, entry->offset, chd->header.hunkbytes, dest); + if (err != CHDERR_NONE) + return err; break; /* mini-compressed data */ @@ -2125,6 +2189,7 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des uint16_t blockcrc; #endif uint8_t *rawmap = &chd->header.rawmap[chd->header.mapentrybytes * hunknum]; + UINT8 *bytes; #if 0 /* uncompressed case - TODO */ @@ -2155,11 +2220,9 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des case COMPRESSION_TYPE_1: case COMPRESSION_TYPE_2: case COMPRESSION_TYPE_3: - if (core_fseek(chd->file, blockoffs, SEEK_SET) != 0) - return CHDERR_READ_ERROR; - if(core_fread(chd->file, chd->compressed, blocklen) != blocklen) - return CHDERR_READ_ERROR; - + bytes = read_compressed(chd, blockoffs, blocklen); + if (bytes == NULL) + return CHDERR_READ_ERROR; switch (chd->codecintf[rawmap[0]]->compression) { case CHD_CODEC_CD_LZMA: @@ -2186,13 +2249,12 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des return CHDERR_NONE; case COMPRESSION_NONE: - if (core_fseek(chd->file, blockoffs, SEEK_SET) != 0) - return CHDERR_READ_ERROR; - if (core_fread(chd->file, dest, chd->header.hunkbytes) != chd->header.hunkbytes) - return CHDERR_READ_ERROR; + err = read_uncompressed(chd, blockoffs, blocklen, dest); + if (err != CHDERR_NONE) + return err; #ifdef VERIFY_BLOCK_CRC - if (crc16(dest, chd->header.hunkbytes) != blockcrc) - return CHDERR_DECOMPRESSION_ERROR; + if (crc16(dest, chd->header.hunkbytes) != blockcrc) + return CHDERR_DECOMPRESSION_ERROR; #endif return CHDERR_NONE; @@ -2219,12 +2281,12 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des INTERNAL MAP ACCESS ***************************************************************************/ -static size_t core_fsize(core_file *f) +static size_t core_fsize(RFILE *f) { - long rv,p = ftell(f); - fseek(f, 0, SEEK_END); - rv = ftell(f); - fseek(f, p, SEEK_SET); + int64_t rv, p = filestream_tell(f); + filestream_seek(f, 0, SEEK_END); + rv = filestream_tell(f); + filestream_seek(f, p, SEEK_SET); return rv; } @@ -2238,7 +2300,7 @@ static chd_error map_read(chd_file *chd) UINT8 raw_map_entries[MAP_STACK_ENTRIES * MAP_ENTRY_SIZE]; UINT64 fileoffset, maxoffset = 0; UINT8 cookie[MAP_ENTRY_SIZE]; - UINT32 count; + int64_t count; chd_error err; int i; @@ -2257,8 +2319,8 @@ static chd_error map_read(chd_file *chd) entries = MAP_STACK_ENTRIES; /* read that many */ - core_fseek(chd->file, fileoffset, SEEK_SET); - count = core_fread(chd->file, raw_map_entries, entries * entrysize); + filestream_seek(chd->file, fileoffset, SEEK_SET); + count = filestream_read(chd->file, raw_map_entries, entries * entrysize); if (count != entries * entrysize) { err = CHDERR_READ_ERROR; @@ -2286,8 +2348,8 @@ static chd_error map_read(chd_file *chd) } /* verify the cookie */ - core_fseek(chd->file, fileoffset, SEEK_SET); - count = core_fread(chd->file, &cookie, entrysize); + filestream_seek(chd->file, fileoffset, SEEK_SET); + count = filestream_read(chd->file, &cookie, entrysize); if (count != entrysize || memcmp(&cookie, END_OF_LIST_COOKIE, entrysize)) { err = CHDERR_INVALID_FILE; @@ -2327,11 +2389,11 @@ static chd_error metadata_find_entry(chd_file *chd, UINT32 metatag, UINT32 metai while (metaentry->offset != 0) { UINT8 raw_meta_header[METADATA_HEADER_SIZE]; - UINT32 count; + int64_t count; /* read the raw header */ - core_fseek(chd->file, metaentry->offset, SEEK_SET); - count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header)); + filestream_seek(chd->file, metaentry->offset, SEEK_SET); + count = filestream_read(chd->file, raw_meta_header, sizeof(raw_meta_header)); if (count != sizeof(raw_meta_header)) break; diff --git a/libretro-common/formats/libchdr/flac.c b/libretro-common/formats/libchdr/libchdr_flac.c similarity index 99% rename from libretro-common/formats/libchdr/flac.c rename to libretro-common/formats/libchdr/libchdr_flac.c index 8fe0cf7..4cc5dc2 100644 --- a/libretro-common/formats/libchdr/flac.c +++ b/libretro-common/formats/libchdr/libchdr_flac.c @@ -12,6 +12,7 @@ #include #include #include +#include /*************************************************************************** * FLAC DECODER @@ -153,7 +154,7 @@ bool flac_decoder::decode(int16_t **samples, uint32_t num_samples, bool swap_end { /* make sure we don't have too many channels */ int chans = channels(); - if (chans > ARRAY_LENGTH(m_uncompressed_start)) + if (chans > ARRAY_SIZE(m_uncompressed_start)) return false; /* configure the uncompressed buffer */ diff --git a/libretro-common/formats/libchdr/huffman.c b/libretro-common/formats/libchdr/libchdr_huffman.c similarity index 99% rename from libretro-common/formats/libchdr/huffman.c rename to libretro-common/formats/libchdr/libchdr_huffman.c index 04b0300..dd041a7 100644 --- a/libretro-common/formats/libchdr/huffman.c +++ b/libretro-common/formats/libchdr/libchdr_huffman.c @@ -294,7 +294,10 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder, /* make sure we ended up with the right number */ if (curcode != decoder->numcodes) + { + delete_huffman_decoder(smallhuff); return HUFFERR_INVALID_DATA; + } /* assign canonical codes for all nodes based on their code lengths */ error = huffman_assign_canonical_codes(decoder); diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index b4b9c6c..e282721 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rpng.c). diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index 92e25e1..3500c3a 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rpng_encode.c). diff --git a/libretro-common/formats/png/rpng_internal.h b/libretro-common/formats/png/rpng_internal.h index 440bd3d..62dcfbc 100644 --- a/libretro-common/formats/png/rpng_internal.h +++ b/libretro-common/formats/png/rpng_internal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rpng_internal.h). diff --git a/libretro-common/formats/tga/rtga.c b/libretro-common/formats/tga/rtga.c index 7e4e62e..c96e7ba 100644 --- a/libretro-common/formats/tga/rtga.c +++ b/libretro-common/formats/tga/rtga.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rtga.c). diff --git a/libretro-common/formats/wav/rwav.c b/libretro-common/formats/wav/rwav.c index 7e43ade..e012005 100644 --- a/libretro-common/formats/wav/rwav.c +++ b/libretro-common/formats/wav/rwav.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rwav.c). diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index b712965..e2a02a7 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml.c). diff --git a/libretro-common/formats/xml/test/rxml_test.c b/libretro-common/formats/xml/test/rxml_test.c index e966b1d..36e794e 100644 --- a/libretro-common/formats/xml/test/rxml_test.c +++ b/libretro-common/formats/xml/test/rxml_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml_test.c). diff --git a/libretro-common/gfx/gl_capabilities.c b/libretro-common/gfx/gl_capabilities.c index d9c8d14..d7ec069 100644 --- a/libretro-common/gfx/gl_capabilities.c +++ b/libretro-common/gfx/gl_capabilities.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (gl_capabilities.c). diff --git a/libretro-common/gfx/scaler/pixconv.c b/libretro-common/gfx/scaler/pixconv.c index 604479e..64f5d89 100644 --- a/libretro-common/gfx/scaler/pixconv.c +++ b/libretro-common/gfx/scaler/pixconv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (pixconv.c). diff --git a/libretro-common/gfx/scaler/scaler.c b/libretro-common/gfx/scaler/scaler.c index eb0a0e4..803fecb 100644 --- a/libretro-common/gfx/scaler/scaler.c +++ b/libretro-common/gfx/scaler/scaler.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (scaler.c). @@ -239,6 +239,10 @@ bool scaler_ctx_gen_filter(struct scaler_ctx *ctx) ctx->out_pixconv = conv_argb8888_bgr24; break; + case SCALER_FMT_ABGR8888: + ctx->out_pixconv = conv_argb8888_abgr8888; + break; + default: return false; } diff --git a/libretro-common/gfx/scaler/scaler_filter.c b/libretro-common/gfx/scaler/scaler_filter.c index 6134e99..498f80d 100644 --- a/libretro-common/gfx/scaler/scaler_filter.c +++ b/libretro-common/gfx/scaler/scaler_filter.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (scaler_filter.c). diff --git a/libretro-common/gfx/scaler/scaler_int.c b/libretro-common/gfx/scaler/scaler_int.c index 42c8ab5..9aa583c 100644 --- a/libretro-common/gfx/scaler/scaler_int.c +++ b/libretro-common/gfx/scaler/scaler_int.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (scaler_int.c). diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index ab8c562..85a7ced 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsm). @@ -2207,7 +2207,7 @@ static bool glsm_state_ctx_init(void *data) #ifdef CORE hw_render.context_type = RETRO_HW_CONTEXT_OPENGL_CORE; hw_render.version_major = 3; - hw_render.version_minor = 1; + hw_render.version_minor = 3; #else hw_render.context_type = RETRO_HW_CONTEXT_OPENGL; #endif diff --git a/libretro-common/glsym/glsym_gl.c b/libretro-common/glsym/glsym_gl.c index 5aa92fd..d89992c 100644 --- a/libretro-common/glsym/glsym_gl.c +++ b/libretro-common/glsym/glsym_gl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsym). diff --git a/libretro-common/glsym/rglgen.c b/libretro-common/glsym/rglgen.c index 0ea1fdc..6306eae 100644 --- a/libretro-common/glsym/rglgen.c +++ b/libretro-common/glsym/rglgen.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsym). diff --git a/libretro-common/hash/rhash.c b/libretro-common/hash/rhash.c index 616e859..b123d4d 100644 --- a/libretro-common/hash/rhash.c +++ b/libretro-common/hash/rhash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rhash.c). diff --git a/libretro-common/include/audio/audio_mix.h b/libretro-common/include/audio/audio_mix.h index 3b59dff..937c4b2 100644 --- a/libretro-common/include/audio/audio_mix.h +++ b/libretro-common/include/audio/audio_mix.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_mix.h). diff --git a/libretro-common/include/audio/audio_mixer.h b/libretro-common/include/audio/audio_mixer.h index 3df9c64..a9c5883 100644 --- a/libretro-common/include/audio/audio_mixer.h +++ b/libretro-common/include/audio/audio_mixer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_mixer.h). @@ -41,7 +41,9 @@ enum audio_mixer_type AUDIO_MIXER_TYPE_NONE = 0, AUDIO_MIXER_TYPE_WAV, AUDIO_MIXER_TYPE_OGG, - AUDIO_MIXER_TYPE_MOD + AUDIO_MIXER_TYPE_MOD, + AUDIO_MIXER_TYPE_FLAC, + AUDIO_MIXER_TYPE_MP3 }; typedef struct audio_mixer_sound audio_mixer_sound_t; @@ -61,6 +63,8 @@ void audio_mixer_done(void); audio_mixer_sound_t* audio_mixer_load_wav(void *buffer, int32_t size); audio_mixer_sound_t* audio_mixer_load_ogg(void *buffer, int32_t size); audio_mixer_sound_t* audio_mixer_load_mod(void *buffer, int32_t size); +audio_mixer_sound_t* audio_mixer_load_flac(void *buffer, int32_t size); +audio_mixer_sound_t* audio_mixer_load_mp3(void *buffer, int32_t size); void audio_mixer_destroy(audio_mixer_sound_t* sound); diff --git a/libretro-common/include/audio/audio_resampler.h b/libretro-common/include/audio/audio_resampler.h index d950586..46eb426 100644 --- a/libretro-common/include/audio/audio_resampler.h +++ b/libretro-common/include/audio/audio_resampler.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_resampler.h). diff --git a/libretro-common/include/audio/conversion/float_to_s16.h b/libretro-common/include/audio/conversion/float_to_s16.h index 30903cf..2ddf65e 100644 --- a/libretro-common/include/audio/conversion/float_to_s16.h +++ b/libretro-common/include/audio/conversion/float_to_s16.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (float_to_s16.h). diff --git a/libretro-common/include/audio/conversion/s16_to_float.h b/libretro-common/include/audio/conversion/s16_to_float.h index ebe43ac..4f705b8 100644 --- a/libretro-common/include/audio/conversion/s16_to_float.h +++ b/libretro-common/include/audio/conversion/s16_to_float.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (s16_to_float.h). diff --git a/libretro-common/include/audio/dsp_filter.h b/libretro-common/include/audio/dsp_filter.h index 2055235..82af771 100644 --- a/libretro-common/include/audio/dsp_filter.h +++ b/libretro-common/include/audio/dsp_filter.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (dsp_filter.h). diff --git a/libretro-common/include/boolean.h b/libretro-common/include/boolean.h index 8a5482c..f06ac5a 100644 --- a/libretro-common/include/boolean.h +++ b/libretro-common/include/boolean.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (boolean.h). diff --git a/libretro-common/include/clamping.h b/libretro-common/include/clamping.h index 7919332..ec29bf9 100644 --- a/libretro-common/include/clamping.h +++ b/libretro-common/include/clamping.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (clamping.h). diff --git a/libretro-common/include/compat/apple_compat.h b/libretro-common/include/compat/apple_compat.h index f656546..819b39e 100644 --- a/libretro-common/include/compat/apple_compat.h +++ b/libretro-common/include/compat/apple_compat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (apple_compat.h). diff --git a/libretro-common/include/compat/fnmatch.h b/libretro-common/include/compat/fnmatch.h index 3f3c025..cede1ca 100644 --- a/libretro-common/include/compat/fnmatch.h +++ b/libretro-common/include/compat/fnmatch.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fnmatch.h). diff --git a/libretro-common/include/compat/fopen_utf8.h b/libretro-common/include/compat/fopen_utf8.h index 67cc289..f59822a 100644 --- a/libretro-common/include/compat/fopen_utf8.h +++ b/libretro-common/include/compat/fopen_utf8.h @@ -1,13 +1,33 @@ -#ifndef __FOPEN_UTF8_H -#define __FOPEN_UTF8_H +/* Copyright (C) 2010-2018 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (fopen_utf8.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. + */ -#include +#ifndef __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H +#define __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H #ifdef _WIN32 -/* defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ +/* Defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ /* TODO: enable */ /* #define fopen (use fopen_utf8 instead) */ -FILE* fopen_utf8(const char * filename, const char * mode); +void *fopen_utf8(const char * filename, const char * mode); #else #define fopen_utf8 fopen #endif diff --git a/libretro-common/include/compat/getopt.h b/libretro-common/include/compat/getopt.h index f685681..74287b6 100644 --- a/libretro-common/include/compat/getopt.h +++ b/libretro-common/include/compat/getopt.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (getopt.h). diff --git a/libretro-common/include/compat/intrinsics.h b/libretro-common/include/compat/intrinsics.h index 5d6e8a5..3fc7d92 100644 --- a/libretro-common/include/compat/intrinsics.h +++ b/libretro-common/include/compat/intrinsics.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (intrinsics.h). diff --git a/libretro-common/include/compat/msvc.h b/libretro-common/include/compat/msvc.h index fea4b53..822c973 100644 --- a/libretro-common/include/compat/msvc.h +++ b/libretro-common/include/compat/msvc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (msvc.h). diff --git a/libretro-common/include/compat/posix_string.h b/libretro-common/include/compat/posix_string.h index 380e1a1..9f56322 100644 --- a/libretro-common/include/compat/posix_string.h +++ b/libretro-common/include/compat/posix_string.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (posix_string.h). diff --git a/libretro-common/include/compat/strcasestr.h b/libretro-common/include/compat/strcasestr.h index 376f100..f849593 100644 --- a/libretro-common/include/compat/strcasestr.h +++ b/libretro-common/include/compat/strcasestr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (strcasestr.h). diff --git a/libretro-common/include/compat/strl.h b/libretro-common/include/compat/strl.h index 853acef..290498d 100644 --- a/libretro-common/include/compat/strl.h +++ b/libretro-common/include/compat/strl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (strl.h). diff --git a/libretro-common/include/dynamic/dylib.h b/libretro-common/include/dynamic/dylib.h index b8ee171..f695127 100644 --- a/libretro-common/include/dynamic/dylib.h +++ b/libretro-common/include/dynamic/dylib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (dylib.h). diff --git a/libretro-common/include/encodings/crc32.h b/libretro-common/include/encodings/crc32.h index 0c99476..76fbb54 100644 --- a/libretro-common/include/encodings/crc32.h +++ b/libretro-common/include/encodings/crc32.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (crc32.h). diff --git a/libretro-common/include/encodings/utf.h b/libretro-common/include/encodings/utf.h index bad9458..b513f28 100644 --- a/libretro-common/include/encodings/utf.h +++ b/libretro-common/include/encodings/utf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (utf.h). diff --git a/libretro-common/include/encodings/win32.h b/libretro-common/include/encodings/win32.h index 7d8057e..d4221bd 100644 --- a/libretro-common/include/encodings/win32.h +++ b/libretro-common/include/encodings/win32.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (utf.h). diff --git a/libretro-common/include/fastcpy.h b/libretro-common/include/fastcpy.h index 13b94d9..9d40702 100644 --- a/libretro-common/include/fastcpy.h +++ b/libretro-common/include/fastcpy.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fastcpy.h). diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h index fd8f5f6..0aa043d 100644 --- a/libretro-common/include/features/features_cpu.h +++ b/libretro-common/include/features/features_cpu.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (features_cpu.h). diff --git a/libretro-common/include/file/archive_file.h b/libretro-common/include/file/archive_file.h index b2b5971..6cc7d47 100644 --- a/libretro-common/include/file/archive_file.h +++ b/libretro-common/include/file/archive_file.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (archive_file.h). @@ -187,7 +187,7 @@ bool file_archive_perform_mode(const char *name, const char *valid_exts, int file_archive_compressed_read( const char* path, void **buf, - const char* optional_filename, ssize_t *length); + const char* optional_filename, int64_t *length); const struct file_archive_file_backend* file_archive_get_zlib_file_backend(void); const struct file_archive_file_backend* file_archive_get_7z_file_backend(void); diff --git a/libretro-common/include/file/config_file.h b/libretro-common/include/file/config_file.h index 3c0d999..6b4dde7 100644 --- a/libretro-common/include/file/config_file.h +++ b/libretro-common/include/file/config_file.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (config_file.h). diff --git a/libretro-common/include/file/config_file_userdata.h b/libretro-common/include/file/config_file_userdata.h index 0c433ed..ca6f691 100644 --- a/libretro-common/include/file/config_file_userdata.h +++ b/libretro-common/include/file/config_file_userdata.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (config_file_userdata.h). diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 85f190c..89321c8 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_path.h). @@ -432,7 +432,7 @@ void path_basedir_wrapper(char *path); #endif /** - * path_default_slash: + * path_default_slash and path_default_slash_c: * * Gets the default slash separator. * @@ -440,8 +440,10 @@ void path_basedir_wrapper(char *path); */ #ifdef _WIN32 #define path_default_slash() "\\" +#define path_default_slash_c() '\\' #else #define path_default_slash() "/" +#define path_default_slash_c() '/' #endif /** @@ -454,7 +456,7 @@ void path_basedir_wrapper(char *path); **/ void fill_pathname_slash(char *path, size_t size); -#ifndef RARCH_CONSOLE +#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) void fill_pathname_application_path(char *buf, size_t size); #endif diff --git a/libretro-common/include/file/nbio.h b/libretro-common/include/file/nbio.h index 554bd11..4b5e5a4 100644 --- a/libretro-common/include/file/nbio.h +++ b/libretro-common/include/file/nbio.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (nbio.h). diff --git a/libretro-common/include/filters.h b/libretro-common/include/filters.h index 53743bb..69048ef 100644 --- a/libretro-common/include/filters.h +++ b/libretro-common/include/filters.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (filters.h). diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index bba8866..20a3c80 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (image.h). diff --git a/libretro-common/include/formats/jsonsax.h b/libretro-common/include/formats/jsonsax.h index d8b18e6..c98331f 100644 --- a/libretro-common/include/formats/jsonsax.h +++ b/libretro-common/include/formats/jsonsax.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (jsonsax.h). diff --git a/libretro-common/include/formats/rbmp.h b/libretro-common/include/formats/rbmp.h index 622d8c9..9b3a908 100644 --- a/libretro-common/include/formats/rbmp.h +++ b/libretro-common/include/formats/rbmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rbmp.h). diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index a999516..ed4ee3e 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rjpeg.h). diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index b16a830..aeae7af 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rpng.h). diff --git a/libretro-common/include/formats/rtga.h b/libretro-common/include/formats/rtga.h index a66f4a0..1b9409c 100644 --- a/libretro-common/include/formats/rtga.h +++ b/libretro-common/include/formats/rtga.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rtga.h). diff --git a/libretro-common/include/formats/rwav.h b/libretro-common/include/formats/rwav.h index 3f4ed17..198d24b 100644 --- a/libretro-common/include/formats/rwav.h +++ b/libretro-common/include/formats/rwav.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rwav.h). diff --git a/libretro-common/include/formats/rxml.h b/libretro-common/include/formats/rxml.h index 13bceba..78d01a2 100644 --- a/libretro-common/include/formats/rxml.h +++ b/libretro-common/include/formats/rxml.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml.h). diff --git a/libretro-common/include/gfx/gl_capabilities.h b/libretro-common/include/gfx/gl_capabilities.h index 4e7c97a..c71352e 100644 --- a/libretro-common/include/gfx/gl_capabilities.h +++ b/libretro-common/include/gfx/gl_capabilities.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (gl_capabilities.h). diff --git a/libretro-common/include/gfx/math/matrix_3x3.h b/libretro-common/include/gfx/math/matrix_3x3.h index 9bdd886..791f1da 100644 --- a/libretro-common/include/gfx/math/matrix_3x3.h +++ b/libretro-common/include/gfx/math/matrix_3x3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (matrix_3x3.h). diff --git a/libretro-common/include/gfx/math/matrix_4x4.h b/libretro-common/include/gfx/math/matrix_4x4.h index de5244e..dacb37c 100644 --- a/libretro-common/include/gfx/math/matrix_4x4.h +++ b/libretro-common/include/gfx/math/matrix_4x4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (matrix_4x4.h). diff --git a/libretro-common/include/gfx/math/vector_2.h b/libretro-common/include/gfx/math/vector_2.h index 1265c6d..a38153e 100644 --- a/libretro-common/include/gfx/math/vector_2.h +++ b/libretro-common/include/gfx/math/vector_2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (vector_2.h). diff --git a/libretro-common/include/gfx/math/vector_3.h b/libretro-common/include/gfx/math/vector_3.h index 6725617..40c9f7f 100644 --- a/libretro-common/include/gfx/math/vector_3.h +++ b/libretro-common/include/gfx/math/vector_3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (vector_3.h). diff --git a/libretro-common/include/gfx/math/vector_4.h b/libretro-common/include/gfx/math/vector_4.h index 3b9510c..e985649 100644 --- a/libretro-common/include/gfx/math/vector_4.h +++ b/libretro-common/include/gfx/math/vector_4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (vector_4.h). diff --git a/libretro-common/include/gfx/scaler/filter.h b/libretro-common/include/gfx/scaler/filter.h index ba5ae93..27f677a 100644 --- a/libretro-common/include/gfx/scaler/filter.h +++ b/libretro-common/include/gfx/scaler/filter.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (filter.h). diff --git a/libretro-common/include/gfx/scaler/pixconv.h b/libretro-common/include/gfx/scaler/pixconv.h index 6dfab47..100864d 100644 --- a/libretro-common/include/gfx/scaler/pixconv.h +++ b/libretro-common/include/gfx/scaler/pixconv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (pixconv.h). diff --git a/libretro-common/include/gfx/scaler/scaler.h b/libretro-common/include/gfx/scaler/scaler.h index 8d97515..97854d4 100644 --- a/libretro-common/include/gfx/scaler/scaler.h +++ b/libretro-common/include/gfx/scaler/scaler.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (scaler.h). diff --git a/libretro-common/include/gfx/scaler/scaler_int.h b/libretro-common/include/gfx/scaler/scaler_int.h index 87ef68e..2cb203a 100644 --- a/libretro-common/include/gfx/scaler/scaler_int.h +++ b/libretro-common/include/gfx/scaler/scaler_int.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (scaler_int.h). diff --git a/libretro-common/include/gfx/video_frame.h b/libretro-common/include/gfx/video_frame.h index 4b0f7d1..c00dc81 100644 --- a/libretro-common/include/gfx/video_frame.h +++ b/libretro-common/include/gfx/video_frame.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (video_frame.h). @@ -34,13 +34,15 @@ RETRO_BEGIN_DECLS #define scaler_ctx_scale_direct(ctx, output, input) \ - if (ctx->unscaled) \ +{ \ + if (ctx && ctx->unscaled && ctx->direct_pixconv) \ /* Just perform straight pixel conversion. */ \ ctx->direct_pixconv(output, input, \ - ctx->out_width, ctx->out_height, \ + ctx->out_width, ctx->out_height, \ ctx->out_stride, ctx->in_stride); \ else \ - scaler_ctx_scale(ctx, output, input) + scaler_ctx_scale(ctx, output, input); \ +} static INLINE void video_frame_convert_rgb16_to_rgb32( struct scaler_ctx *scaler, diff --git a/libretro-common/include/glsm/glsm.h b/libretro-common/include/glsm/glsm.h index 8e30acd..d422267 100644 --- a/libretro-common/include/glsm/glsm.h +++ b/libretro-common/include/glsm/glsm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsm.h). diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 215f3ec..3611441 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsmsym.h). diff --git a/libretro-common/include/glsym/glsym.h b/libretro-common/include/glsym/glsym.h index c1c13e2..24f4584 100644 --- a/libretro-common/include/glsym/glsym.h +++ b/libretro-common/include/glsym/glsym.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsym). diff --git a/libretro-common/include/glsym/glsym_gl.h b/libretro-common/include/glsym/glsym_gl.h index 9720c2e..1934287 100644 --- a/libretro-common/include/glsym/glsym_gl.h +++ b/libretro-common/include/glsym/glsym_gl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsym). diff --git a/libretro-common/include/glsym/rglgen.h b/libretro-common/include/glsym/rglgen.h index 54dcb62..b8a1a0c 100644 --- a/libretro-common/include/glsym/rglgen.h +++ b/libretro-common/include/glsym/rglgen.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsym). diff --git a/libretro-common/include/glsym/rglgen_headers.h b/libretro-common/include/glsym/rglgen_headers.h index 06d8530..766efb6 100644 --- a/libretro-common/include/glsym/rglgen_headers.h +++ b/libretro-common/include/glsym/rglgen_headers.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro SDK code part (glsym). diff --git a/libretro-common/include/libchdr/chd.h b/libretro-common/include/libchdr/chd.h index 1a33e0c..5180d8e 100644 --- a/libretro-common/include/libchdr/chd.h +++ b/libretro-common/include/libchdr/chd.h @@ -47,6 +47,7 @@ extern "C" { #endif #include "coretypes.h" +#include /*************************************************************************** @@ -347,15 +348,18 @@ struct _chd_verify_result /* chd_error chd_create_file(core_file *file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); */ /* open an existing CHD file */ -chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd); +chd_error chd_open_file(RFILE *file, int mode, chd_file *parent, chd_file **chd); + chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd); +/* precache underlying file */ +chd_error chd_precache(chd_file *chd); /* close a CHD file */ void chd_close(chd_file *chd); /* return the associated core_file */ -core_file *chd_core_file(chd_file *chd); +RFILE *chd_core_file(chd_file *chd); /* return an error string for the given CHD error */ const char *chd_error_string(chd_error err); diff --git a/libretro-common/include/libchdr/coretypes.h b/libretro-common/include/libchdr/coretypes.h index 5a769f6..2a68a8a 100644 --- a/libretro-common/include/libchdr/coretypes.h +++ b/libretro-common/include/libchdr/coretypes.h @@ -3,8 +3,7 @@ #include #include - -#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) +#include typedef uint64_t UINT64; #ifndef OSD_CPU_H @@ -20,11 +19,4 @@ typedef int16_t INT16; typedef int8_t INT8; #endif -#define core_file FILE -#define core_fopen(file) fopen(file, "rb") -#define core_fseek fseek -#define core_fread(fc, buff, len) fread(buff, 1, len, fc) -#define core_fclose fclose -#define core_ftell ftell - #endif diff --git a/libretro-common/include/libco.h b/libretro-common/include/libco.h index 1599cb2..851b29c 100644 --- a/libretro-common/include/libco.h +++ b/libretro-common/include/libco.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (libco.h). diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index e15403d..654c799 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro API header (libretro.h). @@ -599,9 +599,12 @@ enum retro_mod * GET_VARIABLE. * This allows the frontend to present these variables to * a user dynamically. - * This should be called as early as possible (ideally in - * retro_set_environment). - * + * This should be called the first time as early as + * possible (ideally in retro_set_environment). + * Afterward it may be called again for the core to communicate + * updated options to the frontend, but the number of core + * options must not change from the number in the initial call. + * * 'data' points to an array of retro_variable structs * terminated by a { NULL, NULL } element. * retro_variable::key should be namespaced to not collide @@ -1088,8 +1091,12 @@ struct retro_vfs_interface_info enum retro_hw_render_interface_type { - RETRO_HW_RENDER_INTERFACE_VULKAN = 0, - RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX + RETRO_HW_RENDER_INTERFACE_VULKAN = 0, + RETRO_HW_RENDER_INTERFACE_D3D9 = 1, + RETRO_HW_RENDER_INTERFACE_D3D10 = 2, + RETRO_HW_RENDER_INTERFACE_D3D11 = 3, + RETRO_HW_RENDER_INTERFACE_D3D12 = 4, + RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX }; /* Base struct. All retro_hw_render_interface_* types @@ -1103,7 +1110,7 @@ struct retro_hw_render_interface #define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL) /* struct retro_led_interface * -- - * Gets an interface which is used by a libretro core to set + * Gets an interface which is used by a libretro core to set * state of LEDs. */ @@ -1113,6 +1120,47 @@ struct retro_led_interface retro_set_led_state_t set_led_state; }; +#define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* int * -- + * Tells the core if the frontend wants audio or video. + * If disabled, the frontend will discard the audio or video, + * so the core may decide to skip generating a frame or generating audio. + * This is mainly used for increasing performance. + * Bit 0 (value 1): Enable Video + * Bit 1 (value 2): Enable Audio + * Bit 2 (value 4): Use Fast Savestates. + * Bit 3 (value 8): Hard Disable Audio + * Other bits are reserved for future use and will default to zero. + * If video is disabled: + * * The frontend wants the core to not generate any video, + * including presenting frames via hardware acceleration. + * * The frontend's video frame callback will do nothing. + * * After running the frame, the video output of the next frame should be + * no different than if video was enabled, and saving and loading state + * should have no issues. + * If audio is disabled: + * * The frontend wants the core to not generate any audio. + * * The frontend's audio callbacks will do nothing. + * * After running the frame, the audio output of the next frame should be + * no different than if audio was enabled, and saving and loading state + * should have no issues. + * Fast Savestates: + * * Guaranteed to be created by the same binary that will load them. + * * Will not be written to or read from the disk. + * * Suggest that the core assumes loading state will succeed. + * * Suggest that the core updates its memory buffers in-place if possible. + * * Suggest that the core skips clearing memory. + * * Suggest that the core skips resetting the system. + * * Suggest that the core may skip validation steps. + * Hard Disable Audio: + * * Used for a secondary core when running ahead. + * * Indicates that the frontend will never need audio from the core. + * * Suggests that the core may stop synthesizing audio, but this should not + * compromise emulation accuracy. + * * Audio output for the next frame does not matter, and the frontend will + * never need an accurate audio state in the future. + * * State will never be saved when using Hard Disable Audio. + */ #define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL) /* const struct retro_hw_render_interface ** -- @@ -1842,6 +1890,10 @@ enum retro_hw_context_type /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */ RETRO_HW_CONTEXT_VULKAN = 6, + /* Direct3D, set version_major to select the type of interface + * returned by RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */ + RETRO_HW_CONTEXT_DIRECT3D = 7, + RETRO_HW_CONTEXT_DUMMY = INT_MAX }; diff --git a/libretro-common/include/libretro_d3d.h b/libretro-common/include/libretro_d3d.h new file mode 100644 index 0000000..d95931b --- /dev/null +++ b/libretro-common/include/libretro_d3d.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2010-2018 The RetroArch team + * + * --------------------------------------------------------------------------------------------- + * The following license statement only applies to this libretro API header (libretro_d3d.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_DIRECT3D_H__ +#define LIBRETRO_DIRECT3D_H__ + +#include "libretro.h" + +#ifdef HAVE_D3D11 + +#include +#include + +#define RETRO_HW_RENDER_INTERFACE_D3D11_VERSION 1 + +struct retro_hw_render_interface_d3d11 +{ + /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D11. */ + enum retro_hw_render_interface_type interface_type; + /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D11_VERSION. */ + unsigned interface_version; + + /* Opaque handle to the d3d11 backend in the frontend + * which must be passed along to all function pointers + * in this interface. + */ + void* handle; + ID3D11Device *device; + ID3D11DeviceContext *context; + D3D_FEATURE_LEVEL featureLevel; + pD3DCompile D3DCompile; +}; + + +#endif + +#endif /* LIBRETRO_DIRECT3D_H__ */ diff --git a/libretro-common/include/libretro_dspfilter.h b/libretro-common/include/libretro_dspfilter.h index 4de515d..36bfd88 100644 --- a/libretro-common/include/libretro_dspfilter.h +++ b/libretro-common/include/libretro_dspfilter.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro API header (libretro_dspfilter.h). diff --git a/libretro-common/include/libretro_vulkan.h b/libretro-common/include/libretro_vulkan.h index e1005a1..5ae7187 100644 --- a/libretro-common/include/libretro_vulkan.h +++ b/libretro-common/include/libretro_vulkan.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------------- * The following license statement only applies to this libretro API header (libretro_vulkan.h) diff --git a/libretro-common/include/lists/dir_list.h b/libretro-common/include/lists/dir_list.h index 3b4a9c5..4babb02 100644 --- a/libretro-common/include/lists/dir_list.h +++ b/libretro-common/include/lists/dir_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (dir_list.h). diff --git a/libretro-common/include/lists/file_list.h b/libretro-common/include/lists/file_list.h index f6715a3..208bf15 100644 --- a/libretro-common/include/lists/file_list.h +++ b/libretro-common/include/lists/file_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_list.h). diff --git a/libretro-common/include/lists/string_list.h b/libretro-common/include/lists/string_list.h index c15cd0e..513876e 100644 --- a/libretro-common/include/lists/string_list.h +++ b/libretro-common/include/lists/string_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (string_list.h). diff --git a/libretro-common/include/math/complex.h b/libretro-common/include/math/complex.h index d7695c2..abfbfa6 100644 --- a/libretro-common/include/math/complex.h +++ b/libretro-common/include/math/complex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (complex.h). diff --git a/libretro-common/include/math/float_minmax.h b/libretro-common/include/math/float_minmax.h index d917ef8..2164dde 100644 --- a/libretro-common/include/math/float_minmax.h +++ b/libretro-common/include/math/float_minmax.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (float_minmax.h). diff --git a/libretro-common/include/math/fxp.h b/libretro-common/include/math/fxp.h index 56b036c..46f58ba 100644 --- a/libretro-common/include/math/fxp.h +++ b/libretro-common/include/math/fxp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fxp.h). diff --git a/libretro-common/include/memalign.h b/libretro-common/include/memalign.h index ca809f8..2c07a7c 100644 --- a/libretro-common/include/memalign.h +++ b/libretro-common/include/memalign.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (memalign.h). diff --git a/libretro-common/include/memmap.h b/libretro-common/include/memmap.h index 8d939c4..2bedd5c 100644 --- a/libretro-common/include/memmap.h +++ b/libretro-common/include/memmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (memmap.h). diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 7a182af..789f944 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_compat.h). diff --git a/libretro-common/include/net/net_http.h b/libretro-common/include/net/net_http.h index d312c74..f984627 100644 --- a/libretro-common/include/net/net_http.h +++ b/libretro-common/include/net/net_http.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_http.h). @@ -68,7 +68,11 @@ uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error); /* Cleans up all memory. */ void net_http_delete(struct http_t *state); -void net_http_urlencode_full(char **dest, const char *source); +/* URL Encode a string */ +void net_http_urlencode(char **dest, const char *source); + +/* Re-encode a full URL */ +void net_http_urlencode_full(char *dest, const char *source, size_t size); RETRO_END_DECLS diff --git a/libretro-common/include/net/net_http_parse.h b/libretro-common/include/net/net_http_parse.h index 4fc4845..6e957d3 100644 --- a/libretro-common/include/net/net_http_parse.h +++ b/libretro-common/include/net/net_http_parse.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_http.h). diff --git a/libretro-common/include/net/net_ifinfo.h b/libretro-common/include/net/net_ifinfo.h index 9949da2..b1d2535 100644 --- a/libretro-common/include/net/net_ifinfo.h +++ b/libretro-common/include/net/net_ifinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_ifinfo.h). diff --git a/libretro-common/include/net/net_natt.h b/libretro-common/include/net/net_natt.h index 9c8b3d7..a755480 100644 --- a/libretro-common/include/net/net_natt.h +++ b/libretro-common/include/net/net_natt.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_natt.h). diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 5d6dd87..098854e 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_socket.h). diff --git a/libretro-common/include/net/net_socket_ssl.h b/libretro-common/include/net/net_socket_ssl.h index c9ca75d..2691a2d 100644 --- a/libretro-common/include/net/net_socket_ssl.h +++ b/libretro-common/include/net/net_socket_ssl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_socket.h). diff --git a/libretro-common/include/queues/fifo_queue.h b/libretro-common/include/queues/fifo_queue.h index f1a3cae..b9c22e7 100644 --- a/libretro-common/include/queues/fifo_queue.h +++ b/libretro-common/include/queues/fifo_queue.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fifo_queue.h). diff --git a/libretro-common/include/queues/message_queue.h b/libretro-common/include/queues/message_queue.h index 2339e93..760ba27 100644 --- a/libretro-common/include/queues/message_queue.h +++ b/libretro-common/include/queues/message_queue.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (message_queue.h). diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index 8e25cc4..40c35dd 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (task_queue.h). diff --git a/libretro-common/include/retro_assert.h b/libretro-common/include/retro_assert.h index 3ef0300..9f3abde 100644 --- a/libretro-common/include/retro_assert.h +++ b/libretro-common/include/retro_assert.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_assert.h). diff --git a/libretro-common/include/retro_common.h b/libretro-common/include/retro_common.h index 5938bea..e4804fa 100644 --- a/libretro-common/include/retro_common.h +++ b/libretro-common/include/retro_common.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_common.h). diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h index ff38f98..c3b3f49 100644 --- a/libretro-common/include/retro_common_api.h +++ b/libretro-common/include/retro_common_api.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_common_api.h). diff --git a/libretro-common/include/retro_dirent.h b/libretro-common/include/retro_dirent.h index 090076e..c345073 100644 --- a/libretro-common/include/retro_dirent.h +++ b/libretro-common/include/retro_dirent.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_dirent.h). @@ -32,6 +32,16 @@ RETRO_BEGIN_DECLS typedef struct RDIR RDIR; +/** + * + * retro_opendir: + * @name : path to the directory to open. + * + * Opens a directory for reading. Tidy up with retro_closedir. + * + * Returns: RDIR pointer on success, NULL if name is not a + * valid directory, null itself or the empty string. + */ struct RDIR *retro_opendir(const char *name); int retro_readdir(struct RDIR *rdir); diff --git a/libretro-common/include/retro_endianness.h b/libretro-common/include/retro_endianness.h index fc9299e..e721ec9 100644 --- a/libretro-common/include/retro_endianness.h +++ b/libretro-common/include/retro_endianness.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_endianness.h). diff --git a/libretro-common/include/retro_environment.h b/libretro-common/include/retro_environment.h index 12ee429..1a18cd6 100644 --- a/libretro-common/include/retro_environment.h +++ b/libretro-common/include/retro_environment.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_environment.h). diff --git a/libretro-common/include/retro_inline.h b/libretro-common/include/retro_inline.h index ffdaa4a..e4a21f6 100644 --- a/libretro-common/include/retro_inline.h +++ b/libretro-common/include/retro_inline.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_inline.h). diff --git a/libretro-common/include/retro_math.h b/libretro-common/include/retro_math.h index c0efb23..03d31dd 100644 --- a/libretro-common/include/retro_math.h +++ b/libretro-common/include/retro_math.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_math.h). diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 23f9ef0..afcb885 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_miscellaneous.h). diff --git a/libretro-common/include/retro_stat.h b/libretro-common/include/retro_stat.h deleted file mode 100644 index 6429bb6..0000000 --- a/libretro-common/include/retro_stat.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2010-2015 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (retro_stat.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 __RETRO_STAT_H -#define __RETRO_STAT_H - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * path_is_directory: - * @path : path - * - * Checks if path is a directory. - * - * Returns: true (1) if path is a directory, otherwise false (0). - */ -bool path_is_directory(const char *path); - -bool path_is_character_special(const char *path); - -bool path_is_valid(const char *path); - -int32_t path_get_size(const char *path); - -/** - * path_mkdir_norecurse: - * @dir : directory - * - * Create directory on filesystem. - * - * Returns: true (1) if directory could be created, otherwise false (0). - **/ -bool mkdir_norecurse(const char *dir); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index 0cd4b4c..e56e18f 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_timers.h). diff --git a/libretro-common/include/rhash.h b/libretro-common/include/rhash.h index d739488..6ed9149 100644 --- a/libretro-common/include/rhash.h +++ b/libretro-common/include/rhash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rhash.h). diff --git a/libretro-common/include/rthreads/rthreads.h b/libretro-common/include/rthreads/rthreads.h index c9448ec..6e248f3 100644 --- a/libretro-common/include/rthreads/rthreads.h +++ b/libretro-common/include/rthreads/rthreads.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rthreads.h). diff --git a/libretro-common/include/streams/chd_stream.h b/libretro-common/include/streams/chd_stream.h index 2f51cae..246a2dc 100644 --- a/libretro-common/include/streams/chd_stream.h +++ b/libretro-common/include/streams/chd_stream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (chd_stream.h). @@ -49,11 +49,13 @@ int chdstream_getc(chdstream_t *stream); char *chdstream_gets(chdstream_t *stream, char *buffer, size_t len); -size_t chdstream_tell(chdstream_t *stream); +uint64_t chdstream_tell(chdstream_t *stream); void chdstream_rewind(chdstream_t *stream); -int chdstream_seek(chdstream_t *stream, ssize_t offset, int whence); +int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence); + +ssize_t chdstream_get_size(chdstream_t *stream); RETRO_END_DECLS diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index fba803c..546fd12 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_stream.h). @@ -60,19 +60,19 @@ int64_t filestream_get_size(RFILE *stream); **/ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints); -ssize_t filestream_seek(RFILE *stream, ssize_t offset, int seek_position); +int64_t filestream_seek(RFILE *stream, int64_t offset, int seek_position); -ssize_t filestream_read(RFILE *stream, void *data, int64_t len); +int64_t filestream_read(RFILE *stream, void *data, int64_t len); -ssize_t filestream_write(RFILE *stream, const void *data, int64_t len); +int64_t filestream_write(RFILE *stream, const void *data, int64_t len); -ssize_t filestream_tell(RFILE *stream); +int64_t filestream_tell(RFILE *stream); void filestream_rewind(RFILE *stream); int filestream_close(RFILE *stream); -int filestream_read_file(const char *path, void **buf, ssize_t *len); +int64_t filestream_read_file(const char *path, void **buf, int64_t *len); char *filestream_gets(RFILE *stream, char *s, size_t len); @@ -80,7 +80,7 @@ int filestream_getc(RFILE *stream); int filestream_eof(RFILE *stream); -bool filestream_write_file(const char *path, const void *data, ssize_t size); +bool filestream_write_file(const char *path, const void *data, int64_t size); int filestream_putc(RFILE *stream, int c); diff --git a/libretro-common/include/streams/file_stream_transforms.h b/libretro-common/include/streams/file_stream_transforms.h index 0cd565b..c1690fa 100644 --- a/libretro-common/include/streams/file_stream_transforms.h +++ b/libretro-common/include/streams/file_stream_transforms.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_stream_transforms.h). @@ -23,9 +23,10 @@ #ifndef __LIBRETRO_SDK_FILE_STREAM_TRANSFORMS_H #define __LIBRETRO_SDK_FILE_STREAM_TRANSFORMS_H +#include +#include #include #include -#include RETRO_BEGIN_DECLS @@ -61,19 +62,19 @@ RFILE* rfopen(const char *path, const char *mode); int rfclose(RFILE* stream); -long rftell(RFILE* stream); +int64_t rftell(RFILE* stream); -int rfseek(RFILE* stream, long offset, int origin); +int64_t rfseek(RFILE* stream, int64_t offset, int origin); -size_t rfread(void* buffer, - size_t elementSize, size_t elementCount, RFILE* stream); +int64_t rfread(void* buffer, + size_t elem_size, size_t elem_count, RFILE* stream); char *rfgets(char *buffer, int maxCount, RFILE* stream); int rfgetc(RFILE* stream); -size_t rfwrite(void const* buffer, - size_t elementSize, size_t elementCount, RFILE* stream); +int64_t rfwrite(void const* buffer, + size_t elem_size, size_t elem_count, RFILE* stream); int rfputc(int character, RFILE * stream); diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index 98c0d61..71d5c97 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (interface_stream.h). @@ -48,7 +48,7 @@ typedef struct intfstream_info struct { uint8_t *data; - unsigned size; + uint64_t size; } buf; bool writable; } memory; @@ -68,23 +68,23 @@ bool intfstream_resize(intfstream_internal_t *intf, bool intfstream_open(intfstream_internal_t *intf, const char *path, unsigned mode, unsigned hints); -ssize_t intfstream_read(intfstream_internal_t *intf, - void *s, size_t len); +int64_t intfstream_read(intfstream_internal_t *intf, + void *s, uint64_t len); -ssize_t intfstream_write(intfstream_internal_t *intf, - const void *s, size_t len); +int64_t intfstream_write(intfstream_internal_t *intf, + const void *s, uint64_t len); char *intfstream_gets(intfstream_internal_t *intf, - char *buffer, size_t len); + char *buffer, uint64_t len); int intfstream_getc(intfstream_internal_t *intf); -int intfstream_seek(intfstream_internal_t *intf, - int offset, int whence); +int64_t intfstream_seek(intfstream_internal_t *intf, + int64_t offset, int whence); void intfstream_rewind(intfstream_internal_t *intf); -int intfstream_tell(intfstream_internal_t *intf); +int64_t intfstream_tell(intfstream_internal_t *intf); void intfstream_putc(intfstream_internal_t *intf, int c); @@ -98,7 +98,7 @@ intfstream_t* intfstream_open_file(const char *path, unsigned mode, unsigned hints); intfstream_t *intfstream_open_memory(void *data, - unsigned mode, unsigned hints, size_t size); + unsigned mode, unsigned hints, uint64_t size); intfstream_t *intfstream_open_chd_track(const char *path, unsigned mode, unsigned hints, int32_t track); diff --git a/libretro-common/include/streams/memory_stream.h b/libretro-common/include/streams/memory_stream.h index dca8e7a..c594808 100644 --- a/libretro-common/include/streams/memory_stream.h +++ b/libretro-common/include/streams/memory_stream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (memory_stream.h). @@ -36,9 +36,9 @@ memstream_t *memstream_open(unsigned writing); void memstream_close(memstream_t *stream); -size_t memstream_read(memstream_t *stream, void *data, size_t bytes); +uint64_t memstream_read(memstream_t *stream, void *data, uint64_t bytes); -size_t memstream_write(memstream_t *stream, const void *data, size_t bytes); +uint64_t memstream_write(memstream_t *stream, const void *data, uint64_t bytes); int memstream_getc(memstream_t *stream); @@ -46,15 +46,15 @@ void memstream_putc(memstream_t *stream, int c); char *memstream_gets(memstream_t *stream, char *buffer, size_t len); -size_t memstream_pos(memstream_t *stream); +uint64_t memstream_pos(memstream_t *stream); void memstream_rewind(memstream_t *stream); -int memstream_seek(memstream_t *stream, int offset, int whence); +int64_t memstream_seek(memstream_t *stream, int64_t offset, int whence); -void memstream_set_buffer(uint8_t *buffer, size_t size); +void memstream_set_buffer(uint8_t *buffer, uint64_t size); -size_t memstream_get_last_size(void); +uint64_t memstream_get_last_size(void); RETRO_END_DECLS diff --git a/libretro-common/include/streams/stdin_stream.h b/libretro-common/include/streams/stdin_stream.h index ce5ebe5..dda0296 100644 --- a/libretro-common/include/streams/stdin_stream.h +++ b/libretro-common/include/streams/stdin_stream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (stdin_stream.h). diff --git a/libretro-common/include/streams/trans_stream.h b/libretro-common/include/streams/trans_stream.h index 4023103..0a10368 100644 --- a/libretro-common/include/streams/trans_stream.h +++ b/libretro-common/include/streams/trans_stream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (trans_stream.h). diff --git a/libretro-common/include/string/stdstring.h b/libretro-common/include/string/stdstring.h index 23bf062..eb2954b 100644 --- a/libretro-common/include/string/stdstring.h +++ b/libretro-common/include/string/stdstring.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (stdstring.h). @@ -75,9 +75,28 @@ static INLINE void string_add_between_pairs(char *s, const char *str, #define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0) #define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0) +static INLINE bool string_is_equal_case_insensitive(const char *a, + const char *b) +{ + int result = 0; + const unsigned char *p1 = (const unsigned char*)a; + const unsigned char *p2 = (const unsigned char*)b; + + if (!a || !b) + return false; + if (p1 == p2) + return true; + + while ((result = tolower (*p1) - tolower (*p2++)) == 0) + if (*p1++ == '\0') + break; + + return (result == 0); +} + static INLINE bool string_is_equal_noncase(const char *a, const char *b) { - int result; + int result = 0; const unsigned char *p1 = (const unsigned char*)a; const unsigned char *p2 = (const unsigned char*)b; diff --git a/libretro-common/include/vfs/vfs_implementation.h b/libretro-common/include/vfs/vfs_implementation.h index 5ceae39..047b170 100644 --- a/libretro-common/include/vfs/vfs_implementation.h +++ b/libretro-common/include/vfs/vfs_implementation.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (vfs_implementation.h). diff --git a/libretro-common/lists/dir_list.c b/libretro-common/lists/dir_list.c index 73148c8..fc360f7 100644 --- a/libretro-common/lists/dir_list.c +++ b/libretro-common/lists/dir_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (dir_list.c). @@ -185,13 +185,16 @@ static int dir_list_read(const char *dir, bool is_dir = false; int ret = 0; const char *name = retro_dirent_get_name(entry); - const char *file_ext = path_get_extension(name); + const char *file_ext = ""; file_path[0] = '\0'; fill_pathname_join(file_path, dir, name, sizeof(file_path)); is_dir = retro_dirent_is_dir(entry, file_path); + if(!is_dir) + file_ext = path_get_extension(name); + if (!include_hidden) { if (*name == '.') @@ -200,7 +203,7 @@ static int dir_list_read(const char *dir, if(is_dir && recursive) { - if(strstr(name, ".") || strstr(name, "..")) + if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue; dir_list_read(file_path, list, ext_list, include_dirs, diff --git a/libretro-common/lists/file_list.c b/libretro-common/lists/file_list.c index c52523e..1525d88 100644 --- a/libretro-common/lists/file_list.c +++ b/libretro-common/lists/file_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_list.c). diff --git a/libretro-common/lists/string_list.c b/libretro-common/lists/string_list.c index a5cb4be..3a5fb96 100644 --- a/libretro-common/lists/string_list.c +++ b/libretro-common/lists/string_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (string_list.c). diff --git a/libretro-common/lists/vector_list.c b/libretro-common/lists/vector_list.c index 4b8c231..b8493c5 100644 --- a/libretro-common/lists/vector_list.c +++ b/libretro-common/lists/vector_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (vector_list.c). diff --git a/libretro-common/memmap/memalign.c b/libretro-common/memmap/memalign.c index 56d0c94..449d847 100644 --- a/libretro-common/memmap/memalign.c +++ b/libretro-common/memmap/memalign.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (memalign.c). diff --git a/libretro-common/memmap/memmap.c b/libretro-common/memmap/memmap.c index cda86ff..26d9ce0 100644 --- a/libretro-common/memmap/memmap.c +++ b/libretro-common/memmap/memmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (memmap.c). diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 1c3e6a3..86c1381 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_compat.c). @@ -213,7 +213,7 @@ int getaddrinfo_retro(const char *node, const char *service, in_addr->sin_family = host->h_addrtype; -#if defined(AF_INET6) && !defined(__CELLOS_LV2__) +#if defined(AF_INET6) && !defined(__CELLOS_LV2__) || defined(VITA) /* TODO/FIXME - In case we ever want to support IPv6 */ in_addr->sin_addr.s_addr = inet_addr(host->h_addr_list[0]); #else diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index fb40d89..9e916f7 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_http.c). @@ -33,6 +33,7 @@ #include #include #include +#include enum { @@ -97,12 +98,13 @@ void urlencode_lut_init() for (i = 0; i < 256; i++) { - urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' ? i : (i == ' ') ? '+' : 0; + urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' || i == '/' ? i : 0; } } -/* caller is responsible for deleting the destination buffer */ -void net_http_urlencode_full(char **dest, const char *source) +/* URL Encode a string + caller is responsible for deleting the destination buffer */ +void net_http_urlencode(char **dest, const char *source) { char *enc = NULL; /* Assume every character will be encoded, so we need 3 times the space. */ @@ -129,6 +131,38 @@ void net_http_urlencode_full(char **dest, const char *source) (*dest)[len - 1] = '\0'; } +/* Re-encode a full URL */ +void net_http_urlencode_full(char *dest, + const char *source, size_t size) +{ + char *tmp = NULL; + char url_domain[PATH_MAX_LENGTH] = {0}; + char url_path[PATH_MAX_LENGTH] = {0}; + int count = 0; + + strlcpy (url_path, source, sizeof(url_path)); + tmp = url_path; + + while (count < 3 && tmp[0] != '\0') + { + tmp = strchr(tmp, '/'); + count++; + tmp++; + } + + strlcpy(url_domain, source, tmp - url_path); + + strlcpy(url_path, + source + strlen(url_domain) + 1, + strlen(tmp) + 1 + ); + + tmp = NULL; + net_http_urlencode(&tmp, url_path); + snprintf(dest, size, "%s/%s", url_domain, tmp); + free (tmp); +} + static int net_http_new_socket(struct http_connection_t *conn) { int ret; diff --git a/libretro-common/net/net_http_parse.c b/libretro-common/net/net_http_parse.c index 69b80f6..113eeaa 100644 --- a/libretro-common/net/net_http_parse.c +++ b/libretro-common/net/net_http_parse.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_http_parse.c). diff --git a/libretro-common/net/net_ifinfo.c b/libretro-common/net/net_ifinfo.c index e226dda..77c5971 100644 --- a/libretro-common/net/net_ifinfo.c +++ b/libretro-common/net/net_ifinfo.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_ifinfo.c). diff --git a/libretro-common/net/net_natt.c b/libretro-common/net/net_natt.c index 34c6f1d..1924f4d 100644 --- a/libretro-common/net/net_natt.c +++ b/libretro-common/net/net_natt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2016-2017 The RetroArch team +/* Copyright (C) 2016-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_natt.c). diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 0c96036..e2213c9 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_socket.c). diff --git a/libretro-common/net/net_socket_ssl.c b/libretro-common/net/net_socket_ssl.c index 4b9da12..04e0bab 100644 --- a/libretro-common/net/net_socket_ssl.c +++ b/libretro-common/net/net_socket_ssl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_socket.c). diff --git a/libretro-common/queues/fifo_queue.c b/libretro-common/queues/fifo_queue.c index 85d0268..d6b21ac 100644 --- a/libretro-common/queues/fifo_queue.c +++ b/libretro-common/queues/fifo_queue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (fifo_queue.c). diff --git a/libretro-common/queues/message_queue.c b/libretro-common/queues/message_queue.c index dda5cbf..a8086c3 100644 --- a/libretro-common/queues/message_queue.c +++ b/libretro-common/queues/message_queue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (message_queue.c). diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 2d45f65..2eb51dd 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (task_queue.c). diff --git a/libretro-common/rthreads/ctr_pthread.h b/libretro-common/rthreads/ctr_pthread.h index 8c82e6e..0a393eb 100644 --- a/libretro-common/rthreads/ctr_pthread.h +++ b/libretro-common/rthreads/ctr_pthread.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (gx_pthread.h). diff --git a/libretro-common/rthreads/gx_pthread.h b/libretro-common/rthreads/gx_pthread.h index 8cb4616..055c6af 100644 --- a/libretro-common/rthreads/gx_pthread.h +++ b/libretro-common/rthreads/gx_pthread.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (gx_pthread.h). diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index bddf2f4..e155075 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rthreads.c). @@ -76,6 +76,7 @@ struct sthread { #ifdef USE_WIN32_THREADS HANDLE thread; + DWORD id; #else pthread_t id; #endif @@ -161,9 +162,7 @@ sthread_t *sthread_create(void (*thread_func)(void*), void *userdata) bool thread_created = false; struct thread_data *data = NULL; sthread_t *thread = (sthread_t*)calloc(1, sizeof(*thread)); -#if defined(_WIN32_WINNT) && _WIN32_WINNT <= 0x0410 - DWORD thread_id = 0; -#endif + if (!thread) return NULL; @@ -175,11 +174,7 @@ sthread_t *sthread_create(void (*thread_func)(void*), void *userdata) data->userdata = userdata; #ifdef USE_WIN32_THREADS -#if defined(_WIN32_WINNT) && _WIN32_WINNT <= 0x0410 - thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, &thread_id); -#else - thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, NULL); -#endif + thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, &thread->id); thread_created = !!thread->thread; #else #if defined(VITA) @@ -259,10 +254,11 @@ void sthread_join(sthread_t *thread) bool sthread_isself(sthread_t *thread) { /* This thread can't possibly be a null thread */ - if (!thread) return false; + if (!thread) + return false; #ifdef USE_WIN32_THREADS - return GetCurrentThread() == thread->thread; + return GetCurrentThreadId() == thread->id; #else return pthread_equal(pthread_self(),thread->id); #endif diff --git a/libretro-common/rthreads/xenon_sdl_threads.c b/libretro-common/rthreads/xenon_sdl_threads.c index 0097673..ff1855c 100644 --- a/libretro-common/rthreads/xenon_sdl_threads.c +++ b/libretro-common/rthreads/xenon_sdl_threads.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (xenon_sdl_threads.c). diff --git a/libretro-common/samples/net/Makefile b/libretro-common/samples/net/Makefile index 9ef1c56..e447590 100644 --- a/libretro-common/samples/net/Makefile +++ b/libretro-common/samples/net/Makefile @@ -4,6 +4,21 @@ LIBRETRO_COMM_DIR := ../.. INCFLAGS = -I$(LIBRETRO_COMM_DIR)/include +ifeq ($(platform),) +platform = unix +ifeq ($(shell uname -a),) + platform = win +else ifneq ($(findstring Darwin,$(shell uname -a)),) + platform = osx + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc +endif +else ifneq ($(findstring MINGW,$(shell uname -a)),) + platform = win +endif +endif + ifeq ($(DEBUG),1) CFLAGS += -O0 -g else @@ -16,6 +31,7 @@ HTTP_TEST_C = \ $(LIBRETRO_COMM_DIR)/net/net_compat.c \ $(LIBRETRO_COMM_DIR)/net/net_socket.c \ $(LIBRETRO_COMM_DIR)/compat/compat_strl.c \ + $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \ $(LIBRETRO_COMM_DIR)/string/stdstring.c \ net_http_test.c @@ -25,6 +41,10 @@ NET_IFINFO_C = \ $(LIBRETRO_COMM_DIR)/net/net_ifinfo.c \ net_ifinfo_test.c +ifeq ($(platform), win) +CFLAGS += -liphlpapi -lws2_32 +endif + NET_IFINFO_OBJS := $(NET_IFINFO_C:.c=.o) .PHONY: all clean diff --git a/libretro-common/samples/net/net_http_test.c b/libretro-common/samples/net/net_http_test.c index 8df530b..448c6db 100644 --- a/libretro-common/samples/net/net_http_test.c +++ b/libretro-common/samples/net/net_http_test.c @@ -37,7 +37,7 @@ int main(void) if (!network_init()) return -1; - http1 = net_http_new("http://buildbot.libretro.com/nightly/win-x86/latest/mednafen_psx_libretro.dll.zip"); + http1 = net_http_new("http://buildbot.libretro.com/nightly/windows/x86_64/latest/mednafen_psx_libretro.dll.zip"); while (!net_http_update(http1, &pos, &tot)) printf("%.9lu / %.9lu \r",pos,tot); diff --git a/libretro-common/streams/chd_stream.c b/libretro-common/streams/chd_stream.c index 1449b91..669bd43 100644 --- a/libretro-common/streams/chd_stream.c +++ b/libretro-common/streams/chd_stream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (chd_stream.c). @@ -23,7 +23,8 @@ #include #include #include -#include + +#include #include #include @@ -385,7 +386,7 @@ char *chdstream_gets(chdstream_t *stream, char *buffer, size_t len) return buffer; } -size_t chdstream_tell(chdstream_t *stream) +uint64_t chdstream_tell(chdstream_t *stream) { return stream->offset; } @@ -395,9 +396,9 @@ void chdstream_rewind(chdstream_t *stream) stream->offset = 0; } -int chdstream_seek(chdstream_t *stream, ssize_t offset, int whence) +int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence) { - ssize_t new_offset; + int64_t new_offset; switch (whence) { @@ -423,3 +424,8 @@ int chdstream_seek(chdstream_t *stream, ssize_t offset, int whence) stream->offset = new_offset; return 0; } + +ssize_t chdstream_get_size(chdstream_t *stream) +{ + return stream->track_end; +} diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index cc062f4..5ccdbcf 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_stream.c). @@ -191,7 +191,7 @@ int filestream_getc(RFILE *stream) return EOF; } -ssize_t filestream_seek(RFILE *stream, ssize_t offset, int seek_position) +int64_t filestream_seek(RFILE *stream, int64_t offset, int seek_position) { int64_t output; @@ -213,9 +213,9 @@ int filestream_eof(RFILE *stream) } -ssize_t filestream_tell(RFILE *stream) +int64_t filestream_tell(RFILE *stream) { - ssize_t output; + int64_t output; if (filestream_size_cb != NULL) output = filestream_tell_cb(stream->hfile); @@ -237,7 +237,7 @@ void filestream_rewind(RFILE *stream) stream->eof_flag = false; } -ssize_t filestream_read(RFILE *stream, void *s, int64_t len) +int64_t filestream_read(RFILE *stream, void *s, int64_t len) { int64_t output; @@ -294,7 +294,7 @@ const char *filestream_get_path(RFILE *stream) return retro_vfs_file_get_path_impl((libretro_vfs_implementation_file*)stream->hfile); } -ssize_t filestream_write(RFILE *stream, const void *s, int64_t len) +int64_t filestream_write(RFILE *stream, const void *s, int64_t len) { int64_t output; @@ -320,14 +320,14 @@ int filestream_putc(RFILE *stream, int c) int filestream_vprintf(RFILE *stream, const char* format, va_list args) { static char buffer[8 * 1024]; - int num_chars = vsprintf(buffer, format, args); + int64_t num_chars = vsprintf(buffer, format, args); if (num_chars < 0) return -1; else if (num_chars == 0) return 0; - return filestream_write(stream, buffer, num_chars); + return (int)filestream_write(stream, buffer, num_chars); } int filestream_printf(RFILE *stream, const char* format, ...) @@ -373,9 +373,9 @@ int filestream_close(RFILE *stream) * * Returns: number of items read, -1 on error. */ -int filestream_read_file(const char *path, void **buf, ssize_t *len) +int64_t filestream_read_file(const char *path, void **buf, int64_t *len) { - ssize_t ret = 0; + int64_t ret = 0; int64_t content_buf_size = 0; void *content_buf = NULL; RFILE *file = filestream_open(path, @@ -397,7 +397,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) if (!content_buf) goto error; - if ((int64_t)(size_t)(content_buf_size + 1) != (content_buf_size + 1)) + if ((int64_t)(uint64_t)(content_buf_size + 1) != (content_buf_size + 1)) goto error; ret = filestream_read(file, content_buf, (int64_t)content_buf_size); @@ -441,9 +441,9 @@ error: * * Returns: true (1) on success, false (0) otherwise. */ -bool filestream_write_file(const char *path, const void *data, ssize_t size) +bool filestream_write_file(const char *path, const void *data, int64_t size) { - ssize_t ret = 0; + int64_t ret = 0; RFILE *file = filestream_open(path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); diff --git a/libretro-common/streams/file_stream_transforms.c b/libretro-common/streams/file_stream_transforms.c index 8796073..efeb7ed 100644 --- a/libretro-common/streams/file_stream_transforms.c +++ b/libretro-common/streams/file_stream_transforms.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (file_stream_transforms.c). @@ -72,12 +72,12 @@ int rfclose(RFILE* stream) return filestream_close(stream); } -long rftell(RFILE* stream) +int64_t rftell(RFILE* stream) { return filestream_tell(stream); } -int rfseek(RFILE* stream, long offset, int origin) +int64_t rfseek(RFILE* stream, int64_t offset, int origin) { int seek_position = -1; switch (origin) @@ -96,7 +96,7 @@ int rfseek(RFILE* stream, long offset, int origin) return filestream_seek(stream, offset, seek_position); } -size_t rfread(void* buffer, +int64_t rfread(void* buffer, size_t elem_size, size_t elem_count, RFILE* stream) { return filestream_read(stream, buffer, elem_size * elem_count); @@ -112,7 +112,7 @@ int rfgetc(RFILE* stream) return filestream_getc(stream); } -size_t rfwrite(void const* buffer, +int64_t rfwrite(void const* buffer, size_t elem_size, size_t elem_count, RFILE* stream) { return filestream_write(stream, buffer, elem_size * elem_count); diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index 5edb5fd..0207823 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (interface_stream.c). @@ -43,7 +43,7 @@ struct intfstream_internal struct { uint8_t *data; - unsigned size; + uint64_t size; } buf; memstream_t *fp; bool writable; @@ -69,8 +69,11 @@ int64_t intfstream_get_size(intfstream_internal_t *intf) case INTFSTREAM_MEMORY: return intf->memory.buf.size; case INTFSTREAM_CHD: - /* TODO/FIXME - implement this */ - break; +#ifdef HAVE_CHD + return chdstream_get_size(intf->chd.fp); +#else + break; +#endif } return 0; @@ -216,7 +219,7 @@ error: return NULL; } -int intfstream_seek(intfstream_internal_t *intf, int offset, int whence) +int64_t intfstream_seek(intfstream_internal_t *intf, int64_t offset, int whence) { if (!intf) return -1; @@ -238,14 +241,14 @@ int intfstream_seek(intfstream_internal_t *intf, int offset, int whence) seek_position = RETRO_VFS_SEEK_POSITION_END; break; } - return (int)filestream_seek(intf->file.fp, (int)offset, + return (int64_t)filestream_seek(intf->file.fp, (int64_t)offset, seek_position); } case INTFSTREAM_MEMORY: - return (int)memstream_seek(intf->memory.fp, offset, whence); + return (int64_t)memstream_seek(intf->memory.fp, offset, whence); case INTFSTREAM_CHD: #ifdef HAVE_CHD - return (int)chdstream_seek(intf->chd.fp, offset, whence); + return (int64_t)chdstream_seek(intf->chd.fp, offset, whence); #else break; #endif @@ -254,7 +257,7 @@ int intfstream_seek(intfstream_internal_t *intf, int offset, int whence) return -1; } -ssize_t intfstream_read(intfstream_internal_t *intf, void *s, size_t len) +int64_t intfstream_read(intfstream_internal_t *intf, void *s, uint64_t len) { if (!intf) return 0; @@ -276,8 +279,8 @@ ssize_t intfstream_read(intfstream_internal_t *intf, void *s, size_t len) return -1; } -ssize_t intfstream_write(intfstream_internal_t *intf, - const void *s, size_t len) +int64_t intfstream_write(intfstream_internal_t *intf, + const void *s, uint64_t len) { if (!intf) return 0; @@ -296,7 +299,7 @@ ssize_t intfstream_write(intfstream_internal_t *intf, } char *intfstream_gets(intfstream_internal_t *intf, - char *buffer, size_t len) + char *buffer, uint64_t len) { if (!intf) return NULL; @@ -304,9 +307,11 @@ char *intfstream_gets(intfstream_internal_t *intf, switch (intf->type) { case INTFSTREAM_FILE: - return filestream_gets(intf->file.fp, buffer, len); + return filestream_gets(intf->file.fp, + buffer, (size_t)len); case INTFSTREAM_MEMORY: - return memstream_gets(intf->memory.fp, buffer, len); + return memstream_gets(intf->memory.fp, + buffer, (size_t)len); case INTFSTREAM_CHD: #ifdef HAVE_CHD return chdstream_gets(intf->chd.fp, buffer, len); @@ -340,7 +345,7 @@ int intfstream_getc(intfstream_internal_t *intf) return -1; } -int intfstream_tell(intfstream_internal_t *intf) +int64_t intfstream_tell(intfstream_internal_t *intf) { if (!intf) return -1; @@ -348,12 +353,12 @@ int intfstream_tell(intfstream_internal_t *intf) switch (intf->type) { case INTFSTREAM_FILE: - return (int)filestream_tell(intf->file.fp); + return (int64_t)filestream_tell(intf->file.fp); case INTFSTREAM_MEMORY: - return (int)memstream_pos(intf->memory.fp); + return (int64_t)memstream_pos(intf->memory.fp); case INTFSTREAM_CHD: #ifdef HAVE_CHD - return (int)chdstream_tell(intf->chd.fp); + return (int64_t)chdstream_tell(intf->chd.fp); #else break; #endif @@ -425,7 +430,7 @@ error: } intfstream_t *intfstream_open_memory(void *data, - unsigned mode, unsigned hints, size_t size) + unsigned mode, unsigned hints, uint64_t size) { intfstream_info_t info; intfstream_t *fd = NULL; diff --git a/libretro-common/streams/memory_stream.c b/libretro-common/streams/memory_stream.c index 0141012..77a2c00 100644 --- a/libretro-common/streams/memory_stream.c +++ b/libretro-common/streams/memory_stream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (memory_stream.c). @@ -26,16 +26,16 @@ #include -static uint8_t* g_buffer = NULL; -static size_t g_size = 0; -static size_t last_file_size = 0; +static uint8_t* g_buffer = NULL; +static uint64_t g_size = 0; +static uint64_t last_file_size = 0; struct memstream { uint8_t *buf; - size_t size; - size_t ptr; - size_t max_ptr; + uint64_t size; + uint64_t ptr; + uint64_t max_ptr; unsigned writing; }; @@ -45,19 +45,19 @@ static void memstream_update_pos(memstream_t *stream) stream->max_ptr = stream->ptr; } -void memstream_set_buffer(uint8_t *buffer, size_t size) +void memstream_set_buffer(uint8_t *buffer, uint64_t size) { g_buffer = buffer; g_size = size; } -size_t memstream_get_last_size(void) +uint64_t memstream_get_last_size(void) { return last_file_size; } static void memstream_init(memstream_t *stream, - uint8_t *buffer, size_t max_size, unsigned writing) + uint8_t *buffer, uint64_t max_size, unsigned writing) { if (!stream) return; @@ -92,9 +92,9 @@ void memstream_close(memstream_t *stream) free(stream); } -size_t memstream_read(memstream_t *stream, void *data, size_t bytes) +uint64_t memstream_read(memstream_t *stream, void *data, uint64_t bytes) { - size_t avail = 0; + uint64_t avail = 0; if (!stream) return 0; @@ -103,15 +103,15 @@ size_t memstream_read(memstream_t *stream, void *data, size_t bytes) if (bytes > avail) bytes = avail; - memcpy(data, stream->buf + stream->ptr, bytes); + memcpy(data, stream->buf + stream->ptr, (size_t)bytes); stream->ptr += bytes; memstream_update_pos(stream); return bytes; } -size_t memstream_write(memstream_t *stream, const void *data, size_t bytes) +uint64_t memstream_write(memstream_t *stream, const void *data, uint64_t bytes) { - size_t avail = 0; + uint64_t avail = 0; if (!stream) return 0; @@ -120,15 +120,15 @@ size_t memstream_write(memstream_t *stream, const void *data, size_t bytes) if (bytes > avail) bytes = avail; - memcpy(stream->buf + stream->ptr, data, bytes); + memcpy(stream->buf + stream->ptr, data, (size_t)bytes); stream->ptr += bytes; memstream_update_pos(stream); return bytes; } -int memstream_seek(memstream_t *stream, int offset, int whence) +int64_t memstream_seek(memstream_t *stream, int64_t offset, int whence) { - size_t ptr; + uint64_t ptr; switch (whence) { @@ -159,7 +159,7 @@ void memstream_rewind(memstream_t *stream) memstream_seek(stream, 0L, SEEK_SET); } -size_t memstream_pos(memstream_t *stream) +uint64_t memstream_pos(memstream_t *stream) { return stream->ptr; } diff --git a/libretro-common/streams/stdin_stream.c b/libretro-common/streams/stdin_stream.c index c30c0f4..6aedfae 100644 --- a/libretro-common/streams/stdin_stream.c +++ b/libretro-common/streams/stdin_stream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (stdin_stream.c). diff --git a/libretro-common/streams/trans_stream.c b/libretro-common/streams/trans_stream.c index 10eea45..92f3207 100644 --- a/libretro-common/streams/trans_stream.c +++ b/libretro-common/streams/trans_stream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (trans_stream.c). diff --git a/libretro-common/streams/trans_stream_pipe.c b/libretro-common/streams/trans_stream_pipe.c index f30d5df..5a2e076 100644 --- a/libretro-common/streams/trans_stream_pipe.c +++ b/libretro-common/streams/trans_stream_pipe.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (trans_stream_pipe.c). diff --git a/libretro-common/streams/trans_stream_zlib.c b/libretro-common/streams/trans_stream_zlib.c index ec35011..7f797f1 100644 --- a/libretro-common/streams/trans_stream_zlib.c +++ b/libretro-common/streams/trans_stream_zlib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (trans_stream_zlib.c). diff --git a/libretro-common/string/stdstring.c b/libretro-common/string/stdstring.c index 02f8dad..6e1555d 100644 --- a/libretro-common/string/stdstring.c +++ b/libretro-common/string/stdstring.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (stdstring.c). @@ -169,7 +169,7 @@ char *word_wrap(char* buffer, const char *string, int line_width, bool unicode) } character = utf8skip(&string[i], 1); - char_len = character - &string[i]; + char_len = (unsigned)(character - &string[i]); if (!unicode) counter += char_len - 1; diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index 1906ec5..ff8100f 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2017 The RetroArch team +/* Copyright (C) 2010-2018 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (vfs_implementation.c). @@ -123,7 +123,7 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i /* VC2005 and up have a special 64-bit fseek */ #ifdef ATLEAST_VC2005 return _fseeki64(stream->fp, offset, whence); -#elif defined(__CELLOS_LV2__) +#elif defined(__CELLOS_LV2__) || defined(_MSC_VER) && _MSC_VER <= 1310 return fseek(stream->fp, (long)offset, whence); #else return fseeko(stream->fp, (off_t)offset, whence); @@ -264,7 +264,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) { - FILE *fp = fopen_utf8(path, mode_str); + FILE *fp = (FILE*)fopen_utf8(path, mode_str); if (!fp) goto error;