SDL_mixer: added latest 1.29.3 windows builds of libmpg123

From 6448069360cff5944f1f3999d50a380b0914138f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 8 May 2022 12:15:14 +0300
Subject: [PATCH] added latest 1.29.3 windows builds of libmpg123

(the official release builds from mpg123.org .)
---
 VisualC/external/include/fmt123.h        |  54 +-
 VisualC/external/include/mpg123.h        | 716 ++++++++++++++++++++---
 VisualC/external/lib/x64/libmpg123-0.dll | Bin 336384 -> 515944 bytes
 VisualC/external/lib/x86/libmpg123-0.dll | Bin 337408 -> 551955 bytes
 4 files changed, 677 insertions(+), 93 deletions(-)

diff --git a/VisualC/external/include/fmt123.h b/VisualC/external/include/fmt123.h
index cc30a066..d7772e1e 100644
--- a/VisualC/external/include/fmt123.h
+++ b/VisualC/external/include/fmt123.h
@@ -4,7 +4,7 @@
 	separate header just for audio format definitions not tied to
 	library code
 
-	copyright 1995-2015 by the mpg123 project
+	copyright 1995-2020 by the mpg123 project
 	free software under the terms of the LGPL 2.1
 	see COPYING and AUTHORS files in distribution or http://mpg123.org
 */
@@ -99,19 +99,43 @@ enum mpg123_enc_enum
  * \return size of one sample in bytes
  */
 #define MPG123_SAMPLESIZE(enc) ( \
-	(enc) & MPG123_ENC_8 \
-	?	1 \
-	:	( (enc) & MPG123_ENC_16 \
-		?	2 \
-		:	( (enc) & MPG123_ENC_24 \
-			?	3 \
-			:	( (  (enc) & MPG123_ENC_32 \
-				  || (enc) == MPG123_ENC_FLOAT_32 ) \
-				?	4 \
-				:	( (enc) == MPG123_ENC_FLOAT_64 \
-					?	8 \
-					:	0 \
-)	)	)	)	)
+	(enc) < 1 \
+	?	0 \
+	:	( (enc) & MPG123_ENC_8 \
+		?	1 \
+		:	( (enc) & MPG123_ENC_16 \
+			?	2 \
+			:	( (enc) & MPG123_ENC_24 \
+				?	3 \
+				:	( (  (enc) & MPG123_ENC_32 \
+					  || (enc) == MPG123_ENC_FLOAT_32 ) \
+					?	4 \
+					:	( (enc) == MPG123_ENC_FLOAT_64 \
+						?	8 \
+						:	0 \
+)	)	)	)	)	)
+
+/** Representation of zero in differing encodings.
+ *  This exists to define proper silence in various encodings without
+ *  having to link to libsyn123 to do actual conversions at runtime.
+ *  You have to handle big/little endian order yourself, though.
+ *  This takes the shortcut that any signed encoding has a zero with
+ *  all-zero bits. Unsigned linear encodings just have the highest bit set
+ *  (2^(n-1) for n bits), while the nonlinear 8-bit ones are special.
+ *  \param enc the encoding (mpg123_enc_enum value)
+ *  \param siz bytes per sample (return value of MPG123_SAMPLESIZE(enc))
+ *  \param off byte (octet) offset counted from LSB
+ *  \return unsigned byte value for the designated octet
+ */
+#define MPG123_ZEROSAMPLE(enc, siz, off) ( \
+	(enc) == MPG123_ENC_ULAW_8 \
+	?	(off == 0 ? 0xff : 0x00) \
+	:	( (enc) == MPG123_ENC_ALAW_8 \
+		?	(off == 0 ? 0xd5 : 0x00) \
+		:	( (((enc) & (MPG123_ENC_SIGNED|MPG123_ENC_FLOAT)) || (siz) != ((off)+1)) \
+			?	0x00 \
+			:	0x80 \
+	)	)	)
 
 /** Structure defining an audio format.
  *  Providing the members as individual function arguments to define a certain
@@ -129,7 +153,7 @@ struct mpg123_fmt
 	int encoding;
 };
 
-/* @} */
+/** @} */
 
 #endif
 
