From 21518121de0ac5ebc3c85e7b6ef9cd842c4f1231 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 14 Mar 2022 18:53:38 +0100 Subject: [PATCH] Windows: Support mpg123 1.28.1 and newer With this release they added mpg123_ssize_t but this cannot be used because they forgot to bump MPG123_API_VERSION. Instead the underlying types were hardcoded. --- src/decoder_mpg123.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/decoder_mpg123.cpp b/src/decoder_mpg123.cpp index 22e806e889..483bfe2504 100644 --- a/src/decoder_mpg123.cpp +++ b/src/decoder_mpg123.cpp @@ -30,7 +30,13 @@ static void Mpg123Decoder_deinit(void) { mpg123_exit(); } -static ssize_t custom_read(void* io, void* buffer, size_t nbyte) { +#ifdef _MSC_VER +using MPG123_SIZE_TYPE = ptrdiff_t; +#else +using MPG123_SIZE_TYPE = ssize_t; +#endif + +static MPG123_SIZE_TYPE custom_read(void* io, void* buffer, size_t nbyte) { auto* f = reinterpret_cast(io); return f->read(reinterpret_cast(buffer), nbyte).gcount(); }