mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-25 00:03:44 +02:00
Fix some libretro build errors for game consoles
This commit is contained in:
parent
d89c7894da
commit
322caeb628
6 changed files with 132 additions and 14 deletions
|
@ -2,4 +2,4 @@
|
|||
url = https://github.com/xiph/flac
|
||||
revision = 1.4.3
|
||||
depth = 1
|
||||
diff_files = flac-buildtype.patch, flac-deps.patch, flac-emscripten-endian.patch
|
||||
diff_files = flac-buildtype.patch, flac-deps.patch, flac-emscripten-endian.patch, flac-int32.patch
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
url = https://github.com/libsndfile/libsndfile
|
||||
revision = 1.2.2
|
||||
depth = 1
|
||||
diff_files = libsndfile-deps.patch, libsndfile-emscripten-endian.patch
|
||||
diff_files = libsndfile-deps.patch, libsndfile-emscripten-endian.patch, libsndfile-int32.patch
|
||||
|
|
23
subprojects/packagefiles/flac-int32.patch
Normal file
23
subprojects/packagefiles/flac-int32.patch
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Fixes a compilation error when using the devkitARM toolchain or Vita SDK toolchain to compile FLAC.
|
||||
# For some reason, there's no implicit casting between `int` and `int32_t` and between `unsigned int` and `uint32_t` in devkitARM or Vita SDK even though they're the same size, so we have to do this whole song and dance to appease the compiler.
|
||||
|
||||
--- a/src/libFLAC/stream_decoder.c
|
||||
+++ b/src/libFLAC/stream_decoder.c
|
||||
@@ -2973,7 +2973,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_
|
||||
if(rice_parameter < pesc) {
|
||||
partitioned_rice_contents->raw_bits[partition] = 0;
|
||||
u = (partition == 0) ? partition_samples - predictor_order : partition_samples;
|
||||
- if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter)){
|
||||
+ if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, (int *)(residual + sample), u, rice_parameter)){
|
||||
if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) {
|
||||
/* no error was set, read_callback_ didn't set it, so
|
||||
* invalid rice symbol was found */
|
||||
@@ -2996,7 +2996,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_
|
||||
}
|
||||
else{
|
||||
for(u = (partition == 0)? predictor_order : 0; u < partition_samples; u++, sample++) {
|
||||
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter))
|
||||
+ if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, (FLAC__int32 *)&i, rice_parameter))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
residual[sample] = i;
|
||||
}
|
63
subprojects/packagefiles/libsndfile-int32.patch
Normal file
63
subprojects/packagefiles/libsndfile-int32.patch
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Fixes a compilation error when using the devkitARM toolchain or Vita SDK toolchain to compile libsndfile.
|
||||
# For some reason, there's no implicit casting between `int` and `int32_t` and between `unsigned int` and `uint32_t` in devkitARM or Vita SDK even though they're the same size, so we have to do this whole song and dance to appease the compiler.
|
||||
|
||||
--- a/src/alac.c
|
||||
+++ b/src/alac.c
|
||||
@@ -427,7 +427,7 @@ alac_decode_block (SF_PRIVATE *psf, ALAC_PRIVATE *plac)
|
||||
|
||||
plac->input_data_pos += packet_size ;
|
||||
plac->frames_this_block = 0 ;
|
||||
- alac_decode (pdec, &bit_buffer, plac->buffer, plac->frames_per_block, &plac->frames_this_block) ;
|
||||
+ alac_decode (pdec, &bit_buffer, (int32_t *)plac->buffer, plac->frames_per_block, &plac->frames_this_block) ;
|
||||
|
||||
plac->partial_block_frames = 0 ;
|
||||
|
||||
@@ -440,7 +440,7 @@ alac_encode_block (ALAC_PRIVATE *plac)
|
||||
{ ALAC_ENCODER *penc = &plac->u.encoder ;
|
||||
uint32_t num_bytes = 0 ;
|
||||
|
||||
- alac_encode (penc, plac->partial_block_frames, plac->buffer, plac->byte_buffer, &num_bytes) ;
|
||||
+ alac_encode (penc, plac->partial_block_frames, (int32_t *)plac->buffer, plac->byte_buffer, &num_bytes) ;
|
||||
|
||||
if (fwrite (plac->byte_buffer, 1, num_bytes, plac->enctmp) != num_bytes)
|
||||
return 0 ;
|
||||
--- a/src/flac.c
|
||||
+++ b/src/flac.c
|
||||
@@ -132,7 +132,7 @@ static void sf_flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__St
|
||||
/* Encoder Callbacks */
|
||||
static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
|
||||
static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
|
||||
-static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ;
|
||||
+static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) ;
|
||||
|
||||
static void
|
||||
s2flac8_array (const short *src, int32_t *dest, int count)
|
||||
@@ -579,7 +579,7 @@ sf_flac_enc_tell_callback (const FLAC__StreamEncoder *UNUSED (encoder), FLAC__ui
|
||||
} /* sf_flac_enc_tell_callback */
|
||||
|
||||
static FLAC__StreamEncoderWriteStatus
|
||||
-sf_flac_enc_write_callback (const FLAC__StreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], size_t bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data)
|
||||
+sf_flac_enc_write_callback (const FLAC__StreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], size_t bytes, uint32_t UNUSED (samples), uint32_t UNUSED (current_frame), void *client_data)
|
||||
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
||||
|
||||
if (psf_fwrite (buffer, 1, bytes, psf) == (sf_count_t) bytes && psf->error == 0)
|
||||
--- a/src/ogg_opus.c
|
||||
+++ b/src/ogg_opus.c
|
||||
@@ -713,7 +713,7 @@ ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus
|
||||
oopus->header.nb_streams = nb_streams ;
|
||||
oopus->header.nb_coupled = nb_coupled ;
|
||||
|
||||
- opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_BITRATE (&oopus->u.encode.bitrate)) ;
|
||||
+ opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_BITRATE ((opus_int32 *)&oopus->u.encode.bitrate)) ;
|
||||
psf_log_printf (psf, "Encoding at target bitrate of %dbps\n", oopus->u.encode.bitrate) ;
|
||||
|
||||
/* TODO: Make configurable? */
|
||||
@@ -729,7 +729,7 @@ ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus
|
||||
** GOTCHA: This returns the preskip at the encoder samplerate, not the
|
||||
** granulepos rate of 48000Hz needed for header.preskip.
|
||||
*/
|
||||
- error = opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_LOOKAHEAD (&lookahead)) ;
|
||||
+ error = opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_LOOKAHEAD ((opus_int32 *)&lookahead)) ;
|
||||
if (error != OPUS_OK)
|
||||
{ psf_log_printf (psf, "Opus : OPUS_GET_LOOKAHEAD returned: %s\n", opus_strerror (error)) ;
|
||||
return SFE_BAD_OPEN_FORMAT ;
|
|
@ -2,61 +2,70 @@
|
|||
|
||||
--- a/common/althreads.h
|
||||
+++ b/common/althreads.h
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
-#else
|
||||
+#elif (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__)) && !defined(__DEVKITPPC__) && !defined(__vita__)
|
||||
|
||||
#include <threads.h>
|
||||
#endif
|
||||
@@ -107,29 +107,57 @@ public:
|
||||
|
||||
#else
|
||||
|
||||
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
+#if (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__)
|
||||
+ void **mTss;
|
||||
+#else
|
||||
tss_t mTss{};
|
||||
+#endif /* defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) */
|
||||
+#endif /* (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__) */
|
||||
|
||||
public:
|
||||
tss()
|
||||
{
|
||||
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
+#if (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__)
|
||||
+ if ((mTss = (void **)std::malloc(sizeof *mTss)) == NULL)
|
||||
+ throw std::runtime_error{"al::tss::tss()"};
|
||||
+ *mTss = nullptr;
|
||||
+#else
|
||||
if(int res{tss_create(&mTss, nullptr)}; res != thrd_success)
|
||||
throw std::runtime_error{"al::tss::tss()"};
|
||||
+#endif /* defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) */
|
||||
+#endif /* (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__) */
|
||||
}
|
||||
explicit tss(const T &init) : tss{}
|
||||
{
|
||||
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
+#if (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__)
|
||||
+ if ((mTss = (void **)std::malloc(sizeof *mTss)) == NULL)
|
||||
+ throw std::runtime_error{"al::tss::tss()"};
|
||||
+ *mTss = to_ptr(init);
|
||||
+#else
|
||||
if(int res{tss_set(mTss, to_ptr(init))}; res != thrd_success)
|
||||
throw std::runtime_error{"al::tss::tss(T)"};
|
||||
+#endif /* defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) */
|
||||
+#endif /* (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__) */
|
||||
}
|
||||
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
+#if (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__)
|
||||
+ ~tss() { std::free(mTss); }
|
||||
+#else
|
||||
~tss() { tss_delete(mTss); }
|
||||
+#endif /* defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) */
|
||||
+#endif /* (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__) */
|
||||
|
||||
void set(const T &value) const
|
||||
{
|
||||
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
+#if (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__)
|
||||
+ *mTss = to_ptr(value);
|
||||
+#else
|
||||
if(int res{tss_set(mTss, to_ptr(value))}; res != thrd_success)
|
||||
throw std::runtime_error{"al::tss::set(T)"};
|
||||
+#endif /* defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) */
|
||||
+#endif /* (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__) */
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
+#if (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__)
|
||||
+ auto get() const noexcept -> T { return from_ptr(*mTss); }
|
||||
+#else
|
||||
auto get() const noexcept -> T { return from_ptr(tss_get(mTss)); }
|
||||
+#endif /* defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) */
|
||||
+#endif /* (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) || defined(__DEVKITPPC__) || defined(__vita__) */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
tss(const tss&) = delete;
|
||||
|
|
|
@ -1,6 +1,29 @@
|
|||
# Fixes a compilation error when using the devkitARM toolchain or Vita SDK toolchain to compile OpenAL Soft.
|
||||
# For some reason, there's no implicit casting between `int` and `int32_t` and between `unsigned int` and `uint32_t` in devkitARM or Vita SDK even though they're the same size, so we have to do this whole song and dance to appease the compiler.
|
||||
|
||||
--- a/core/converter.cpp
|
||||
+++ b/core/converter.cpp
|
||||
@@ -83,16 +83,16 @@ inline DevFmtType_t<T> StoreSample(float) noexcept;
|
||||
|
||||
template<> inline float StoreSample<DevFmtFloat>(float val) noexcept
|
||||
{ return val; }
|
||||
-template<> inline int32_t StoreSample<DevFmtInt>(float val) noexcept
|
||||
-{ return fastf2i(std::clamp(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); }
|
||||
+template<> inline int StoreSample<DevFmtInt>(float val) noexcept
|
||||
+{ static_assert(sizeof(int) == sizeof(int32_t), "`int` should be a 32-bit integer"); return fastf2i(std::clamp(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); }
|
||||
template<> inline int16_t StoreSample<DevFmtShort>(float val) noexcept
|
||||
{ return static_cast<int16_t>(fastf2i(std::clamp(val*32768.0f, -32768.0f, 32767.0f))); }
|
||||
template<> inline int8_t StoreSample<DevFmtByte>(float val) noexcept
|
||||
{ return static_cast<int8_t>(fastf2i(std::clamp(val*128.0f, -128.0f, 127.0f))); }
|
||||
|
||||
/* Define unsigned output variations. */
|
||||
-template<> inline uint32_t StoreSample<DevFmtUInt>(float val) noexcept
|
||||
-{ return static_cast<uint32_t>(StoreSample<DevFmtInt>(val)) + 2147483648u; }
|
||||
+template<> inline unsigned int StoreSample<DevFmtUInt>(float val) noexcept
|
||||
+{ static_assert(sizeof(unsigned int) == sizeof(uint32_t), "`unsigned int` should be a 32-bit integer"); return static_cast<unsigned int>(StoreSample<DevFmtInt>(val)) + 2147483648u; }
|
||||
template<> inline uint16_t StoreSample<DevFmtUShort>(float val) noexcept
|
||||
{ return static_cast<uint16_t>(StoreSample<DevFmtShort>(val) + 32768); }
|
||||
template<> inline uint8_t StoreSample<DevFmtUByte>(float val) noexcept
|
||||
--- a/core/devformat.h
|
||||
+++ b/core/devformat.h
|
||||
@@ -94,9 +94,9 @@ struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
|
||||
|
|
Loading…
Add table
Reference in a new issue