diff --git a/VisualC/external/include/mpg123.h b/VisualC/external/include/mpg123.h
index 99df615f..10510535 100644
--- a/VisualC/external/include/mpg123.h
+++ b/VisualC/external/include/mpg123.h
@@ -1,5 +1,5 @@
 /*
-	libmpg123: MPEG Audio Decoder library (version 1.25.13)
+	libmpg123: MPEG Audio Decoder library (version 1.29.3)
 
 	copyright 1995-2015 by the mpg123 project
 	free software under the terms of the LGPL 2.1
@@ -17,7 +17,9 @@
  * This should be incremented at least each time a new symbol is added
  * to the header.
  */
-#define MPG123_API_VERSION 44
+#ifndef MPG123_API_VERSION
+#define MPG123_API_VERSION 46
+#endif
 
 #ifndef MPG123_EXPORT
 /** Defines needed for MS Visual Studio(tm) DLL builds.
@@ -41,17 +43,60 @@
 #endif
 #endif
 
-/* This is for Visual Studio, so this header works as distributed in the binary downloads */
-#if defined(_MSC_VER) && !defined(MPG123_DEF_SSIZE_T)
-#define MPG123_DEF_SSIZE_T
-#include <stddef.h>
-typedef ptrdiff_t ssize_t;
+/** Earlier versions of libmpg123 put enums into public API calls,
+ * thich is not exactly safe. There are ABI rules, but you can use
+ * compiler switches to change the sizes of enums. It is safer not
+ * to have them in API calls. Thus, the default is to remap calls and
+ * structs to variants that use plain ints. Define MPG123_ENUM_API to
+ * prevent that remapping.
+ *
+ * You might want to define this to increase the chance of your binary
+ * working with an older version of the library. But if that is your goal,
+ * you should better build with an older version to begin with.
+ */
+#ifndef MPG123_ENUM_API
+
+#define mpg123_param        mpg123_param2
+#define mpg123_getparam     mpg123_getparam2
+#define mpg123_feature      mpg123_feature2
+#define mpg123_eq           mpg123_eq2
+#define mpg123_geteq        mpg123_geteq2
+#define mpg123_frameinfo    mpg123_frameinfo2
+#define mpg123_info         mpg123_info2
+#define mpg123_getstate     mpg123_getstate2
+#define mpg123_enc_from_id3 mpg123_enc_from_id3_2
+#define mpg123_store_utf8   mpg123_store_utf8_2
+#define mpg123_par          mpg123_par2
+#define mpg123_getpar       mpg123_getpar2
+
 #endif
 
-#ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */
+/* You can use this file directly, avoiding the autoconf replacements.
+   Might have to set MPG123_NO_LARGENAME, too, in case you have
+   _FILE_OFFSET_BITS defined where it does not make sense. */
+#ifndef MPG123_NO_CONFIGURE
+
 #include <stdlib.h>
 #include <sys/types.h>
 
+/* A little hack to help MSVC not having ssize_t. */
+#ifdef _MSC_VER
+#include <stddef.h>
+typedef ptrdiff_t mpg123_ssize_t;
+#else
+typedef ssize_t mpg123_ssize_t;
+#endif
+
+/* You can always enforce largefile hackery by setting MPG123_LARGESUFFIX. */
+/* Otherwise, this header disables it if the build system decided so. */
+#if !defined(MPG123_LARGESUFFIX) && 0
+#ifndef MPG123_NO_LARGENAME
+#define MPG123_NO_LARGENAME
+#endif
+#endif
+
+#endif /* MPG123_NO_CONFIGURE */
+
 /* Simplified large file handling.
 	I used to have a check here that prevents building for a library with conflicting large file setup
 	(application that uses 32 bit offsets with library that uses 64 bits).
@@ -83,6 +128,7 @@ typedef ptrdiff_t ssize_t;
 #endif
 #define MPG123_LARGENAME(func) MPG123_MACROCAT(func, MPG123_LARGESUFFIX)
 
+#define mpg123_open_fixed   MPG123_LARGENAME(mpg123_open_fixed)
 #define mpg123_open         MPG123_LARGENAME(mpg123_open)
 #define mpg123_open_fd      MPG123_LARGENAME(mpg123_open_fd)
 #define mpg123_open_handle  MPG123_LARGENAME(mpg123_open_handle)
@@ -107,8 +153,6 @@ typedef ptrdiff_t ssize_t;
 
 #endif /* largefile hackery */
 
-#endif /* MPG123_NO_CONFIGURE */
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -130,15 +174,26 @@ struct mpg123_handle_struct;
  */
 typedef struct mpg123_handle_struct mpg123_handle;
 
-/** Function to initialise the mpg123 library. 
- *	This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library.
+/** Useless no-op that used to do initialization work.
+ *
+ * For API version before 46 (mpg123 1.27.0), you had to ensure to have
+ * this called once before creating a handle. To be pure, this had to
+ * happen in a single-threaded context, too (while in practice, there was no
+ * harm done possibly racing to compute the same numbers again).
+ *
+ * Now this function really does nothing anymore. The only reason to call
+ * it is to be compatible with old versions of the library that still require
+ * it.
  *
  *	\return MPG123_OK if successful, otherwise an error number.
  */
 MPG123_EXPORT int mpg123_init(void);
 
-/** Function to close down the mpg123 library. 
- *	This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library. */
+/** Superfluous Function to close down the mpg123 library.
+ * This was created with the thought that there sometime will be cleanup code
+ * to be run after library use. This never materialized. You can forget about
+ * this function and it is only here for old programs that do call it.
+ */
 MPG123_EXPORT void mpg123_exit(void);
 
 /** Create a handle with optional choice of decoder (named by a string, see mpg123_decoders() or mpg123_supported_decoders()).
@@ -156,6 +211,13 @@ MPG123_EXPORT mpg123_handle *mpg123_new(const char* decoder, int *error);
  */
 MPG123_EXPORT void mpg123_delete(mpg123_handle *mh);
 
+/** Free plain memory allocated within libmpg123.
+ *  This is for library users that are not sure to use the same underlying
+ *  memory allocator as libmpg123. It is just a wrapper over free() in
+ *  the underlying C library.
+ */
+MPG123_EXPORT void mpg123_free(void *ptr);
+
 /** Enumeration of the parameters types that it is possible to set/get. */
 enum mpg123_parms
 {
@@ -169,7 +231,8 @@ enum mpg123_parms
 	MPG123_UPSPEED,        /**< play every Nth frame (integer) */
 	MPG123_START_FRAME,    /**< start with this frame (skip frames before that, integer) */ 
 	MPG123_DECODE_FRAMES,  /**< decode only this number of frames (integer) */
-	MPG123_ICY_INTERVAL,   /**< stream contains ICY metadata with this interval (integer) */
+	MPG123_ICY_INTERVAL,   /**< Stream contains ICY metadata with this interval (integer).
+	                            Make sure to set this _before_ opening a stream.*/
 	MPG123_OUTSCALE,       /**< the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer) */
 	MPG123_TIMEOUT,        /**< timeout for reading from a stream (not supported on win32, integer) */
 	MPG123_REMOVE_FLAGS,   /**< remove some flags (inverse of MPG123_ADD_FLAGS, integer) */
@@ -178,6 +241,11 @@ enum mpg123_parms
 	,MPG123_PREFRAMES /**< Decode/ignore that many frames in advance for layer 3. This is needed to fill bit reservoir after seeking, for example (but also at least one frame in advance is needed to have all "normal" data for layer 3). Give a positive integer value, please.*/
 	,MPG123_FEEDPOOL  /**< For feeder mode, keep that many buffers in a pool to avoid frequent malloc/free. The pool is allocated on mpg123_open_feed(). If you change this parameter afterwards, you can trigger growth and shrinkage during decoding. The default value could change any time. If you care about this, then set it. (integer) */
 	,MPG123_FEEDBUFFER /**< Minimal size of one internal feeder buffer, again, the default value is subject to change. (integer) */
+	,MPG123_FREEFORMAT_SIZE /**< Tell the parser a free-format frame size to
+	 * avoid read-ahead to get it. A value of -1 (default) means that the parser
+	 * will determine it. The parameter value is applied during decoder setup
+	 * for a freshly opened stream only.
+	 */
 };
 
 /** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */
@@ -208,6 +276,37 @@ enum mpg123_param_flags
 	 *  the stream is assumed as non-seekable unless overridden.
 	 */
 	,MPG123_FORCE_SEEKABLE = 0x40000 /**< 19th bit: Force the stream to be seekable. */
+	,MPG123_STORE_RAW_ID3  = 0x80000 /**< store raw ID3 data (even if skipping) */
+	,MPG123_FORCE_ENDIAN   = 0x100000 /**< Enforce endianess of output samples.
+	 *  This is not reflected in the format codes. If this flag is set along with
+	 *  MPG123_BIG_ENDIAN, MPG123_ENC_SIGNED16 means s16be, without
+	 *  MPG123_BIG_ENDIAN, it means s16le. Normal operation without
+	 *  MPG123_FORCE_ENDIAN produces output in native byte order.
+	 */
+	,MPG123_BIG_ENDIAN     = 0x200000 /**< Choose big endian instead of little. */
+	,MPG123_NO_READAHEAD   = 0x400000 /**< Disable read-ahead in parser. If
+	 * you know you provide full frames to the feeder API, this enables
+	 * decoder output from the first one on, instead of having to wait for
+	 * the next frame to confirm that the stream is healthy. It also disables
+	 * free format support unless you provide a frame size using
+	 * MPG123_FREEFORMAT_SIZE.
+	 */
+	,MPG123_FLOAT_FALLBACK = 0x800000 /**< Consider floating point output encoding only after
+	 * trying other (possibly downsampled) rates and encodings first. This is to
+	 * support efficient playback where floating point output is only configured for
+	 * an external resampler, bypassing that resampler when the desired rate can
+	 * be produced directly. This is enabled by default to be closer to older versions
+	 * of libmpg123 which did not enable float automatically at all. If disabled,
+	 * float is considered after the 16 bit default and higher-bit integer encodings
+	 * for any rate. */
+	,MPG123_NO_FRANKENSTEIN = 0x1000000 /**< Disable support for Frankenstein streams
+	 * (different MPEG streams stiched together). Do not accept serious change of MPEG
+	 * header inside a single stream. With this flag, the audio output format cannot
+	 * change during decoding unless you open a new stream. This also stops decoding
+	 * after an announced end of stream (Info header contained a number of frames
+	 * and this number has been reached). This makes your MP3 files behave more like
+	 * ordinary media files with defined structure, rather than stream dumps with
+	 * some sugar. */
 };
 
 /** choices for MPG123_RVA */
@@ -219,8 +318,12 @@ enum mpg123_param_rva
 	,MPG123_RVA_MAX   = MPG123_RVA_ALBUM /**< The maximum RVA code, may increase in future. */
 };
 
-/** Set a specific parameter, for a specific mpg123_handle, using a parameter 
- *  type key chosen from the mpg123_parms enumeration, to the specified value.
+#ifdef MPG123_ENUM_API
+/** Set a specific parameter on a handle.
+ *
+ *  Note that this name is mapped to mpg123_param2() instead unless
+ *  MPG123_ENUM_API is defined.
+ *
  *  \param mh handle
  *  \param type parameter choice
  *  \param value integer value
@@ -229,9 +332,28 @@ enum mpg123_param_rva
  */
 MPG123_EXPORT int mpg123_param( mpg123_handle *mh
 ,	enum mpg123_parms type, long value, double fvalue );
+#endif
 
-/** Get a specific parameter, for a specific mpg123_handle. 
- *  See the mpg123_parms enumeration for a list of available parameters.
+/** Set a specific parameter on a handle. No enums.
+ *
+ *  This is actually called instead of mpg123_param()
+ *  unless MPG123_ENUM_API is defined.
+ *
+ *  \param mh handle
+ *  \param type parameter choice (from enum #mpg123_parms)
+ *  \param value integer value
+ *  \param fvalue floating point value
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_param2( mpg123_handle *mh
+,	int type, long value, double fvalue );
+
+#ifdef MPG123_ENUM_API
+/** Get a specific parameter from a handle.
+ *
+ *  Note that this name is mapped to mpg123_getparam2() instead unless
+ *  MPG123_ENUM_API is defined.
+ *
  *  \param mh handle
  *  \param type parameter choice
  *  \param value integer value return address
@@ -240,6 +362,21 @@ MPG123_EXPORT int mpg123_param( mpg123_handle *mh
  */
 MPG123_EXPORT int mpg123_getparam( mpg123_handle *mh
 ,	enum mpg123_parms type, long *value, double *fvalue );
+#endif
+
+/** Get a specific parameter from a handle. No enums.
+ *
+ *  This is actually called instead of mpg123_getparam() unless MPG123_ENUM_API
+ *  is defined.
+ *
+ *  \param mh handle
+ *  \param type parameter choice (from enum #mpg123_parms)
+ *  \param value integer value return address
+ *  \param fvalue floating point value return address
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_getparam2( mpg123_handle *mh
+,	int type, long *value, double *fvalue );
 
 /** Feature set available for query with mpg123_feature. */
 enum mpg123_feature_set
@@ -259,15 +396,34 @@ enum mpg123_feature_set
 	,MPG123_FEATURE_PARSE_ICY            /**< ICY support                  */
 	,MPG123_FEATURE_TIMEOUT_READ         /**< Reader with timeout (network). */
 	,MPG123_FEATURE_EQUALIZER            /**< tunable equalizer */
+	,MPG123_FEATURE_MOREINFO             /**< more info extraction (for frame analyzer) */
+	,MPG123_FEATURE_OUTPUT_FLOAT32      /**< 32 bit float output */
+	,MPG123_FEATURE_OUTPUT_FLOAT64      /**< 64 bit float output (as of now: never!) */
 };
 
+#ifdef MPG123_ENUM_API
 /** Query libmpg123 features.
+ *
+ *  Note that this name is mapped to mpg123_feature2() instead unless
+ *  MPG123_ENUM_API is defined.
+ *
  *  \param key feature selection
  *  \return 1 for success, 0 for unimplemented functions
  */
 MPG123_EXPORT int mpg123_feature(const enum mpg123_feature_set key);
+#endif
+
+/** Query libmpg123 features. No enums.
+ *
+ *  This is actually called instead of mpg123_feature() unless MPG123_ENUM_API
+ *  is defined.
+ *
+ *  \param key feature selection (from enum #mpg123_feature_set)
+ *  \return 1 for success, 0 for unimplemented functions
+ */
+MPG123_EXPORT int mpg123_feature2(int key);
 
-/* @} */
+/** @} */
 
 
 /** \defgroup mpg123_error mpg123 error handling
@@ -352,6 +508,7 @@ enum mpg123_errors
 	,MPG123_BAD_CUSTOM_IO /**< Custom I/O not prepared. */
 	,MPG123_LFS_OVERFLOW /**< Offset value overflow during translation of large file API calls -- your client program cannot handle that large file. */
 	,MPG123_INT_OVERFLOW /**< Some integer overflow. */
+	,MPG123_BAD_FLOAT /**< Floating-point computations work not as expected. */
 };
 
 /** Look up error strings given integer code.
@@ -375,7 +532,7 @@ MPG123_EXPORT const char* mpg123_strerror(mpg123_handle *mh);
  */
 MPG123_EXPORT int mpg123_errcode(mpg123_handle *mh);
 
-/*@}*/
+/** @} */
 
 
 /** \defgroup mpg123_decoder mpg123 decoder selection
@@ -392,6 +549,10 @@ MPG123_EXPORT int mpg123_errcode(mpg123_handle *mh);
 MPG123_EXPORT const char **mpg123_decoders(void);
 
 /** Get supported decoder list.
+ *
+ * This possibly writes to static storage in the library, so avoid
+ * calling concurrently, please.
+ *
  *  \return NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII)
  */
 MPG123_EXPORT const char **mpg123_supported_decoders(void);
@@ -414,14 +575,19 @@ MPG123_EXPORT int mpg123_decoder(mpg123_handle *mh, const char* decoder_name);
  */
 MPG123_EXPORT const char* mpg123_current_decoder(mpg123_handle *mh);
 
-/*@}*/
+/** @} */
 
 
 /** \defgroup mpg123_output mpg123 output audio format 
  *
  * Functions to get and select the format of the decoded audio.
  *
- * Before you dive in, please be warned that you might get confused by this. This seems to happen a lot, therefore I am trying to explain in advance.
+ * Before you dive in, please be warned that you might get confused by this.
+ * This seems to happen a lot, therefore I am trying to explain in advance.
+ * If you do feel confused and just want to decode your normal MPEG audio files that
+ * don't alter properties in the middle, just use mpg123_open_fixed() with a fixed encoding
+ * and channel count and forget about a matrix of audio formats. If you want to get funky,
+ * read ahead ...
  *
  * The mpg123 library decides what output format to use when encountering the first frame in a stream, or actually any frame that is still valid but differs from the frames before in the prompted output format. At such a deciding point, an internal table of allowed encodings, sampling rates and channel setups is consulted. According to this table, an output format is chosen and the decoding engine set up accordingly (including optimized routines for different output formats). This might seem unusual but it just follows from the non-existence of "MPEG audio files" with defined overall properties. There are streams, streams are concatenations of (semi) independent frames. We store streams on disk and call them "MPEG audio files", but that does not change their nature as the decoder is concerned (the LAME/Xing header for gapless decoding makes things interesting again).
  *
@@ -443,7 +609,9 @@ enum mpg123_channelcount
 
 /** An array of supported standard sample rates
  *  These are possible native sample rates of MPEG audio files.
- *  You can still force mpg123 to resample to a different one, but by default you will only get audio in one of these samplings.
+ *  You can still force mpg123 to resample to a different one, but by
+ *  default you will only get audio in one of these samplings.
+ *  This list is in ascending order.
  *  \param list Store a pointer to the sample rates array there.
  *  \param number Store the number of sample rates there. */
 MPG123_EXPORT void mpg123_rates(const long **list, size_t *number);
@@ -482,6 +650,19 @@ MPG123_EXPORT int mpg123_format_all(mpg123_handle *mh);
 MPG123_EXPORT int mpg123_format( mpg123_handle *mh
 ,	long rate, int channels, int encodings );
 
+/** Set the audio format support of a mpg123_handle in detail:
+ *  \param mh handle
+ *  \param rate The sample rate value (in Hertz). Special value 0 means
+ *     all rates (the reason for this variant of mpg123_format()).
+ *  \param channels A combination of MPG123_STEREO and MPG123_MONO.
+ *  \param encodings A combination of accepted encodings for rate and channels,
+ *     p.ex MPG123_ENC_SIGNED16 | MPG123_ENC_ULAW_8 (or 0 for no support).
+ *     Please note that some encodings may not be supported in the library build
+ *     and thus will be ignored here.
+ *  \return MPG123_OK on success, MPG123_ERR if there was an error. */
+MPG123_EXPORT int mpg123_format2( mpg123_handle *mh
+,	long rate, int channels, int encodings );
+
 /** Check to see if a specific format at a specific rate is supported 
  *  by mpg123_handle.
  *  \param mh handle
@@ -520,7 +701,7 @@ MPG123_EXPORT int mpg123_getformat( mpg123_handle *mh
 MPG123_EXPORT int mpg123_getformat2( mpg123_handle *mh
 ,	long *rate, int *channels, int *encoding, int clear_flag );
 
-/*@}*/
+/** @} */
 
 
 /** \defgroup mpg123_input mpg123 file input and decoding
@@ -530,14 +711,65 @@ MPG123_EXPORT int mpg123_getformat2( mpg123_handle *mh
  * @{
  */
 
-/* reading samples / triggering decoding, possible return values: */
-/** Enumeration of the error codes returned by libmpg123 functions. */
+/** Open a simple MPEG file with fixed properties.
+ *
+ *  This function shall simplify the common use case of a plain MPEG
+ *  file on disk that you want to decode, with one fixed sample
+ *  rate and channel count, and usually a length defined by a Lame/Info/Xing
+ *  tag. It will:
+ *
+ *  - set the MPG123_NO_FRANKENSTEIN flag
+ *  - set up format support according to given parameters,
+ *  - open the file,
+ *  - query audio format,
+ *  - fix the audio format support table to ensure the format stays the same,
+ *  - call mpg123_scan() if there is no header frame to tell the track length.
+ *
+ *  From that on, you can call mpg123_getformat() for querying the sample
+ *  rate (and channel count in case you allowed both) and mpg123_length()
+ *  to get a pretty safe number for the duration.
+ *  Only the sample rate is left open as that indeed is a fixed property of
+ *  MPEG files. You could set MPG123_FORCE_RATE beforehand, but that may trigger
+ *  low-quality resampling in the decoder, only do so if in dire need.
+ *  The library will convert mono files to stereo for you, and vice versa.
+ *  If any constraint cannot be satisified (most likely because of a non-default
+ *  build of libmpg123), you get MPG123_ERR returned and can query the detailed
+ *  cause from the handle. Only on MPG123_OK there will an open file that you
+ *  then close using mpg123_close(), or implicitly on mpg123_delete() or the next
+ *  call to open another file.
+ *
+ *  So, for your usual CD rip collection, you could use
+ *
+ *    mpg123_open_fixed(mh, path, MPG123_STEREO, MPG123_ENC_SIGNED_16)
+ *
+ *  and be happy calling mpg123_getformat() to verify 44100 Hz rate, then just
+ *  playing away with mpg123_read(). The occasional mono file, or MP2 file,
+ *  will also be decoded without you really noticing. Just the speed could be
+ *  wrong if you do not care about sample rate at all.
+ *  \param mh handle
+ *  \param path filesystem path (see mpg123_open())
+ *  \param channels allowed channel count, either 1 (MPG123_MONO) or
+ *    2 (MPG123_STEREO), or bitwise or of them, but then you're halfway back to
+ *    calling mpg123_format() again;-)
+ *  \param encoding a definite encoding from enum mpg123_enc_enum
+ *    or a bitmask like for mpg123_format(), defeating the purpose somewhat
+ */
+MPG123_EXPORT int mpg123_open_fixed(mpg123_handle *mh, const char *path
+,	int channels, int encoding);
 
 /** Open and prepare to decode the specified file by filesystem path.
  *  This does not open HTTP urls; libmpg123 contains no networking code.
  *  If you want to decode internet streams, use mpg123_open_fd() or mpg123_open_feed().
+ *
+ *  The path parameter usually is just a string that is handed to the underlying
+ *  OS routine for opening, treated as a blob of binary data. On platforms
+ *  where encoding needs to be involved, something like _wopen() is called
+ *  underneath and the path argument to libmpg123 is assumed to be encoded in UTF-8.
+ *  So, if you have to ask yourself which encoding is needed, the answer is
+ *  UTF-8, which also fits any sane modern install of Unix-like systems.
+ *
  *  \param mh handle
- *  \param path filesystem path
+ *  \param path filesystem
  *  \return MPG123_OK on success
  */
 MPG123_EXPORT int mpg123_open(mpg123_handle *mh, const char *path);
@@ -561,6 +793,8 @@ MPG123_EXPORT int mpg123_open_handle(mpg123_handle *mh, void *iohandle);
 
 /** Open a new bitstream and prepare for direct feeding
  *  This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream.
+ *  Also, you are expected to handle ICY metadata extraction yourself. This
+ *  input method does not handle MPG123_ICY_INTERVAL. It does parse ID3 frames, though.
  *  \param mh handle
  *  \return MPG123_OK on success
  */
@@ -573,6 +807,10 @@ MPG123_EXPORT int mpg123_open_feed(mpg123_handle *mh);
 MPG123_EXPORT int mpg123_close(mpg123_handle *mh);
 
 /** Read from stream and decode up to outmemsize bytes.
+ *
+ *  Note: The type of outmemory changed to a void pointer in mpg123 1.26.0
+ *  (API version 45).
+ *
  *  \param mh handle
  *  \param outmemory address of output buffer to write to
  *  \param outmemsize maximum number of bytes to write
@@ -580,7 +818,7 @@ MPG123_EXPORT int mpg123_close(mpg123_handle *mh);
  *  \return MPG123_OK or error/message code
  */
 MPG123_EXPORT int mpg123_read(mpg123_handle *mh
-,	unsigned char *outmemory, size_t outmemsize, size_t *done );
+,	void *outmemory, size_t outmemsize, size_t *done );
 
 /** Feed data for a stream that has been opened with mpg123_open_feed().
  *  It's give and take: You provide the bytestream, mpg123 gives you the decoded samples.
@@ -599,6 +837,10 @@ MPG123_EXPORT int mpg123_feed( mpg123_handle *mh
  *  without taking decoded data.
  *  Think of this function being the union of mpg123_read() and mpg123_feed() (which it actually is, sort of;-).
  *  You can actually always decide if you want those specialized functions in separate steps or one call this one here.
+ *
+ *  Note: The type of outmemory changed to a void pointer in mpg123 1.26.0
+ *  (API version 45).
+ *
  *  \param mh handle
  *  \param inmemory input buffer
  *  \param inmemsize number of input bytes
@@ -609,7 +851,7 @@ MPG123_EXPORT int mpg123_feed( mpg123_handle *mh
  */
 MPG123_EXPORT int mpg123_decode( mpg123_handle *mh
 ,	const unsigned char *inmemory, size_t inmemsize
-,	unsigned char *outmemory, size_t outmemsize, size_t *done );
+,	void *outmemory, size_t outmemsize, size_t *done );
 
 /** Decode next MPEG frame to internal buffer
  *  or read a frame and return after setting a new format.
@@ -669,33 +911,55 @@ MPG123_EXPORT int mpg123_framedata( mpg123_handle *mh
  */
 MPG123_EXPORT off_t mpg123_framepos(mpg123_handle *mh);
 
-/*@}*/
+/** @} */
 
 
 /** \defgroup mpg123_seek mpg123 position and seeking
  *
  * Functions querying and manipulating position in the decoded audio bitstream.
- * The position is measured in decoded audio samples, or MPEG frame offset for the specific functions.
- * If gapless code is in effect, the positions are adjusted to compensate the skipped padding/delay - meaning, you should not care about that at all and just use the position defined for the samples you get out of the decoder;-)
+ * The position is measured in decoded audio samples or MPEG frame offset for
+ * the specific functions. The term sample refers to a group of samples for
+ * multiple channels, normally dubbed PCM frames. The latter term is
+ * avoided here because frame means something different in the context of MPEG
+ * audio. Since all samples of a PCM frame occur at the same time, there is only
+ * very limited ambiguity when talking about playback offset, as counting each
+ * channel sample individually does not make sense.
+ *
+ * If gapless code is in effect, the positions are adjusted to compensate the
+ * skipped padding/delay - meaning, you should not care about that at all and
+ * just use the position defined for the samples you get out of the decoder;-)
  * The general usage is modelled after stdlib's ftell() and fseek().
- * Especially, the whence parameter for the seek functions has the same meaning as the one for fseek() and needs the same constants from stdlib.h: 
+ * Especially, the whence parameter for the seek functions has the same meaning
+ * as the one for fseek() and needs the same constants from stdlib.h: 
+ *
  * - SEEK_SET: set position to (or near to) specified offset
  * - SEEK_CUR: change position by offset from now
  * - SEEK_END: set position to offset from end
  *
- * Note that sample-accurate seek only works when gapless support has been enabled at compile time; seek is frame-accurate otherwise.
- * Also, really sample-accurate seeking (meaning that you get the identical sample value after seeking compared to plain decoding up to the position) is only guaranteed when you do not mess with the position code by using MPG123_UPSPEED, MPG123_DOWNSPEED or MPG123_START_FRAME. The first two mainly should cause trouble with NtoM resampling, but in any case with these options in effect, you have to keep in mind that the sample offset is not the same as counting the samples you get from decoding since mpg123 counts the skipped samples, too (or the samples played twice only once)!
- * Short: When you care about the sample position, don't mess with those parameters;-)
- * Also, seeking is not guaranteed to work for all streams (underlying stream may not support it).
- * And yet another caveat: If the stream is concatenated out of differing pieces (Frankenstein stream), seeking may suffer, too.
+ * Note that sample-accurate seek only works when gapless support has been
+ * enabled at compile time; seek is frame-accurate otherwise.
+ * Also, really sample-accurate seeking (meaning that you get the identical
+ * sample value after seeking compared to plain decoding up to the position)
+ * is only guaranteed when you do not mess with the position code by using
+ * #MPG123_UPSPEED, #MPG123_DOWNSPEED or #MPG123_START_FRAME. The first two mainly
+ * should cause trouble with NtoM resampling, but in any case with these options
+ * in effect, you have to keep in mind that the sample offset is not the same
+ * as counting the samples you get from decoding since mpg123 counts the skipped
+ * samples, too (or the samples played twice only once)!
+ *
+ * Short: When you care about the sample position, don't mess with those
+ * parameters;-)
+ *
+ * Streams may be openend in ways that do not support seeking. Also, consider
+ * the effect of #MPG123_FUZZY.
  *
  * @{
  */
 
 /** Returns the current position in samples.
- *  On the next successful read, you'd get that sample.
+ *  On the next successful read, you'd get audio data with that offse

(Patch may be truncated, please check the link at the top of this post.)