1diff -ruN mpg123-1.25.6.orig/android/config.h mpg123-1.25.6/android/config.h
2--- mpg123-1.25.6.orig/android/config.h	1969-12-31 16:00:00.000000000 -0800
3+++ mpg123-1.25.6/android/config.h	2017-10-23 07:43:01.919907577 -0700
4@@ -0,0 +1,478 @@
5+/* src/config.h.  Generated from config.h.in by configure.  */
6+/* src/config.h.in.  Generated from configure.ac by autoheader.  */
7+
8+/* Define if your architecture wants/needs/can use attribute_align_arg and
9+   alignment checks. It is for 32bit x86... */
10+/* #undef ABI_ALIGN_FUN */
11+
12+/* Define to use proper rounding. */
13+/* #undef ACCURATE_ROUNDING */
14+
15+/* Define if building universal (internal helper macro) */
16+/* #undef AC_APPLE_UNIVERSAL_BUILD */
17+
18+/* Define if .balign is present. */
19+#define ASMALIGN_BALIGN 1
20+
21+/* Define if .align just takes byte count. */
22+/* #undef ASMALIGN_BYTE */
23+
24+/* Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8. */
25+/* #undef ASMALIGN_EXP */
26+
27+/* Define if __attribute__((aligned(16))) shall be used */
28+#define CCALIGN 1
29+
30+/* Define if debugging is enabled. */
31+/* #undef DEBUG */
32+
33+/* The default audio output module(s) to use */
34+#define DEFAULT_OUTPUT_MODULE "oss,esd,pulse"
35+
36+/* Define if building with dynamcally linked libmpg123 */
37+#define DYNAMIC_BUILD 1
38+
39+/* Use EFBIG as substitude for EOVERFLOW, mingw.org may lack the latter */
40+/* #undef EOVERFLOW */
41+
42+/* Define if FIFO support is enabled. */
43+/* #undef FIFO */
44+
45+/* Define if frame index should be used. */
46+#define FRAME_INDEX 1
47+
48+/* Define if gapless is enabled. */
49+#define GAPLESS 1
50+
51+/* Define to 1 if you have the <alc.h> header file. */
52+/* #undef HAVE_ALC_H */
53+
54+/* Define to 1 if you have the <Alib.h> header file. */
55+/* #undef HAVE_ALIB_H */
56+
57+/* Define to 1 if you have the <AL/alc.h> header file. */
58+/* #undef HAVE_AL_ALC_H */
59+
60+/* Define to 1 if you have the <AL/al.h> header file. */
61+/* #undef HAVE_AL_AL_H */
62+
63+/* Define to 1 if you have the <al.h> header file. */
64+/* #undef HAVE_AL_H */
65+
66+/* Define to 1 if you have the <arpa/inet.h> header file. */
67+#define HAVE_ARPA_INET_H 1
68+
69+/* Define to 1 if you have the <asm/audioio.h> header file. */
70+/* #undef HAVE_ASM_AUDIOIO_H */
71+
72+/* Define to 1 if you have the `atoll' function. */
73+#define HAVE_ATOLL 1
74+
75+/* Define to 1 if you have the <audios.h> header file. */
76+/* #undef HAVE_AUDIOS_H */
77+
78+/* Define to 1 if you have the <AudioToolbox/AudioToolbox.h> header file. */
79+/* #undef HAVE_AUDIOTOOLBOX_AUDIOTOOLBOX_H */
80+
81+/* Define to 1 if you have the <AudioUnit/AudioUnit.h> header file. */
82+/* #undef HAVE_AUDIOUNIT_AUDIOUNIT_H */
83+
84+/* Define to 1 if you have the <CoreServices/CoreServices.h> header file. */
85+/* #undef HAVE_CORESERVICES_CORESERVICES_H */
86+
87+/* Define to 1 if you have the <CUlib.h> header file. */
88+/* #undef HAVE_CULIB_H */
89+
90+/* Define to 1 if you have the <dirent.h> header file. */
91+#define HAVE_DIRENT_H 1
92+
93+/* Define to 1 if you have the `dlclose' function. */
94+#define HAVE_DLCLOSE 1
95+
96+/* Define to 1 if you have the <dlfcn.h> header file. */
97+#define HAVE_DLFCN_H 1
98+
99+/* Define to 1 if you have the `dlopen' function. */
100+#define HAVE_DLOPEN 1
101+
102+/* Define to 1 if you have the `dlsym' function. */
103+#define HAVE_DLSYM 1
104+
105+/* Define if getaddrinfo accepts the AI_ADDRCONFIG flag */
106+/* #undef HAVE_GAI_ADDRCONFIG */
107+
108+/* Define to 1 if you have the `getaddrinfo' function. */
109+#define HAVE_GETADDRINFO 1
110+
111+/* Define to 1 if you have the `getpagesize' function. */
112+/* #undef HAVE_GETPAGESIZE */
113+
114+/* Define to 1 if you have the `getuid' function. */
115+#define HAVE_GETUID 1
116+
117+/* Define to 1 if you have the <inttypes.h> header file. */
118+#define HAVE_INTTYPES_H 1
119+
120+/* Define to 1 if you have the <langinfo.h> header file. */
121+/* #undef HAVE_LANGINFO_H */
122+
123+/* Define to 1 if you have the `m' library (-lm). */
124+#define HAVE_LIBM 1
125+
126+/* Define to 1 if you have the `mx' library (-lmx). */
127+/* #undef HAVE_LIBMX */
128+
129+/* Define to 1 if you have the <limits.h> header file. */
130+#define HAVE_LIMITS_H 1
131+
132+/* Define to 1 if you have the <linux/soundcard.h> header file. */
133+#define HAVE_LINUX_SOUNDCARD_H 1
134+
135+/* Define to 1 if you have the <locale.h> header file. */
136+#define HAVE_LOCALE_H 1
137+
138+/* Define to 1 if you have the <machine/soundcard.h> header file. */
139+/* #undef HAVE_MACHINE_SOUNDCARD_H */
140+
141+/* Define to 1 if you have the <memory.h> header file. */
142+#define HAVE_MEMORY_H 1
143+
144+/* Define to 1 if you have the `mkfifo' function. */
145+/* #undef HAVE_MKFIFO */
146+
147+/* Define to 1 if you have a working `mmap' system call. */
148+/* #undef HAVE_MMAP */
149+
150+/* Define to 1 if you have the <netdb.h> header file. */
151+#define HAVE_NETDB_H 1
152+
153+/* Define to 1 if you have the <netinet/in.h> header file. */
154+#define HAVE_NETINET_IN_H 1
155+
156+/* Define to 1 if you have the <netinet/tcp.h> header file. */
157+/* #undef HAVE_NETINET_TCP_H */
158+
159+/* Define to 1 if you have the `nl_langinfo' function. */
160+/* #undef HAVE_NL_LANGINFO */
161+
162+/* Define to 1 if you have the <OpenAL/alc.h> header file. */
163+/* #undef HAVE_OPENAL_ALC_H */
164+
165+/* Define to 1 if you have the <OpenAL/al.h> header file. */
166+/* #undef HAVE_OPENAL_AL_H */
167+
168+/* Define to 1 if you have the <os2me.h> header file. */
169+/* #undef HAVE_OS2ME_H */
170+
171+/* Define to 1 if you have the <os2.h> header file. */
172+/* #undef HAVE_OS2_H */
173+
174+/* Define to 1 if you have the `random' function. */
175+/* #undef HAVE_RANDOM */
176+
177+/* Define to 1 if you have the <sched.h> header file. */
178+#define HAVE_SCHED_H 1
179+
180+/* Define to 1 if you have the `sched_setscheduler' function. */
181+#define HAVE_SCHED_SETSCHEDULER 1
182+
183+/* Define to 1 if you have the `setlocale' function. */
184+#define HAVE_SETLOCALE 1
185+
186+/* Define to 1 if you have the `setpriority' function. */
187+#define HAVE_SETPRIORITY 1
188+
189+/* Define to 1 if you have the `setuid' function. */
190+#define HAVE_SETUID 1
191+
192+/* Define to 1 if you have the <signal.h> header file. */
193+#define HAVE_SIGNAL_H 1
194+
195+/* Define to 1 if you have the <sndio.h> header file. */
196+/* #undef HAVE_SNDIO_H */
197+
198+/* Define to 1 if you have the <stdint.h> header file. */
199+#define HAVE_STDINT_H 1
200+
201+/* Define to 1 if you have the <stdio.h> header file. */
202+#define HAVE_STDIO_H 1
203+
204+/* Define to 1 if you have the <stdlib.h> header file. */
205+#define HAVE_STDLIB_H 1
206+
207+/* Define to 1 if you have the `strerror' function. */
208+#define HAVE_STRERROR 1
209+
210+/* Define to 1 if you have the <strings.h> header file. */
211+#define HAVE_STRINGS_H 1
212+
213+/* Define to 1 if you have the <string.h> header file. */
214+#define HAVE_STRING_H 1
215+
216+/* Define to 1 if you have the <sun/audioio.h> header file. */
217+/* #undef HAVE_SUN_AUDIOIO_H */
218+
219+/* Define to 1 if you have the <sys/audioio.h> header file. */
220+/* #undef HAVE_SYS_AUDIOIO_H */
221+
222+/* Define to 1 if you have the <sys/audio.h> header file. */
223+/* #undef HAVE_SYS_AUDIO_H */
224+
225+/* Define to 1 if you have the <sys/ioctl.h> header file. */
226+#define HAVE_SYS_IOCTL_H 1
227+
228+/* Define to 1 if you have the <sys/param.h> header file. */
229+#define HAVE_SYS_PARAM_H 1
230+
231+/* Define to 1 if you have the <sys/resource.h> header file. */
232+#define HAVE_SYS_RESOURCE_H 1
233+
234+/* Define to 1 if you have the <sys/select.h> header file. */
235+#define HAVE_SYS_SELECT_H 1
236+
237+/* Define to 1 if you have the <sys/signal.h> header file. */
238+/* #undef HAVE_SYS_SIGNAL_H */
239+
240+/* Define to 1 if you have the <sys/socket.h> header file. */
241+#define HAVE_SYS_SOCKET_H 1
242+
243+/* Define to 1 if you have the <sys/soundcard.h> header file. */
244+/* #undef HAVE_SYS_SOUNDCARD_H */
245+
246+/* Define to 1 if you have the <sys/stat.h> header file. */
247+#define HAVE_SYS_STAT_H 1
248+
249+/* Define to 1 if you have the <sys/time.h> header file. */
250+#define HAVE_SYS_TIME_H 1
251+
252+/* Define to 1 if you have the <sys/types.h> header file. */
253+#define HAVE_SYS_TYPES_H 1
254+
255+/* Define to 1 if you have the <sys/wait.h> header file. */
256+#define HAVE_SYS_WAIT_H 1
257+
258+/* Define this if you have the POSIX termios library */
259+#define HAVE_TERMIOS 1
260+
261+/* Define to 1 if you have the <unistd.h> header file. */
262+#define HAVE_UNISTD_H 1
263+
264+/* Define to 1 if you have the <windows.h> header file. */
265+/* #undef HAVE_WINDOWS_H */
266+
267+/* Define to 1 if you have the <ws2tcpip.h> header file. */
268+/* #undef HAVE_WS2TCPIP_H */
269+
270+/* Define to indicate that float storage follows IEEE754. */
271+#define IEEE_FLOAT 1
272+
273+/* size of the frame index seek table */
274+#define INDEX_SIZE 1000
275+
276+/* Define if IPV6 support is enabled. */
277+#define IPV6 1
278+
279+/* Define this to the size of native offset type in bits, used for LFS alias
280+   functions. */
281+#define LFS_ALIAS_BITS 32
282+
283+/* Define to the extension used for runtime loadable modules, say, ".so". */
284+#define LT_MODULE_EXT ".so"
285+
286+/* Define to the sub-directory where libtool stores uninstalled libraries. */
287+#define LT_OBJDIR ".libs/"
288+
289+/* Define to the shared library suffix, say, ".dylib". */
290+/* #undef LT_SHARED_EXT */
291+
292+/* Define to the shared archive member specification, say "(shr.o)". */
293+/* #undef LT_SHARED_LIB_MEMBER */
294+
295+/* Define if network support is enabled. */
296+#define NETWORK 1
297+
298+/* Define to disable 16 bit integer output. */
299+/* #undef NO_16BIT */
300+
301+/* Define to disable 32 bit and 24 bit integer output. */
302+/* #undef NO_32BIT */
303+
304+/* Define to disable 8 bit integer output. */
305+/* #undef NO_8BIT */
306+
307+/* Define to disable downsampled decoding. */
308+/* #undef NO_DOWNSAMPLE */
309+
310+/* Define to disable equalizer. */
311+/* #undef NO_EQUALIZER */
312+
313+/* Define to disable error messages in combination with a return value (the
314+   return is left intact). */
315+/* #undef NO_ERETURN */
316+
317+/* Define to disable error messages. */
318+/* #undef NO_ERRORMSG */
319+
320+/* Define to disable feeder and buffered readers. */
321+/* #undef NO_FEEDER */
322+
323+/* Define to disable ICY handling. */
324+/* #undef NO_ICY */
325+
326+/* Define to disable ID3v2 parsing. */
327+/* #undef NO_ID3V2 */
328+
329+/* Define to disable layer I. */
330+/* #undef NO_LAYER1 */
331+
332+/* Define to disable layer II. */
333+/* #undef NO_LAYER2 */
334+
335+/* Define to disable layer III. */
336+/* #undef NO_LAYER3 */
337+
338+/* Define to disable ntom resampling. */
339+/* #undef NO_NTOM */
340+
341+/* Define to disable real output. */
342+/* #undef NO_REAL */
343+
344+/* Define to disable string functions. */
345+/* #undef NO_STRING */
346+
347+/* Define for post-processed 32 bit formats. */
348+/* #undef NO_SYNTH32 */
349+
350+/* Define to disable warning messages. */
351+/* #undef NO_WARNING */
352+
353+/* Name of package */
354+#define PACKAGE "mpg123"
355+
356+/* Define to the address where bug reports for this package should be sent. */
357+#define PACKAGE_BUGREPORT "maintainer@mpg123.org"
358+
359+/* Define to the full name of this package. */
360+#define PACKAGE_NAME "mpg123"
361+
362+/* Define to the full name and version of this package. */
363+#define PACKAGE_STRING "mpg123 1.25.6"
364+
365+/* Define to the one symbol short name of this package. */
366+#define PACKAGE_TARNAME "mpg123"
367+
368+/* Define to the home page for this package. */
369+#define PACKAGE_URL ""
370+
371+/* Define to the version of this package. */
372+#define PACKAGE_VERSION "1.25.6"
373+
374+/* Define if portaudio v18 API is wanted. */
375+/* #undef PORTAUDIO18 */
376+
377+/* The size of `int32_t', as computed by sizeof. */
378+#define SIZEOF_INT32_T 4
379+
380+/* The size of `long', as computed by sizeof. */
381+#define SIZEOF_LONG 4
382+
383+/* The size of `off_t', as computed by sizeof. */
384+#define SIZEOF_OFF_T 4
385+
386+/* The size of `size_t', as computed by sizeof. */
387+#define SIZEOF_SIZE_T 4
388+
389+/* The size of `ssize_t', as computed by sizeof. */
390+#define SIZEOF_SSIZE_T 4
391+
392+/* Define to 1 if you have the ANSI C header files. */
393+#define STDC_HEADERS 1
394+
395+/* Define if modules are enabled */
396+#define USE_MODULES 1
397+
398+/* Define for new Huffman decoding scheme. */
399+#define USE_NEW_HUFFTABLE 1
400+
401+/* Define to use yasm for assemble AVX sources. */
402+/* #undef USE_YASM_FOR_AVX */
403+
404+/* Version number of package */
405+#define VERSION "1.25.6"
406+
407+/* Define to use Win32 named pipes */
408+/* #undef WANT_WIN32_FIFO */
409+
410+/* Define to use Win32 sockets */
411+/* #undef WANT_WIN32_SOCKETS */
412+
413+/* Define to use Unicode for Windows */
414+/* #undef WANT_WIN32_UNICODE */
415+
416+/* WinXP and above for ipv6 */
417+/* #undef WINVER */
418+
419+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
420+   significant byte first (like Motorola and SPARC, unlike Intel). */
421+#if defined AC_APPLE_UNIVERSAL_BUILD
422+# if defined __BIG_ENDIAN__
423+#  define WORDS_BIGENDIAN 1
424+# endif
425+#else
426+# ifndef WORDS_BIGENDIAN
427+/* #  undef WORDS_BIGENDIAN */
428+# endif
429+#endif
430+
431+/* Enable large inode numbers on Mac OS X 10.5.  */
432+#ifndef _DARWIN_USE_64_BIT_INODE
433+# define _DARWIN_USE_64_BIT_INODE 1
434+#endif
435+
436+/* Number of bits in a file offset, on hosts where this is settable. */
437+/* #undef _FILE_OFFSET_BITS */
438+
439+/* Define for large files, on AIX-style hosts. */
440+/* #undef _LARGE_FILES */
441+
442+/* WinXP and above for ipv6 */
443+/* #undef _WIN32_WINNT */
444+
445+/* Define to empty if `const' does not conform to ANSI C. */
446+/* #undef const */
447+
448+/* Define to `__inline__' or `__inline' if that's what the C compiler
449+   calls it, or to nothing if 'inline' is not supported under any name.  */
450+#ifndef __cplusplus
451+/* #undef inline */
452+#endif
453+
454+/* Define to `short' if <sys/types.h> does not define. */
455+/* #undef int16_t */
456+
457+/* Define to `int' if <sys/types.h> does not define. */
458+/* #undef int32_t */
459+
460+/* Define to `long long' if <sys/types.h> does not define. */
461+/* #undef int64_t */
462+
463+/* Define to the native offset type (long or actually off_t). */
464+#define lfs_alias_t off_t
465+
466+/* Define to `long int' if <sys/types.h> does not define. */
467+/* #undef off_t */
468+
469+/* Define to `unsigned long' if <sys/types.h> does not define. */
470+/* #undef size_t */
471+
472+/* Define to `long' if <sys/types.h> does not define. */
473+/* #undef ssize_t */
474+
475+/* Define to `unsigned short' if <sys/types.h> does not define. */
476+/* #undef uint16_t */
477+
478+/* Define to `unsigned int' if <sys/types.h> does not define. */
479+/* #undef uint32_t */
480+
481+/* Define to `unsigned long' if <sys/types.h> does not define. */
482+/* #undef uintptr_t */
483diff -ruN mpg123-1.25.6.orig/android/mpg123.h mpg123-1.25.6/android/mpg123.h
484--- mpg123-1.25.6.orig/android/mpg123.h	1969-12-31 16:00:00.000000000 -0800
485+++ mpg123-1.25.6/android/mpg123.h	2017-10-23 07:43:01.919907577 -0700
486@@ -0,0 +1,1441 @@
487+/*
488+	libmpg123: MPEG Audio Decoder library (version 1.25.6)
489+
490+	copyright 1995-2015 by the mpg123 project
491+	free software under the terms of the LGPL 2.1
492+	see COPYING and AUTHORS files in distribution or http://mpg123.org
493+*/
494+
495+#ifndef MPG123_LIB_H
496+#define MPG123_LIB_H
497+
498+#include <fmt123.h>
499+
500+/** \file mpg123.h The header file for the libmpg123 MPEG Audio decoder */
501+
502+/** A macro to check at compile time which set of API functions to expect.
503+ * This should be incremented at least each time a new symbol is added
504+ * to the header.
505+ */
506+#define MPG123_API_VERSION 44
507+
508+#ifndef MPG123_EXPORT
509+/** Defines needed for MS Visual Studio(tm) DLL builds.
510+ * Every public function must be prefixed with MPG123_EXPORT. When building
511+ * the DLL ensure to define BUILD_MPG123_DLL. This makes the function accessible
512+ * for clients and includes it in the import library which is created together
513+ * with the DLL. When consuming the DLL ensure to define LINK_MPG123_DLL which
514+ * imports the functions from the DLL.
515+ */
516+#ifdef BUILD_MPG123_DLL
517+/* The dll exports. */
518+#define MPG123_EXPORT __declspec(dllexport)
519+#else
520+#ifdef LINK_MPG123_DLL
521+/* The exe imports. */
522+#define MPG123_EXPORT __declspec(dllimport)
523+#else
524+/* Nothing on normal/UNIX builds */
525+#define MPG123_EXPORT
526+#endif
527+#endif
528+#endif
529+
530+/* This is for Visual Studio, so this header works as distributed in the binary downloads */
531+#if defined(_MSC_VER) && !defined(MPG123_DEF_SSIZE_T)
532+#define MPG123_DEF_SSIZE_T
533+#include <stddef.h>
534+typedef ptrdiff_t ssize_t;
535+#endif
536+
537+#ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */
538+#include <stdlib.h>
539+#include <sys/types.h>
540+
541+/* Simplified large file handling.
542+	I used to have a check here that prevents building for a library with conflicting large file setup
543+	(application that uses 32 bit offsets with library that uses 64 bits).
544+	While that was perfectly fine in an environment where there is one incarnation of the library,
545+	it hurt GNU/Linux and Solaris systems with multilib where the distribution fails to provide the
546+	correct header matching the 32 bit library (where large files need explicit support) or
547+	the 64 bit library (where there is no distinction).
548+
549+	New approach: When the app defines _FILE_OFFSET_BITS, it wants non-default large file support,
550+	and thus functions with added suffix (mpg123_open_64).
551+	Any mismatch will be caught at link time because of the _FILE_OFFSET_BITS setting used when
552+	building libmpg123. Plus, there's dual mode large file support in mpg123 since 1.12 now.
553+	Link failure is not the expected outcome of any half-sane usage anymore.
554+
555+	More complication: What about client code defining _LARGEFILE64_SOURCE? It might want direct access to the _64 functions, along with the ones without suffix. Well, that's possible now via defining MPG123_NO_LARGENAME and MPG123_LARGESUFFIX, respectively, for disabling or enforcing the suffix names.
556+*/
557+
558+/*
559+	Now, the renaming of large file aware functions.
560+	By default, it appends underscore _FILE_OFFSET_BITS (so, mpg123_seek_64 for mpg123_seek), if _FILE_OFFSET_BITS is defined. You can force a different suffix via MPG123_LARGESUFFIX (that must include the underscore), or you can just disable the whole mess by defining MPG123_NO_LARGENAME.
561+*/
562+#if (!defined MPG123_NO_LARGENAME) && ((defined _FILE_OFFSET_BITS) || (defined MPG123_LARGESUFFIX))
563+
564+/* Need some trickery to concatenate the value(s) of the given macro(s). */
565+#define MPG123_MACROCAT_REALLY(a, b) a ## b
566+#define MPG123_MACROCAT(a, b) MPG123_MACROCAT_REALLY(a, b)
567+#ifndef MPG123_LARGESUFFIX
568+#define MPG123_LARGESUFFIX MPG123_MACROCAT(_, _FILE_OFFSET_BITS)
569+#endif
570+#define MPG123_LARGENAME(func) MPG123_MACROCAT(func, MPG123_LARGESUFFIX)
571+
572+#define mpg123_open         MPG123_LARGENAME(mpg123_open)
573+#define mpg123_open_fd      MPG123_LARGENAME(mpg123_open_fd)
574+#define mpg123_open_handle  MPG123_LARGENAME(mpg123_open_handle)
575+#define mpg123_framebyframe_decode MPG123_LARGENAME(mpg123_framebyframe_decode)
576+#define mpg123_decode_frame MPG123_LARGENAME(mpg123_decode_frame)
577+#define mpg123_tell         MPG123_LARGENAME(mpg123_tell)
578+#define mpg123_tellframe    MPG123_LARGENAME(mpg123_tellframe)
579+#define mpg123_tell_stream  MPG123_LARGENAME(mpg123_tell_stream)
580+#define mpg123_seek         MPG123_LARGENAME(mpg123_seek)
581+#define mpg123_feedseek     MPG123_LARGENAME(mpg123_feedseek)
582+#define mpg123_seek_frame   MPG123_LARGENAME(mpg123_seek_frame)
583+#define mpg123_timeframe    MPG123_LARGENAME(mpg123_timeframe)
584+#define mpg123_index        MPG123_LARGENAME(mpg123_index)
585+#define mpg123_set_index    MPG123_LARGENAME(mpg123_set_index)
586+#define mpg123_position     MPG123_LARGENAME(mpg123_position)
587+#define mpg123_length       MPG123_LARGENAME(mpg123_length)
588+#define mpg123_framelength  MPG123_LARGENAME(mpg123_framelength)
589+#define mpg123_set_filesize MPG123_LARGENAME(mpg123_set_filesize)
590+#define mpg123_replace_reader MPG123_LARGENAME(mpg123_replace_reader)
591+#define mpg123_replace_reader_handle MPG123_LARGENAME(mpg123_replace_reader_handle)
592+#define mpg123_framepos MPG123_LARGENAME(mpg123_framepos)
593+
594+#endif /* largefile hackery */
595+
596+#endif /* MPG123_NO_CONFIGURE */
597+
598+#ifdef __cplusplus
599+extern "C" {
600+#endif
601+
602+/** \defgroup mpg123_init mpg123 library and handle setup
603+ *
604+ * Functions to initialise and shutdown the mpg123 library and handles.
605+ * The parameters of handles have workable defaults, you only have to tune them when you want to tune something;-)
606+ * Tip: Use a RVA setting...
607+ *
608+ * @{
609+ */
610+
611+/** Opaque structure for the libmpg123 decoder handle. */
612+struct mpg123_handle_struct;
613+
614+/** Opaque structure for the libmpg123 decoder handle.
615+ *  Most functions take a pointer to a mpg123_handle as first argument and operate on its data in an object-oriented manner.
616+ */
617+typedef struct mpg123_handle_struct mpg123_handle;
618+
619+/** Function to initialise the mpg123 library.
620+ *	This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library.
621+ *
622+ *	\return MPG123_OK if successful, otherwise an error number.
623+ */
624+MPG123_EXPORT int mpg123_init(void);
625+
626+/** Function to close down the mpg123 library.
627+ *	This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library. */
628+MPG123_EXPORT void mpg123_exit(void);
629+
630+/** Create a handle with optional choice of decoder (named by a string, see mpg123_decoders() or mpg123_supported_decoders()).
631+ *  and optional retrieval of an error code to feed to mpg123_plain_strerror().
632+ *  Optional means: Any of or both the parameters may be NULL.
633+ *
634+ *  \param decoder optional choice of decoder variant (NULL for default)
635+ *  \param error optional address to store error codes
636+ *  \return Non-NULL pointer to fresh handle when successful.
637+ */
638+MPG123_EXPORT mpg123_handle *mpg123_new(const char* decoder, int *error);
639+
640+/** Delete handle, mh is either a valid mpg123 handle or NULL.
641+ *  \param mh handle
642+ */
643+MPG123_EXPORT void mpg123_delete(mpg123_handle *mh);
644+
645+/** Enumeration of the parameters types that it is possible to set/get. */
646+enum mpg123_parms
647+{
648+	MPG123_VERBOSE = 0,        /**< set verbosity value for enabling messages to stderr, >= 0 makes sense (integer) */
649+	MPG123_FLAGS,          /**< set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX (integer) */
650+	MPG123_ADD_FLAGS,      /**< add some flags (integer) */
651+	MPG123_FORCE_RATE,     /**< when value > 0, force output rate to that value (integer) */
652+	MPG123_DOWN_SAMPLE,    /**< 0=native rate, 1=half rate, 2=quarter rate (integer) */
653+	MPG123_RVA,            /**< one of the RVA choices above (integer) */
654+	MPG123_DOWNSPEED,      /**< play a frame N times (integer) */
655+	MPG123_UPSPEED,        /**< play every Nth frame (integer) */
656+	MPG123_START_FRAME,    /**< start with this frame (skip frames before that, integer) */
657+	MPG123_DECODE_FRAMES,  /**< decode only this number of frames (integer) */
658+	MPG123_ICY_INTERVAL,   /**< stream contains ICY metadata with this interval (integer) */
659+	MPG123_OUTSCALE,       /**< the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer) */
660+	MPG123_TIMEOUT,        /**< timeout for reading from a stream (not supported on win32, integer) */
661+	MPG123_REMOVE_FLAGS,   /**< remove some flags (inverse of MPG123_ADD_FLAGS, integer) */
662+	MPG123_RESYNC_LIMIT,   /**< Try resync on frame parsing for that many bytes or until end of stream (<0 ... integer). This can enlarge the limit for skipping junk on beginning, too (but not reduce it).  */
663+	MPG123_INDEX_SIZE      /**< Set the frame index size (if supported). Values <0 mean that the index is allowed to grow dynamically in these steps (in positive direction, of course) -- Use this when you really want a full index with every individual frame. */
664+	,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.*/
665+	,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) */
666+	,MPG123_FEEDBUFFER /**< Minimal size of one internal feeder buffer, again, the default value is subject to change. (integer) */
667+};
668+
669+/** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */
670+enum mpg123_param_flags
671+{
672+	 MPG123_FORCE_MONO   = 0x7  /**<     0111 Force some mono mode: This is a test bitmask for seeing if any mono forcing is active. */
673+	,MPG123_MONO_LEFT    = 0x1  /**<     0001 Force playback of left channel only.  */
674+	,MPG123_MONO_RIGHT   = 0x2  /**<     0010 Force playback of right channel only. */
675+	,MPG123_MONO_MIX     = 0x4  /**<     0100 Force playback of mixed mono.         */
676+	,MPG123_FORCE_STEREO = 0x8  /**<     1000 Force stereo output.                  */
677+	,MPG123_FORCE_8BIT   = 0x10 /**< 00010000 Force 8bit formats.                   */
678+	,MPG123_QUIET        = 0x20 /**< 00100000 Suppress any printouts (overrules verbose).                    */
679+	,MPG123_GAPLESS      = 0x40 /**< 01000000 Enable gapless decoding (default on if libmpg123 has support). */
680+	,MPG123_NO_RESYNC    = 0x80 /**< 10000000 Disable resync stream after error.                             */
681+	,MPG123_SEEKBUFFER   = 0x100 /**< 000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync). */
682+	,MPG123_FUZZY        = 0x200 /**< 001000000000 Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC) */
683+	,MPG123_FORCE_FLOAT  = 0x400 /**< 010000000000 Force floating point output (32 or 64 bits depends on mpg123 internal precision). */
684+	,MPG123_PLAIN_ID3TEXT = 0x800 /**< 100000000000 Do not translate ID3 text data to UTF-8. ID3 strings will contain the raw text data, with the first byte containing the ID3 encoding code. */
685+	,MPG123_IGNORE_STREAMLENGTH = 0x1000 /**< 1000000000000 Ignore any stream length information contained in the stream, which can be contained in a 'TLEN' frame of an ID3v2 tag or a Xing tag */
686+	,MPG123_SKIP_ID3V2 = 0x2000 /**< 10 0000 0000 0000 Do not parse ID3v2 tags, just skip them. */
687+	,MPG123_IGNORE_INFOFRAME = 0x4000 /**< 100 0000 0000 0000 Do not parse the LAME/Xing info frame, treat it as normal MPEG data. */
688+	,MPG123_AUTO_RESAMPLE = 0x8000 /**< 1000 0000 0000 0000 Allow automatic internal resampling of any kind (default on if supported). Especially when going lowlevel with replacing output buffer, you might want to unset this flag. Setting MPG123_DOWNSAMPLE or MPG123_FORCE_RATE will override this. */
689+	,MPG123_PICTURE = 0x10000 /**< 17th bit: Enable storage of pictures from tags (ID3v2 APIC). */
690+	,MPG123_NO_PEEK_END    = 0x20000 /**< 18th bit: Do not seek to the end of
691+	 *  the stream in order to probe
692+	 *  the stream length and search for the id3v1 field. This also means
693+	 *  the file size is unknown unless set using mpg123_set_filesize() and
694+	 *  the stream is assumed as non-seekable unless overridden.
695+	 */
696+	,MPG123_FORCE_SEEKABLE = 0x40000 /**< 19th bit: Force the stream to be seekable. */
697+};
698+
699+/** choices for MPG123_RVA */
700+enum mpg123_param_rva
701+{
702+	 MPG123_RVA_OFF   = 0 /**< RVA disabled (default).   */
703+	,MPG123_RVA_MIX   = 1 /**< Use mix/track/radio gain. */
704+	,MPG123_RVA_ALBUM = 2 /**< Use album/audiophile gain */
705+	,MPG123_RVA_MAX   = MPG123_RVA_ALBUM /**< The maximum RVA code, may increase in future. */
706+};
707+
708+/** Set a specific parameter, for a specific mpg123_handle, using a parameter
709+ *  type key chosen from the mpg123_parms enumeration, to the specified value.
710+ *  \param mh handle
711+ *  \param type parameter choice
712+ *  \param value integer value
713+ *  \param fvalue floating point value
714+ *  \return MPG123_OK on success
715+ */
716+MPG123_EXPORT int mpg123_param( mpg123_handle *mh
717+,	enum mpg123_parms type, long value, double fvalue );
718+
719+/** Get a specific parameter, for a specific mpg123_handle.
720+ *  See the mpg123_parms enumeration for a list of available parameters.
721+ *  \param mh handle
722+ *  \param type parameter choice
723+ *  \param value integer value return address
724+ *  \param fvalue floating point value return address
725+ *  \return MPG123_OK on success
726+ */
727+MPG123_EXPORT int mpg123_getparam( mpg123_handle *mh
728+,	enum mpg123_parms type, long *value, double *fvalue );
729+
730+/** Feature set available for query with mpg123_feature. */
731+enum mpg123_feature_set
732+{
733+	 MPG123_FEATURE_ABI_UTF8OPEN = 0     /**< mpg123 expects path names to be given in UTF-8 encoding instead of plain native. */
734+	,MPG123_FEATURE_OUTPUT_8BIT          /**< 8bit output   */
735+	,MPG123_FEATURE_OUTPUT_16BIT         /**< 16bit output  */
736+	,MPG123_FEATURE_OUTPUT_32BIT         /**< 32bit output  */
737+	,MPG123_FEATURE_INDEX                /**< support for building a frame index for accurate seeking */
738+	,MPG123_FEATURE_PARSE_ID3V2          /**< id3v2 parsing */
739+	,MPG123_FEATURE_DECODE_LAYER1        /**< mpeg layer-1 decoder enabled */
740+	,MPG123_FEATURE_DECODE_LAYER2        /**< mpeg layer-2 decoder enabled */
741+	,MPG123_FEATURE_DECODE_LAYER3        /**< mpeg layer-3 decoder enabled */
742+	,MPG123_FEATURE_DECODE_ACCURATE      /**< accurate decoder rounding    */
743+	,MPG123_FEATURE_DECODE_DOWNSAMPLE    /**< downsample (sample omit)     */
744+	,MPG123_FEATURE_DECODE_NTOM          /**< flexible rate decoding       */
745+	,MPG123_FEATURE_PARSE_ICY            /**< ICY support                  */
746+	,MPG123_FEATURE_TIMEOUT_READ         /**< Reader with timeout (network). */
747+	,MPG123_FEATURE_EQUALIZER            /**< tunable equalizer */
748+};
749+
750+/** Query libmpg123 features.
751+ *  \param key feature selection
752+ *  \return 1 for success, 0 for unimplemented functions
753+ */
754+MPG123_EXPORT int mpg123_feature(const enum mpg123_feature_set key);
755+
756+/* @} */
757+
758+
759+/** \defgroup mpg123_error mpg123 error handling
760+ *
761+ * Functions to get text version of the error numbers and an enumeration
762+ * of the error codes returned by libmpg123.
763+ *
764+ * Most functions operating on a mpg123_handle simply return MPG123_OK (0)
765+ * on success and MPG123_ERR (-1) on failure, setting the internal error
766+ * variable of the handle to the specific error code. If there was not a valid
767+ * (non-NULL) handle provided to a function operating on one, MPG123_BAD_HANDLE
768+ * may be returned if this can not be confused with a valid positive return
769+ * value.
770+ * Meaning: A function expected to return positive integers on success will
771+ * always indicate error or a special condition by returning a negative one.
772+ *
773+ * Decoding/seek functions may also return message codes MPG123_DONE,
774+ * MPG123_NEW_FORMAT and MPG123_NEED_MORE (all negative, see below on how to
775+ * react). Note that calls to those can be nested, so generally watch out
776+ * for these codes after initial handle setup.
777+ * Especially any function that needs information about the current stream
778+ * to work will try to at least parse the beginning if that did not happen
779+ * yet.
780+ *
781+ * On a function that is supposed to return MPG123_OK on success and
782+ * MPG123_ERR on failure, make sure you check for != MPG123_OK, not
783+ * == MPG123_ERR, as the error code could get more specific in future,
784+ * or there is just a special message from a decoding routine as indicated
785+ * above.
786+ *
787+ * @{
788+ */
789+
790+/** Enumeration of the message and error codes and returned by libmpg123 functions. */
791+enum mpg123_errors
792+{
793+	MPG123_DONE=-12,	/**< Message: Track ended. Stop decoding. */
794+	MPG123_NEW_FORMAT=-11,	/**< Message: Output format will be different on next call. Note that some libmpg123 versions between 1.4.3 and 1.8.0 insist on you calling mpg123_getformat() after getting this message code. Newer verisons behave like advertised: You have the chance to call mpg123_getformat(), but you can also just continue decoding and get your data. */
795+	MPG123_NEED_MORE=-10,	/**< Message: For feed reader: "Feed me more!" (call mpg123_feed() or mpg123_decode() with some new input data). */
796+	MPG123_ERR=-1,			/**< Generic Error */
797+	MPG123_OK=0, 			/**< Success */
798+	MPG123_BAD_OUTFORMAT, 	/**< Unable to set up output format! */
799+	MPG123_BAD_CHANNEL,		/**< Invalid channel number specified. */
800+	MPG123_BAD_RATE,		/**< Invalid sample rate specified.  */
801+	MPG123_ERR_16TO8TABLE,	/**< Unable to allocate memory for 16 to 8 converter table! */
802+	MPG123_BAD_PARAM,		/**< Bad parameter id! */
803+	MPG123_BAD_BUFFER,		/**< Bad buffer given -- invalid pointer or too small size. */
804+	MPG123_OUT_OF_MEM,		/**< Out of memory -- some malloc() failed. */
805+	MPG123_NOT_INITIALIZED,	/**< You didn't initialize the library! */
806+	MPG123_BAD_DECODER,		/**< Invalid decoder choice. */
807+	MPG123_BAD_HANDLE,		/**< Invalid mpg123 handle. */
808+	MPG123_NO_BUFFERS,		/**< Unable to initialize frame buffers (out of memory?). */
809+	MPG123_BAD_RVA,			/**< Invalid RVA mode. */
810+	MPG123_NO_GAPLESS,		/**< This build doesn't support gapless decoding. */
811+	MPG123_NO_SPACE,		/**< Not enough buffer space. */
812+	MPG123_BAD_TYPES,		/**< Incompatible numeric data types. */
813+	MPG123_BAD_BAND,		/**< Bad equalizer band. */
814+	MPG123_ERR_NULL,		/**< Null pointer given where valid storage address needed. */
815+	MPG123_ERR_READER,		/**< Error reading the stream. */
816+	MPG123_NO_SEEK_FROM_END,/**< Cannot seek from end (end is not known). */
817+	MPG123_BAD_WHENCE,		/**< Invalid 'whence' for seek function.*/
818+	MPG123_NO_TIMEOUT,		/**< Build does not support stream timeouts. */
819+	MPG123_BAD_FILE,		/**< File access error. */
820+	MPG123_NO_SEEK,			/**< Seek not supported by stream. */
821+	MPG123_NO_READER,		/**< No stream opened. */
822+	MPG123_BAD_PARS,		/**< Bad parameter handle. */
823+	MPG123_BAD_INDEX_PAR,	/**< Bad parameters to mpg123_index() and mpg123_set_index() */
824+	MPG123_OUT_OF_SYNC,	/**< Lost track in bytestream and did not try to resync. */
825+	MPG123_RESYNC_FAIL,	/**< Resync failed to find valid MPEG data. */
826+	MPG123_NO_8BIT,	/**< No 8bit encoding possible. */
827+	MPG123_BAD_ALIGN,	/**< Stack aligmnent error */
828+	MPG123_NULL_BUFFER,	/**< NULL input buffer with non-zero size... */
829+	MPG123_NO_RELSEEK,	/**< Relative seek not possible (screwed up file offset) */
830+	MPG123_NULL_POINTER, /**< You gave a null pointer somewhere where you shouldn't have. */
831+	MPG123_BAD_KEY,	/**< Bad key value given. */
832+	MPG123_NO_INDEX,	/**< No frame index in this build. */
833+	MPG123_INDEX_FAIL,	/**< Something with frame index went wrong. */
834+	MPG123_BAD_DECODER_SETUP,	/**< Something prevents a proper decoder setup */
835+	MPG123_MISSING_FEATURE  /**< This feature has not been built into libmpg123. */
836+	,MPG123_BAD_VALUE /**< A bad value has been given, somewhere. */
837+	,MPG123_LSEEK_FAILED /**< Low-level seek failed. */
838+	,MPG123_BAD_CUSTOM_IO /**< Custom I/O not prepared. */
839+	,MPG123_LFS_OVERFLOW /**< Offset value overflow during translation of large file API calls -- your client program cannot handle that large file. */
840+	,MPG123_INT_OVERFLOW /**< Some integer overflow. */
841+};
842+
843+/** Look up error strings given integer code.
844+ *  \param errcode integer error code
845+ *  \return string describing what that error error code means
846+ */
847+MPG123_EXPORT const char* mpg123_plain_strerror(int errcode);
848+
849+/** Give string describing what error has occured in the context of handle mh.
850+ *  When a function operating on an mpg123 handle returns MPG123_ERR, you should check for the actual reason via
851+ *  char *errmsg = mpg123_strerror(mh)
852+ *  This function will catch mh == NULL and return the message for MPG123_BAD_HANDLE.
853+ *  \param mh handle
854+ *  \return error message
855+ */
856+MPG123_EXPORT const char* mpg123_strerror(mpg123_handle *mh);
857+
858+/** Return the plain errcode intead of a string.
859+ *  \param mh handle
860+ *  \return error code recorded in handle or MPG123_BAD_HANDLE
861+ */
862+MPG123_EXPORT int mpg123_errcode(mpg123_handle *mh);
863+
864+/*@}*/
865+
866+
867+/** \defgroup mpg123_decoder mpg123 decoder selection
868+ *
869+ * Functions to list and select the available decoders.
870+ * Perhaps the most prominent feature of mpg123: You have several (optimized) decoders to choose from (on x86 and PPC (MacOS) systems, that is).
871+ *
872+ * @{
873+ */
874+
875+/** Get available decoder list.
876+ *  \return NULL-terminated array of generally available decoder names (plain 8bit ASCII)
877+ */
878+MPG123_EXPORT const char **mpg123_decoders(void);
879+
880+/** Get supported decoder list.
881+ *  \return NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII)
882+ */
883+MPG123_EXPORT const char **mpg123_supported_decoders(void);
884+
885+/** Set the active decoder.
886+ *  \param mh handle
887+ *  \param decoder_name name of decoder
888+ *  \return MPG123_OK on success
889+ */
890+MPG123_EXPORT int mpg123_decoder(mpg123_handle *mh, const char* decoder_name);
891+
892+/** Get the currently active decoder name.
893+ *  The active decoder engine can vary depening on output constraints,
894+ *  mostly non-resampling, integer output is accelerated via 3DNow & Co. but for
895+ *  other modes a fallback engine kicks in.
896+ *  Note that this can return a decoder that is only active in the hidden and not
897+ *  available as decoder choice from the outside.
898+ *  \param mh handle
899+ *  \return The decoder name or NULL on error.
900+ */
901+MPG123_EXPORT const char* mpg123_current_decoder(mpg123_handle *mh);
902+
903+/*@}*/
904+
905+
906+/** \defgroup mpg123_output mpg123 output audio format
907+ *
908+ * Functions to get and select the format of the decoded audio.
909+ *
910+ * 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.
911+ *
912+ * 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).
913+ *
914+ * To get to the point: What you do with mpg123_format() and friends is to fill the internal table of allowed formats before it is used. That includes removing support for some formats or adding your forced sample rate (see MPG123_FORCE_RATE) that will be used with the crude internal resampler. Also keep in mind that the sample encoding is just a question of choice -- the MPEG frames do only indicate their native sampling rate and channel count. If you want to decode to integer or float samples, 8 or 16 bit ... that is your decision. In a "clean" world, libmpg123 would always decode to 32 bit float and let you handle any sample conversion. But there are optimized routines that work faster by directly decoding to the desired encoding / accuracy. We prefer efficiency over conceptual tidyness.
915+ *
916+ * People often start out thinking that mpg123_format() should change the actual decoding format on the fly. That is wrong. It only has effect on the next natural change of output format, when libmpg123 will consult its format table again. To make life easier, you might want to call mpg123_format_none() before any thing else and then just allow one desired encoding and a limited set of sample rates / channel choices that you actually intend to deal with. You can force libmpg123 to decode everything to 44100 KHz, stereo, 16 bit integer ... it will duplicate mono channels and even do resampling if needed (unless that feature is disabled in the build, same with some encodings). But I have to stress that the resampling of libmpg123 is very crude and doesn't even contain any kind of "proper" interpolation.
917+ *
918+ * In any case, watch out for MPG123_NEW_FORMAT as return message from decoding routines and call mpg123_getformat() to get the currently active output format.
919+ *
920+ * @{
921+ */
922+
923+/** They can be combined into one number (3) to indicate mono and stereo... */
924+enum mpg123_channelcount
925+{
926+	 MPG123_MONO   = 1 /**< mono */
927+	,MPG123_STEREO = 2 /**< stereo */
928+};
929+
930+/** An array of supported standard sample rates
931+ *  These are possible native sample rates of MPEG audio files.
932+ *  You can still force mpg123 to resample to a different one, but by default you will only get audio in one of these samplings.
933+ *  \param list Store a pointer to the sample rates array there.
934+ *  \param number Store the number of sample rates there. */
935+MPG123_EXPORT void mpg123_rates(const long **list, size_t *number);
936+
937+/** An array of supported audio encodings.
938+ *  An audio encoding is one of the fully qualified members of mpg123_enc_enum (MPG123_ENC_SIGNED_16, not MPG123_SIGNED).
939+ *  \param list Store a pointer to the encodings array there.
940+ *  \param number Store the number of encodings there. */
941+MPG123_EXPORT void mpg123_encodings(const int **list, size_t *number);
942+
943+/** Return the size (in bytes) of one mono sample of the named encoding.
944+ * \param encoding The encoding value to analyze.
945+ * \return positive size of encoding in bytes, 0 on invalid encoding. */
946+MPG123_EXPORT int mpg123_encsize(int encoding);
947+
948+/** Configure a mpg123 handle to accept no output format at all,
949+ *  use before specifying supported formats with mpg123_format
950+ *  \param mh handle
951+ *  \return MPG123_OK on success
952+ */
953+MPG123_EXPORT int mpg123_format_none(mpg123_handle *mh);
954+
955+/** Configure mpg123 handle to accept all formats
956+ *  (also any custom rate you may set) -- this is default.
957+ *  \param mh handle
958+ *  \return MPG123_OK on success
959+ */
960+MPG123_EXPORT int mpg123_format_all(mpg123_handle *mh);
961+
962+/** Set the audio format support of a mpg123_handle in detail:
963+ *  \param mh handle
964+ *  \param rate The sample rate value (in Hertz).
965+ *  \param channels A combination of MPG123_STEREO and MPG123_MONO.
966+ *  \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.
967+ *  \return MPG123_OK on success, MPG123_ERR if there was an error. */
968+MPG123_EXPORT int mpg123_format( mpg123_handle *mh
969+,	long rate, int channels, int encodings );
970+
971+/** Check to see if a specific format at a specific rate is supported
972+ *  by mpg123_handle.
973+ *  \param mh handle
974+ *  \param rate sampling rate
975+ *  \param encoding encoding
976+ *  \return 0 for no support (that includes invalid parameters), MPG123_STEREO,
977+ *          MPG123_MONO or MPG123_STEREO|MPG123_MONO. */
978+MPG123_EXPORT int mpg123_format_support( mpg123_handle *mh
979+,	long rate, int encoding );
980+
981+/** Get the current output format written to the addresses given.
982+ *  If the stream is freshly loaded, this will try to parse enough
983+ *  of it to give you the format to come. This clears the flag that
984+ *  would otherwise make the first decoding call return
985+ *  MPG123_NEW_FORMAT.
986+ *  \param mh handle
987+ *  \param rate sampling rate return address
988+ *  \param channels channel count return address
989+ *  \param encoding encoding return address
990+ *  \return MPG123_OK on success
991+ */
992+MPG123_EXPORT int mpg123_getformat( mpg123_handle *mh
993+,	long *rate, int *channels, int *encoding );
994+
995+/** Get the current output format written to the addresses given.
996+ *  This differs from plain mpg123_getformat() in that you can choose
997+ *  _not_ to clear the flag that would trigger the next decoding call
998+ *  to return MPG123_NEW_FORMAT in case of a new format arriving.
999+ *  \param mh handle
1000+ *  \param rate sampling rate return address
1001+ *  \param channels channel count return address
1002+ *  \param encoding encoding return address
1003+ *  \param clear_flag if true, clear internal format flag
1004+ *  \return MPG123_OK on success
1005+ */
1006+MPG123_EXPORT int mpg123_getformat2( mpg123_handle *mh
1007+,	long *rate, int *channels, int *encoding, int clear_flag );
1008+
1009+/*@}*/
1010+
1011+
1012+/** \defgroup mpg123_input mpg123 file input and decoding
1013+ *
1014+ * Functions for input bitstream and decoding operations.
1015+ * Decoding/seek functions may also return message codes MPG123_DONE, MPG123_NEW_FORMAT and MPG123_NEED_MORE (please read up on these on how to react!).
1016+ * @{
1017+ */
1018+
1019+/* reading samples / triggering decoding, possible return values: */
1020+/** Enumeration of the error codes returned by libmpg123 functions. */
1021+
1022+/** Open and prepare to decode the specified file by filesystem path.
1023+ *  This does not open HTTP urls; libmpg123 contains no networking code.
1024+ *  If you want to decode internet streams, use mpg123_open_fd() or mpg123_open_feed().
1025+ *  \param mh handle
1026+ *  \param path filesystem path
1027+ *  \return MPG123_OK on success
1028+ */
1029+MPG123_EXPORT int mpg123_open(mpg123_handle *mh, const char *path);
1030+
1031+/** Use an already opened file descriptor as the bitstream input
1032+ *  mpg123_close() will _not_ close the file descriptor.
1033+ *  \param mh handle
1034+ *  \param fd file descriptor
1035+ *  \return MPG123_OK on success
1036+ */
1037+MPG123_EXPORT int mpg123_open_fd(mpg123_handle *mh, int fd);
1038+
1039+/** Use an opaque handle as bitstream input. This works only with the
1040+ *  replaced I/O from mpg123_replace_reader_handle()!
1041+ *  mpg123_close() will call the cleanup callback for your handle (if you gave one).
1042+ *  \param mh handle
1043+ *  \param iohandle your handle
1044+ *  \return MPG123_OK on success
1045+ */
1046+MPG123_EXPORT int mpg123_open_handle(mpg123_handle *mh, void *iohandle);
1047+
1048+/** Open a new bitstream and prepare for direct feeding
1049+ *  This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream.
1050+ *  \param mh handle
1051+ *  \return MPG123_OK on success
1052+ */
1053+MPG123_EXPORT int mpg123_open_feed(mpg123_handle *mh);
1054+
1055+/** Closes the source, if libmpg123 opened it.
1056+ *  \param mh handle
1057+ *  \return MPG123_OK on success
1058+ */
1059+MPG123_EXPORT int mpg123_close(mpg123_handle *mh);
1060+
1061+/** Read from stream and decode up to outmemsize bytes.
1062+ *  \param mh handle
1063+ *  \param outmemory address of output buffer to write to
1064+ *  \param outmemsize maximum number of bytes to write
1065+ *  \param done address to store the number of actually decoded bytes to
1066+ *  \return MPG123_OK or error/message code
1067+ */
1068+MPG123_EXPORT int mpg123_read(mpg123_handle *mh
1069+,	unsigned char *outmemory, size_t outmemsize, size_t *done );
1070+
1071+/** Feed data for a stream that has been opened with mpg123_open_feed().
1072+ *  It's give and take: You provide the bytestream, mpg123 gives you the decoded samples.
1073+ *  \param mh handle
1074+ *  \param in input buffer
1075+ *  \param size number of input bytes
1076+ *  \return MPG123_OK or error/message code.
1077+ */
1078+MPG123_EXPORT int mpg123_feed( mpg123_handle *mh
1079+,	const unsigned char *in, size_t size );
1080+
1081+/** Decode MPEG Audio from inmemory to outmemory.
1082+ *  This is very close to a drop-in replacement for old mpglib.
1083+ *  When you give zero-sized output buffer the input will be parsed until
1084+ *  decoded data is available. This enables you to get MPG123_NEW_FORMAT (and query it)
1085+ *  without taking decoded data.
1086+ *  Think of this function being the union of mpg123_read() and mpg123_feed() (which it actually is, sort of;-).
1087+ *  You can actually always decide if you want those specialized functions in separate steps or one call this one here.
1088+ *  \param mh handle
1089+ *  \param inmemory input buffer
1090+ *  \param inmemsize number of input bytes
1091+ *  \param outmemory output buffer
1092+ *  \param outmemsize maximum number of output bytes
1093+ *  \param done address to store the number of actually decoded bytes to
1094+ *  \return error/message code (watch out especially for MPG123_NEED_MORE)
1095+ */
1096+MPG123_EXPORT int mpg123_decode( mpg123_handle *mh
1097+,	const unsigned char *inmemory, size_t inmemsize
1098+,	unsigned char *outmemory, size_t outmemsize, size_t *done );
1099+
1100+/** Decode next MPEG frame to internal buffer
1101+ *  or read a frame and return after setting a new format.
1102+ *  \param mh handle
1103+ *  \param num current frame offset gets stored there
1104+ *  \param audio This pointer is set to the internal buffer to read the decoded audio from.
1105+ *  \param bytes number of output bytes ready in the buffer
1106+ *  \return MPG123_OK or error/message code
1107+ */
1108+MPG123_EXPORT int mpg123_decode_frame( mpg123_handle *mh
1109+,	off_t *num, unsigned char **audio, size_t *bytes );
1110+
1111+/** Decode current MPEG frame to internal buffer.
1112+ * Warning: This is experimental API that might change in future releases!
1113+ * Please watch mpg123 development closely when using it.
1114+ *  \param mh handle
1115+ *  \param num last frame offset gets stored there
1116+ *  \param audio this pointer is set to the internal buffer to read the decoded audio from.
1117+ *  \param bytes number of output bytes ready in the buffer
1118+ *  \return MPG123_OK or error/message code
1119+ */
1120+MPG123_EXPORT int mpg123_framebyframe_decode( mpg123_handle *mh
1121+,	off_t *num, unsigned char **audio, size_t *bytes );
1122+
1123+/** Find, read and parse the next mp3 frame
1124+ * Warning: This is experimental API that might change in future releases!
1125+ * Please watch mpg123 development closely when using it.
1126+ *  \param mh handle
1127+ *  \return MPG123_OK or error/message code
1128+ */
1129+MPG123_EXPORT int mpg123_framebyframe_next(mpg123_handle *mh);
1130+
1131+/** Get access to the raw input data for the last parsed frame.
1132+ * This gives you a direct look (and write access) to the frame body data.
1133+ * Together with the raw header, you can reconstruct the whole raw MPEG stream without junk and meta data, or play games by actually modifying the frame body data before decoding this frame (mpg123_framebyframe_decode()).
1134+ * A more sane use would be to use this for CRC checking (see mpg123_info() and MPG123_CRC), the first two bytes of the body make up the CRC16 checksum, if present.
1135+ * You can provide NULL for a parameter pointer when you are not interested in the value.
1136+ *
1137+ * \param mh handle
1138+ * \param header the 4-byte MPEG header
1139+ * \param bodydata pointer to the frame body stored in the handle (without the header)
1140+ * \param bodybytes size of frame body in bytes (without the header)
1141+ * \return MPG123_OK if there was a yet un-decoded frame to get the
1142+ *    data from, MPG123_BAD_HANDLE or MPG123_ERR otherwise (without further
1143+ *    explanation, the error state of the mpg123_handle is not modified by
1144+ *    this function).
1145+ */
1146+MPG123_EXPORT int mpg123_framedata( mpg123_handle *mh
1147+,	unsigned long *header, unsigned char **bodydata, size_t *bodybytes );
1148+
1149+/** Get the input position (byte offset in stream) of the last parsed frame.
1150+ *  This can be used for external seek index building, for example.
1151+ *  It just returns the internally stored offset, regardless of validity --
1152+ *  you ensure that a valid frame has been parsed before!
1153+ * \param mh handle
1154+ * \return byte offset in stream
1155+ */
1156+MPG123_EXPORT off_t mpg123_framepos(mpg123_handle *mh);
1157+
1158+/*@}*/
1159+
1160+
1161+/** \defgroup mpg123_seek mpg123 position and seeking
1162+ *
1163+ * Functions querying and manipulating position in the decoded audio bitstream.
1164+ * The position is measured in decoded audio samples, or MPEG frame offset for the specific functions.
1165+ * 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;-)
1166+ * The general usage is modelled after stdlib's ftell() and fseek().
1167+ * 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:
1168+ * - SEEK_SET: set position to (or near to) specified offset
1169+ * - SEEK_CUR: change position by offset from now
1170+ * - SEEK_END: set position to offset from end
1171+ *
1172+ * Note that sample-accurate seek only works when gapless support has been enabled at compile time; seek is frame-accurate otherwise.
1173+ * 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)!
1174+ * Short: When you care about the sample position, don't mess with those parameters;-)
1175+ * Also, seeking is not guaranteed to work for all streams (underlying stream may not support it).
1176+ * And yet another caveat: If the stream is concatenated out of differing pieces (Frankenstein stream), seeking may suffer, too.
1177+ *
1178+ * @{
1179+ */
1180+
1181+/** Returns the current position in samples.
1182+ *  On the next successful read, you'd get that sample.
1183+ *  \param mh handle
1184+ *  \return sample offset or MPG123_ERR (null handle)
1185+ */
1186+MPG123_EXPORT off_t mpg123_tell(mpg123_handle *mh);
1187+
1188+/** Returns the frame number that the next read will give you data from.
1189+ *  \param mh handle
1190+ *  \return frame offset or MPG123_ERR (null handle)
1191+ */
1192+MPG123_EXPORT off_t mpg123_tellframe(mpg123_handle *mh);
1193+
1194+/** Returns the current byte offset in the input stream.
1195+ *  \param mh handle
1196+ *  \return byte offset or MPG123_ERR (null handle)
1197+ */
1198+MPG123_EXPORT off_t mpg123_tell_stream(mpg123_handle *mh);
1199+
1200+/** Seek to a desired sample offset.
1201+ *  Usage is modelled afer the standard lseek().
1202+ * \param mh handle
1203+ * \param sampleoff offset in PCM samples
1204+ * \param whence one of SEEK_SET, SEEK_CUR or SEEK_END
1205+ * \return The resulting offset >= 0 or error/message code
1206+ */
1207+MPG123_EXPORT off_t mpg123_seek( mpg123_handle *mh
1208+,	off_t sampleoff, int whence );
1209+
1210+/** Seek to a desired sample offset in data feeding mode.
1211+ *  This just prepares things to be right only if you ensure that the next chunk of input data will be from input_offset byte position.
1212+ *  \param mh handle
1213+ *  \param sampleoff offset in PCM samples
1214+ *  \param whence one of SEEK_SET, SEEK_CUR or SEEK_END
1215+ *  \param input_offset The position it expects to be at the
1216+ *                      next time data is fed to mpg123_decode().
1217+ *  \return The resulting offset >= 0 or error/message code */
1218+MPG123_EXPORT off_t mpg123_feedseek( mpg123_handle *mh
1219+,	off_t sampleoff, int whence, off_t *input_offset );
1220+
1221+/** Seek to a desired MPEG frame offset.
1222+ *  Usage is modelled afer the standard lseek().
1223+ * \param mh handle
1224+ * \param frameoff offset in MPEG frames
1225+ * \param whence one of SEEK_SET, SEEK_CUR or SEEK_END
1226+ * \return The resulting offset >= 0 or error/message code */
1227+MPG123_EXPORT off_t mpg123_seek_frame( mpg123_handle *mh
1228+,	off_t frameoff, int whence );
1229+
1230+/** Return a MPEG frame offset corresponding to an offset in seconds.
1231+ *  This assumes that the samples per frame do not change in the file/stream, which is a good assumption for any sane file/stream only.
1232+ *  \return frame offset >= 0 or error/message code */
1233+MPG123_EXPORT off_t mpg123_timeframe(mpg123_handle *mh, double sec);
1234+
1235+/** Give access to the frame index table that is managed for seeking.
1236+ *  You are asked not to modify the values... Use mpg123_set_index to set the
1237+ *  seek index
1238+ *  \param mh handle
1239+ *  \param offsets pointer to the index array
1240+ *  \param step one index byte offset advances this many MPEG frames
1241+ *  \param fill number of recorded index offsets; size of the array
1242+ *  \return MPG123_OK on success
1243+ */
1244+MPG123_EXPORT int mpg123_index( mpg123_handle *mh
1245+,	off_t **offsets, off_t *step, size_t *fill );
1246+
1247+/** Set the frame index table
1248+ *  Setting offsets to NULL and fill > 0 will allocate fill entries. Setting offsets
1249+ *  to NULL and fill to 0 will clear the index and free the allocated memory used by the index.
1250+ *  \param mh handle
1251+ *  \param offsets pointer to the index array
1252+ *  \param step    one index byte offset advances this many MPEG frames
1253+ *  \param fill    number of recorded index offsets; size of the array
1254+ *  \return MPG123_OK on success
1255+ */
1256+MPG123_EXPORT int mpg123_set_index( mpg123_handle *mh
1257+,	off_t *offsets, off_t step, size_t fill );
1258+
1259+/** An old crutch to keep old mpg123 binaries happy.
1260+ *  WARNING: This function is there only to avoid runtime linking errors with
1261+ *  standalone mpg123 before version 1.23.0 (if you strangely update the
1262+ *  library but not the end-user program) and actually is broken
1263+ *  for various cases (p.ex. 24 bit output). Do never use. It might eventually
1264+ *  be purged from the library.
1265+ */
1266+MPG123_EXPORT int mpg123_position( mpg123_handle *mh, off_t frame_offset, off_t buffered_bytes, off_t *current_frame, off_t *frames_left, double *current_seconds, double *seconds_left);
1267+
1268+/*@}*/
1269+
1270+
1271+/** \defgroup mpg123_voleq mpg123 volume and equalizer
1272+ *
1273+ * @{
1274+ */
1275+
1276+/** another channel enumeration, for left/right choice */
1277+enum mpg123_channels
1278+{
1279+	 MPG123_LEFT=0x1	/**< The Left Channel. */
1280+	,MPG123_RIGHT=0x2	/**< The Right Channel. */
1281+	,MPG123_LR=0x3	/**< Both left and right channel; same as MPG123_LEFT|MPG123_RIGHT */
1282+};
1283+
1284+/** Set the 32 Band Audio Equalizer settings.
1285+ *  \param mh handle
1286+ *  \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for both.
1287+ *  \param band The equaliser band to change (from 0 to 31)
1288+ *  \param val The (linear) adjustment factor.
1289+ *  \return MPG123_OK on success
1290+ */
1291+MPG123_EXPORT int mpg123_eq( mpg123_handle *mh
1292+,	enum mpg123_channels channel, int band, double val );
1293+
1294+/** Get the 32 Band Audio Equalizer settings.
1295+ *  \param mh handle
1296+ *  \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for (arithmetic mean of) both.
1297+ *  \param band The equaliser band to change (from 0 to 31)
1298+ *  \return The (linear) adjustment factor (zero for pad parameters) */
1299+MPG123_EXPORT double mpg123_geteq(mpg123_handle *mh
1300+                                 , enum mpg123_channels channel, int band);
1301+
1302+/** Reset the 32 Band Audio Equalizer settings to flat
1303+ *  \param mh handle
1304+ *  \return MPG123_OK on success
1305+ */
1306+MPG123_EXPORT int mpg123_reset_eq(mpg123_handle *mh);
1307+
1308+/** Set the absolute output volume including the RVA setting,
1309+ *  vol<0 just applies (a possibly changed) RVA setting.
1310+ *  \param mh handle
1311+ *  \param vol volume value (linear factor)
1312+ *  \return MPG123_OK on success
1313+ */
1314+MPG123_EXPORT int mpg123_volume(mpg123_handle *mh, double vol);
1315+
1316+/** Adjust output volume including the RVA setting by chosen amount
1317+ *  \param mh handle
1318+ *  \param change volume value (linear factor increment)
1319+ *  \return MPG123_OK on success
1320+ */
1321+MPG123_EXPORT int mpg123_volume_change(mpg123_handle *mh, double change);
1322+
1323+/** Return current volume setting, the actual value due to RVA, and the RVA
1324+ *  adjustment itself. It's all as double float value to abstract the sample
1325+ *  format. The volume values are linear factors / amplitudes (not percent)
1326+ *  and the RVA value is in decibels.
1327+ *  \param mh handle
1328+ *  \param base return address for base volume (linear factor)
1329+ *  \param really return address for actual volume (linear factor)
1330+ *  \param rva_db return address for RVA value (decibels)
1331+ *  \return MPG123_OK on success
1332+ */
1333+MPG123_EXPORT int mpg123_getvolume(mpg123_handle *mh, double *base, double *really, double *rva_db);
1334+
1335+/* TODO: Set some preamp in addition / to replace internal RVA handling? */
1336+
1337+/*@}*/
1338+
1339+
1340+/** \defgroup mpg123_status mpg123 status and information
1341+ *
1342+ * @{
1343+ */
1344+
1345+/** Enumeration of the mode types of Variable Bitrate */
1346+enum mpg123_vbr {
1347+	MPG123_CBR=0,	/**< Constant Bitrate Mode (default) */
1348+	MPG123_VBR,		/**< Variable Bitrate Mode */
1349+	MPG123_ABR		/**< Average Bitrate Mode */
1350+};
1351+
1352+/** Enumeration of the MPEG Versions */
1353+enum mpg123_version {
1354+	MPG123_1_0=0,	/**< MPEG Version 1.0 */
1355+	MPG123_2_0,		/**< MPEG Version 2.0 */
1356+	MPG123_2_5		/**< MPEG Version 2.5 */
1357+};
1358+
1359+
1360+/** Enumeration of the MPEG Audio mode.
1361+ *  Only the mono mode has 1 channel, the others have 2 channels. */
1362+enum mpg123_mode {
1363+	MPG123_M_STEREO=0,	/**< Standard Stereo. */
1364+	MPG123_M_JOINT,		/**< Joint Stereo. */
1365+	MPG123_M_DUAL,		/**< Dual Channel. */
1366+	MPG123_M_MONO		/**< Single Channel. */
1367+};
1368+
1369+
1370+/** Enumeration of the MPEG Audio flag bits */
1371+enum mpg123_flags {
1372+	MPG123_CRC=0x1,			/**< The bitstream is error protected using 16-bit CRC. */
1373+	MPG123_COPYRIGHT=0x2,	/**< The bitstream is copyrighted. */
1374+	MPG123_PRIVATE=0x4,		/**< The private bit has been set. */
1375+	MPG123_ORIGINAL=0x8	/**< The bitstream is an original, not a copy. */
1376+};
1377+
1378+/** Data structure for storing information about a frame of MPEG Audio */
1379+struct mpg123_frameinfo
1380+{
1381+	enum mpg123_version version;	/**< The MPEG version (1.0/2.0/2.5). */
1382+	int layer;						/**< The MPEG Audio Layer (MP1/MP2/MP3). */
1383+	long rate; 						/**< The sampling rate in Hz. */
1384+	enum mpg123_mode mode;			/**< The audio mode (Mono, Stereo, Joint-stero, Dual Channel). */
1385+	int mode_ext;					/**< The mode extension bit flag. */
1386+	int framesize;					/**< The size of the frame (in bytes, including header). */
1387+	enum mpg123_flags flags;		/**< MPEG Audio flag bits. Just now I realize that it should be declared as int, not enum. It's a bitwise combination of the enum values. */
1388+	int emphasis;					/**< The emphasis type. */
1389+	int bitrate;					/**< Bitrate of the frame (kbps). */
1390+	int abr_rate;					/**< The target average bitrate. */
1391+	enum mpg123_vbr vbr;			/**< The VBR mode. */
1392+};
1393+
1394+/** Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure.
1395+ *  \param mh handle
1396+ *  \param mi address of existing frameinfo structure to write to
1397+ *  \return MPG123_OK on success
1398+ */
1399+MPG123_EXPORT int mpg123_info(mpg123_handle *mh, struct mpg123_frameinfo *mi);
1400+
1401+/** Get the safe output buffer size for all cases
1402+ *  (when you want to replace the internal buffer)
1403+ *  \return safe buffer size
1404+ */
1405+MPG123_EXPORT size_t mpg123_safe_buffer(void);
1406+
1407+/** Make a full parsing scan of each frame in the file. ID3 tags are found. An
1408+ *  accurate length value is stored. Seek index will be filled. A seek back to
1409+ *  current position is performed. At all, this function refuses work when
1410+ *  stream is not seekable.
1411+ *  \param mh handle
1412+ *  \return MPG123_OK on success
1413+ */
1414+MPG123_EXPORT int mpg123_scan(mpg123_handle *mh);
1415+
1416+/** Return, if possible, the full (expected) length of current track in frames.
1417+ * \param mh handle
1418+ * \return length >= 0 or MPG123_ERR if there is no length guess possible.
1419+ */
1420+MPG123_EXPORT off_t mpg123_framelength(mpg123_handle *mh);
1421+
1422+/** Return, if possible, the full (expected) length of current track in samples.
1423+ * \param mh handle
1424+ * \return length >= 0 or MPG123_ERR if there is no length guess possible.
1425+ */
1426+MPG123_EXPORT off_t mpg123_length(mpg123_handle *mh);
1427+
1428+/** Override the value for file size in bytes.
1429+ *  Useful for getting sensible track length values in feed mode or for HTTP streams.
1430+ *  \param mh handle
1431+ *  \param size file size in bytes
1432+ *  \return MPG123_OK on success
1433+ */
1434+MPG123_EXPORT int mpg123_set_filesize(mpg123_handle *mh, off_t size);
1435+
1436+/** Get MPEG frame duration in seconds.
1437+ *  \param mh handle
1438+ *  \return frame duration in seconds, <0 on error
1439+ */
1440+MPG123_EXPORT double mpg123_tpf(mpg123_handle *mh);
1441+
1442+/** Get MPEG frame duration in samples.
1443+ *  \param mh handle
1444+ *  \return samples per frame for the most recently parsed frame; <0 on errors
1445+ */
1446+MPG123_EXPORT int mpg123_spf(mpg123_handle *mh);
1447+
1448+/** Get and reset the clip count.
1449+ *  \param mh handle
1450+ *  \return count of clipped samples
1451+ */
1452+MPG123_EXPORT long mpg123_clip(mpg123_handle *mh);
1453+
1454+
1455+/** The key values for state information from mpg123_getstate(). */
1456+enum mpg123_state
1457+{
1458+	 MPG123_ACCURATE = 1 /**< Query if positons are currently accurate (integer value, 0 if false, 1 if true). */
1459+	,MPG123_BUFFERFILL   /**< Get fill of internal (feed) input buffer as integer byte count returned as long and as double. An error is returned on integer overflow while converting to (signed) long, but the returned floating point value shold still be fine. */
1460+	,MPG123_FRANKENSTEIN /**< Stream consists of carelessly stitched together files. Seeking may yield unexpected results (also with MPG123_ACCURATE, it may be confused). */
1461+	,MPG123_FRESH_DECODER /**< Decoder structure has been updated, possibly indicating changed stream (integer value, 0 if false, 1 if true). Flag is cleared after retrieval. */
1462+};
1463+
1464+/** Get various current decoder/stream state information.
1465+ *  \param mh handle
1466+ *  \param key the key to identify the information to give.
1467+ *  \param val the address to return (long) integer values to
1468+ *  \param fval the address to return floating point values to
1469+ *  \return MPG123_OK on success
1470+ */
1471+MPG123_EXPORT int mpg123_getstate( mpg123_handle *mh
1472+,	enum mpg123_state key, long *val, double *fval );
1473+
1474+/*@}*/
1475+
1476+
1477+/** \defgroup mpg123_metadata mpg123 metadata handling
1478+ *
1479+ * Functions to retrieve the metadata from MPEG Audio files and streams.
1480+ * Also includes string handling functions.
1481+ *
1482+ * @{
1483+ */
1484+
1485+/** Data structure for storing strings in a safer way than a standard C-String.
1486+ *  Can also hold a number of null-terminated strings. */
1487+typedef struct
1488+{
1489+	char* p;     /**< pointer to the string data */
1490+	size_t size; /**< raw number of bytes allocated */
1491+	size_t fill; /**< number of used bytes (including closing zero byte) */
1492+} mpg123_string;
1493+
1494+/** Create and allocate memory for a new mpg123_string
1495+ *  \param sb string handle (address of existing structure on your side)
1496+ */
1497+MPG123_EXPORT void mpg123_init_string(mpg123_string* sb);
1498+
1499+/** Free-up mempory for an existing mpg123_string
1500+ *  \param sb string handle
1501+ */
1502+MPG123_EXPORT void mpg123_free_string(mpg123_string* sb);
1503+
1504+/** Change the size of a mpg123_string
1505+ *  \param sb string handle
1506+ *  \param news new size in bytes
1507+ *  \return 0 on error, 1 on success
1508+ */
1509+MPG123_EXPORT int mpg123_resize_string(mpg123_string* sb, size_t news);
1510+
1511+/** Increase size of a mpg123_string if necessary (it may stay larger).
1512+ *  Note that the functions for adding and setting in current libmpg123
1513+ *  use this instead of mpg123_resize_string().
1514+ *  That way, you can preallocate memory and safely work afterwards with
1515+ *  pieces.
1516+ *  \param sb string handle
1517+ *  \param news new minimum size
1518+ *  \return 0 on error, 1 on success
1519+ */
1520+MPG123_EXPORT int mpg123_grow_string(mpg123_string* sb, size_t news);
1521+
1522+/** Copy the contents of one mpg123_string string to another.
1523+ *  Yes the order of arguments is reversed compated to memcpy().
1524+ *  \param from string handle
1525+ *  \param to string handle
1526+ *  \return 0 on error, 1 on success
1527+ */
1528+MPG123_EXPORT int mpg123_copy_string(mpg123_string* from, mpg123_string* to);
1529+
1530+/** Append a C-String to an mpg123_string
1531+ *  \param sb string handle
1532+ *  \param stuff to append
1533+ *  \return 0 on error, 1 on success
1534+ */
1535+MPG123_EXPORT int mpg123_add_string(mpg123_string* sb, const char* stuff);
1536+
1537+/** Append a C-substring to an mpg123 string
1538+ *  \param sb string handle
1539+ *  \param stuff content to copy
1540+ *  \param from offset to copy from
1541+ *  \param count number of characters to copy (a null-byte is always appended)
1542+ *  \return 0 on error, 1 on success
1543+ */
1544+MPG123_EXPORT int mpg123_add_substring( mpg123_string *sb
1545+,	const char *stuff, size_t from, size_t count );
1546+
1547+/** Set the content of a mpg123_string to a C-string
1548+ *  \param sb string handle
1549+ *  \param stuff content to copy
1550+ *  \return 0 on error, 1 on success
1551+ */
1552+MPG123_EXPORT int mpg123_set_string(mpg123_string* sb, const char* stuff);
1553+
1554+/** Set the content of a mpg123_string to a C-substring
1555+ *  \param sb string handle
1556+ *  \param stuff the future content
1557+ *  \param from offset to copy from
1558+ *  \param count number of characters to copy (a null-byte is always appended)
1559+ *  \return 0 on error, 1 on success
1560+ */
1561+MPG123_EXPORT int mpg123_set_substring( mpg123_string *sb
1562+,	const char *stuff, size_t from, size_t count );
1563+
1564+/** Count characters in a mpg123 string (non-null bytes or UTF-8 characters).
1565+ *  Even with the fill property, the character count is not obvious as there could be multiple trailing null bytes.
1566+ *  \param sb string handle
1567+ *  \param utf8 a flag to tell if the string is in utf8 encoding
1568+ *  \return character count
1569+*/
1570+MPG123_EXPORT size_t mpg123_strlen(mpg123_string *sb, int utf8);
1571+
1572+/** Remove trailing \\r and \\n, if present.
1573+ *  \param sb string handle
1574+ *  \return 0 on error, 1 on success
1575+ */
1576+MPG123_EXPORT int mpg123_chomp_string(mpg123_string *sb);
1577+
1578+/** The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info. */
1579+enum mpg123_text_encoding
1580+{
1581+	 mpg123_text_unknown  = 0 /**< Unkown encoding... mpg123_id3_encoding can return that on invalid codes. */
1582+	,mpg123_text_utf8     = 1 /**< UTF-8 */
1583+	,mpg123_text_latin1   = 2 /**< ISO-8859-1. Note that sometimes latin1 in ID3 is abused for totally different encodings. */
1584+	,mpg123_text_icy      = 3 /**< ICY metadata encoding, usually CP-1252 but we take it as UTF-8 if it qualifies as such. */
1585+	,mpg123_text_cp1252   = 4 /**< Really CP-1252 without any guessing. */
1586+	,mpg123_text_utf16    = 5 /**< Some UTF-16 encoding. The last of a set of leading BOMs (byte order mark) rules.
1587+	                           *   When there is no BOM, big endian ordering is used. Note that UCS-2 qualifies as UTF-8 when
1588+	                           *   you don't mess with the reserved code points. If you want to decode little endian data
1589+	                           *   without BOM you need to prepend 0xff 0xfe yourself. */
1590+	,mpg123_text_utf16bom = 6 /**< Just an alias for UTF-16, ID3v2 has this as distinct code. */
1591+	,mpg123_text_utf16be  = 7 /**< Another alias for UTF16 from ID3v2. Note, that, because of the mess that is reality,
1592+	                           *   BOMs are used if encountered. There really is not much distinction between the UTF16 types for mpg123
1593+	                           *   One exception: Since this is seen in ID3v2 tags, leading null bytes are skipped for all other UTF16
1594+	                           *   types (we expect a BOM before real data there), not so for utf16be!*/
1595+	,mpg123_text_max      = 7 /**< Placeholder for the maximum encoding value. */
1596+};
1597+
1598+/** The encoding byte values from ID3v2. */
1599+enum mpg123_id3_enc
1600+{
1601+	 mpg123_id3_latin1   = 0 /**< Note: This sometimes can mean anything in practice... */
1602+	,mpg123_id3_utf16bom = 1 /**< UTF16, UCS-2 ... it's all the same for practical purposes. */
1603+	,mpg123_id3_utf16be  = 2 /**< Big-endian UTF-16, BOM see note for mpg123_text_utf16be. */
1604+	,mpg123_id3_utf8     = 3 /**< Our lovely overly ASCII-compatible 8 byte encoding for the world. */
1605+	,mpg123_id3_enc_max  = 3 /**< Placeholder to check valid range of encoding byte. */
1606+};
1607+
1608+/** Convert ID3 encoding byte to mpg123 encoding index.
1609+ *  \param id3_enc_byte the ID3 encoding code
1610+ *  \return the mpg123 encoding index
1611+ */
1612+
1613+MPG123_EXPORT enum mpg123_text_encoding mpg123_enc_from_id3(unsigned char id3_enc_byte);
1614+
1615+/** Store text data in string, after converting to UTF-8 from indicated encoding
1616+ *  A prominent error can be that you provided an unknown encoding value, or this build of libmpg123 lacks support for certain encodings (ID3 or ICY stuff missing).
1617+ *  Also, you might want to take a bit of care with preparing the data; for example, strip leading zeroes (I have seen that).
1618+ *  \param sb  target string
1619+ *  \param enc mpg123 text encoding value
1620+ *  \param source source buffer with plain unsigned bytes (you might need to cast from signed char)
1621+ *  \param source_size number of bytes in the source buffer
1622+ *  \return 0 on error, 1 on success (on error, mpg123_free_string is called on sb)
1623+ */
1624+MPG123_EXPORT int mpg123_store_utf8(mpg123_string *sb, enum mpg123_text_encoding enc, const unsigned char *source, size_t source_size);
1625+
1626+/** Sub data structure for ID3v2, for storing various text fields (including comments).
1627+ *  This is for ID3v2 COMM, TXXX and all the other text fields.
1628+ *  Only COMM and TXXX have a description, only COMM and USLT have a language.
1629+ *  You should consult the ID3v2 specification for the use of the various text fields ("frames" in ID3v2 documentation, I use "fields" here to separate from MPEG frames). */
1630+typedef struct
1631+{
1632+	char lang[3]; /**< Three-letter language code (not terminated). */
1633+	char id[4];   /**< The ID3v2 text field id, like TALB, TPE2, ... (4 characters, no string termination). */
1634+	mpg123_string description; /**< Empty for the generic comment... */
1635+	mpg123_string text;        /**< ... */
1636+} mpg123_text;
1637+
1638+/** The picture type values from ID3v2. */
1639+enum mpg123_id3_pic_type
1640+{
1641+	 mpg123_id3_pic_other          =  0 /**< see ID3v2 docs */
1642+	,mpg123_id3_pic_icon           =  1 /**< see ID3v2 docs */
1643+	,mpg123_id3_pic_other_icon     =  2 /**< see ID3v2 docs */
1644+	,mpg123_id3_pic_front_cover    =  3 /**< see ID3v2 docs */
1645+	,mpg123_id3_pic_back_cover     =  4 /**< see ID3v2 docs */
1646+	,mpg123_id3_pic_leaflet        =  5 /**< see ID3v2 docs */
1647+	,mpg123_id3_pic_media          =  6 /**< see ID3v2 docs */
1648+	,mpg123_id3_pic_lead           =  7 /**< see ID3v2 docs */
1649+	,mpg123_id3_pic_artist         =  8 /**< see ID3v2 docs */
1650+	,mpg123_id3_pic_conductor      =  9 /**< see ID3v2 docs */
1651+	,mpg123_id3_pic_orchestra      = 10 /**< see ID3v2 docs */
1652+	,mpg123_id3_pic_composer       = 11 /**< see ID3v2 docs */
1653+	,mpg123_id3_pic_lyricist       = 12 /**< see ID3v2 docs */
1654+	,mpg123_id3_pic_location       = 13 /**< see ID3v2 docs */
1655+	,mpg123_id3_pic_recording      = 14 /**< see ID3v2 docs */
1656+	,mpg123_id3_pic_performance    = 15 /**< see ID3v2 docs */
1657+	,mpg123_id3_pic_video          = 16 /**< see ID3v2 docs */
1658+	,mpg123_id3_pic_fish           = 17 /**< see ID3v2 docs */
1659+	,mpg123_id3_pic_illustration   = 18 /**< see ID3v2 docs */
1660+	,mpg123_id3_pic_artist_logo    = 19 /**< see ID3v2 docs */
1661+	,mpg123_id3_pic_publisher_logo = 20 /**< see ID3v2 docs */
1662+};
1663+
1664+/** Sub data structure for ID3v2, for storing picture data including comment.
1665+ *  This is for the ID3v2 APIC field. You should consult the ID3v2 specification
1666+ *  for the use of the APIC field ("frames" in ID3v2 documentation, I use "fields"
1667+ *  here to separate from MPEG frames). */
1668+typedef struct
1669+{
1670+	char type;                 /**< mpg123_id3_pic_type value */
1671+	mpg123_string description; /**< description string */
1672+	mpg123_string mime_type;   /**< MIME type */
1673+	size_t size;               /**< size in bytes */
1674+	unsigned char* data;       /**< pointer to the image data */
1675+} mpg123_picture;
1676+
1677+/** Data structure for storing IDV3v2 tags.
1678+ *  This structure is not a direct binary mapping with the file contents.
1679+ *  The ID3v2 text frames are allowed to contain multiple strings.
1680+ *  So check for null bytes until you reach the mpg123_string fill.
1681+ *  All text is encoded in UTF-8. */
1682+typedef struct
1683+{
1684+	unsigned char version; /**< 3 or 4 for ID3v2.3 or ID3v2.4. */
1685+	mpg123_string *title;   /**< Title string (pointer into text_list). */
1686+	mpg123_string *artist;  /**< Artist string (pointer into text_list). */
1687+	mpg123_string *album;   /**< Album string (pointer into text_list). */
1688+	mpg123_string *year;    /**< The year as a string (pointer into text_list). */
1689+	mpg123_string *genre;   /**< Genre String (pointer into text_list). The genre string(s) may very well need postprocessing, esp. for ID3v2.3. */
1690+	mpg123_string *comment; /**< Pointer to last encountered comment text with empty description. */
1691+	/* Encountered ID3v2 fields are appended to these lists.
1692+	   There can be multiple occurences, the pointers above always point to the last encountered data. */
1693+	mpg123_text    *comment_list; /**< Array of comments. */
1694+	size_t          comments;     /**< Number of comments. */
1695+	mpg123_text    *text;         /**< Array of ID3v2 text fields (including USLT) */
1696+	size_t          texts;        /**< Numer of text fields. */
1697+	mpg123_text    *extra;        /**< The array of extra (TXXX) fields. */
1698+	size_t          extras;       /**< Number of extra text (TXXX) fields. */
1699+	mpg123_picture  *picture;     /**< Array of ID3v2 pictures fields (APIC). */
1700+	size_t           pictures;    /**< Number of picture (APIC) fields. */
1701+} mpg123_id3v2;
1702+
1703+/** Data structure for ID3v1 tags (the last 128 bytes of a file).
1704+ *  Don't take anything for granted (like string termination)!
1705+ *  Also note the change ID3v1.1 did: comment[28] = 0; comment[29] = track_number
1706+ *  It is your task to support ID3v1 only or ID3v1.1 ...*/
1707+typedef struct
1708+{
1709+	char tag[3];         /**< Always the string "TAG", the classic intro. */
1710+	char title[30];      /**< Title string.  */
1711+	char artist[30];     /**< Artist string. */
1712+	char album[30];      /**< Album string. */
1713+	char year[4];        /**< Year string. */
1714+	char comment[30];    /**< Comment string. */
1715+	unsigned char genre; /**< Genre index. */
1716+} mpg123_id3v1;
1717+
1718+#define MPG123_ID3     0x3 /**< 0011 There is some ID3 info. Also matches 0010 or NEW_ID3. */
1719+#define MPG123_NEW_ID3 0x1 /**< 0001 There is ID3 info that changed since last call to mpg123_id3. */
1720+#define MPG123_ICY     0xc /**< 1100 There is some ICY info. Also matches 0100 or NEW_ICY.*/
1721+#define MPG123_NEW_ICY 0x4 /**< 0100 There is ICY info that changed since last call to mpg123_icy. */
1722+
1723+/** Query if there is (new) meta info, be it ID3 or ICY (or something new in future).
1724+ *  \param mh handle
1725+ *  \return combination of flags, 0 on error (same as "nothing new")
1726+ */
1727+MPG123_EXPORT int mpg123_meta_check(mpg123_handle *mh);
1728+
1729+/** Clean up meta data storage (ID3v2 and ICY), freeing memory.
1730+ *  \param mh handle
1731+ */
1732+MPG123_EXPORT void mpg123_meta_free(mpg123_handle *mh);
1733+
1734+/** Point v1 and v2 to existing data structures wich may change on any next read/decode function call.
1735+ *  v1 and/or v2 can be set to NULL when there is no corresponding data.
1736+ *  \return MPG123_OK on success
1737+ */
1738+MPG123_EXPORT int mpg123_id3( mpg123_handle *mh
1739+,	mpg123_id3v1 **v1, mpg123_id3v2 **v2 );
1740+
1741+/** Point icy_meta to existing data structure wich may change on any next read/decode function call.
1742+ *  \param mh handle
1743+ *  \param icy_meta return address for ICY meta string (set to NULL if nothing there)
1744+ *  \return MPG123_OK on success
1745+ */
1746+MPG123_EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta);
1747+
1748+/** Decode from windows-1252 (the encoding ICY metainfo used) to UTF-8.
1749+ *  Note that this is very similar to mpg123_store_utf8(&sb, mpg123_text_icy, icy_text, strlen(icy_text+1)) .
1750+ *  \param icy_text The input data in ICY encoding
1751+ *  \return pointer to newly allocated buffer with UTF-8 data (You free() it!) */
1752+MPG123_EXPORT char* mpg123_icy2utf8(const char* icy_text);
1753+
1754+
1755+/* @} */
1756+
1757+
1758+/** \defgroup mpg123_advpar mpg123 advanced parameter API
1759+ *
1760+ *  Direct access to a parameter set without full handle around it.
1761+ *	Possible uses:
1762+ *    - Influence behaviour of library _during_ initialization of handle (MPG123_VERBOSE).
1763+ *    - Use one set of parameters for multiple handles.
1764+ *
1765+ *	The functions for handling mpg123_pars (mpg123_par() and mpg123_fmt()
1766+ *  family) directly return a fully qualified mpg123 error code, the ones
1767+ *  operating on full handles normally MPG123_OK or MPG123_ERR, storing the
1768+ *  specific error code itseld inside the handle.
1769+ *
1770+ * @{
1771+ */
1772+
1773+/** Opaque structure for the libmpg123 decoder parameters. */
1774+struct mpg123_pars_struct;
1775+
1776+/** Opaque structure for the libmpg123 decoder parameters. */
1777+typedef struct mpg123_pars_struct   mpg123_pars;
1778+
1779+/** Create a handle with preset parameters.
1780+ *  \param mp parameter handle
1781+ *  \param decoder decoder choice
1782+ *  \param error error code return address
1783+ *  \return mpg123 handle
1784+ */
1785+MPG123_EXPORT mpg123_handle *mpg123_parnew( mpg123_pars *mp
1786+,	const char* decoder, int *error );
1787+
1788+/** Allocate memory for and return a pointer to a new mpg123_pars
1789+ *  \param error error code return address
1790+ *  \return new parameter handle
1791+ */
1792+MPG123_EXPORT mpg123_pars *mpg123_new_pars(int *error);
1793+
1794+/** Delete and free up memory used by a mpg123_pars data structure
1795+ *  \param mp parameter handle
1796+ */
1797+MPG123_EXPORT void mpg123_delete_pars(mpg123_pars* mp);
1798+
1799+/** Configure mpg123 parameters to accept no output format at all,
1800+ *  use before specifying supported formats with mpg123_format
1801+ *  \param mp parameter handle
1802+ *  \return MPG123_OK on success
1803+ */
1804+MPG123_EXPORT int mpg123_fmt_none(mpg123_pars *mp);
1805+
1806+/** Configure mpg123 parameters to accept all formats
1807+ *  (also any custom rate you may set) -- this is default.
1808+ *  \param mp parameter handle
1809+ *  \return MPG123_OK on success
1810+ */
1811+MPG123_EXPORT int mpg123_fmt_all(mpg123_pars *mp);
1812+
1813+/** Set the audio format support of a mpg123_pars in detail:
1814+ * \param mp parameter handle
1815+ * \param rate The sample rate value (in Hertz).
1816+ * \param channels A combination of MPG123_STEREO and MPG123_MONO.
1817+ * \param encodings A combination of accepted encodings for rate and channels,
1818+ *                  p.ex MPG123_ENC_SIGNED16|MPG123_ENC_ULAW_8 (or 0 for no
1819+ *                  support).
1820+ * \return MPG123_OK on success
1821+*/
1822+MPG123_EXPORT int mpg123_fmt(mpg123_pars *mp
1823+,	long rate, int channels, int encodings);
1824+
1825+/** Check to see if a specific format at a specific rate is supported
1826+ *  by mpg123_pars.
1827+ *  \param mp parameter handle
1828+ *  \param rate sampling rate
1829+ *  \param encoding encoding
1830+ *  \return 0 for no support (that includes invalid parameters), MPG123_STEREO,
1831+ *          MPG123_MONO or MPG123_STEREO|MPG123_MONO. */
1832+MPG123_EXPORT int mpg123_fmt_support(mpg123_pars *mp, long rate, int encoding);
1833+
1834+/** Set a specific parameter, for a specific mpg123_pars, using a parameter
1835+ *  type key chosen from the mpg123_parms enumeration, to the specified value.
1836+ *  \param mp parameter handle
1837+ *  \param type parameter choice
1838+ *  \param value integer value
1839+ *  \param fvalue floating point value
1840+ *  \return MPG123_OK on success
1841+ */
1842+MPG123_EXPORT int mpg123_par( mpg123_pars *mp
1843+,	enum mpg123_parms type, long value, double fvalue );
1844+
1845+/** Get a specific parameter, for a specific mpg123_pars.
1846+ *  See the mpg123_parms enumeration for a list of available parameters.
1847+ *  \param mp parameter handle
1848+ *  \param type parameter choice
1849+ *  \param value integer value return address
1850+ *  \param fvalue floating point value return address
1851+ *  \return MPG123_OK on success
1852+ */
1853+MPG123_EXPORT int mpg123_getpar( mpg123_pars *mp
1854+,	enum mpg123_parms type, long *value, double *fvalue);
1855+
1856+/* @} */
1857+
1858+
1859+/** \defgroup mpg123_lowio mpg123 low level I/O
1860+  * You may want to do tricky stuff with I/O that does not work with mpg123's default file access or you want to make it decode into your own pocket...
1861+  *
1862+  * @{ */
1863+
1864+/** Replace default internal buffer with user-supplied buffer.
1865+  * Instead of working on it's own private buffer, mpg123 will directly use the one you provide for storing decoded audio.
1866+  * Note that the required buffer size could be bigger than expected from output
1867+  * encoding if libmpg123 has to convert from primary decoder output (p.ex. 32 bit
1868+  * storage for 24 bit output).
1869+  * \param mh handle
1870+  * \param data pointer to user buffer
1871+  * \param size of buffer in bytes
1872+  * \return MPG123_OK on success
1873+  */
1874+MPG123_EXPORT int mpg123_replace_buffer(mpg123_handle *mh
1875+,	unsigned char *data, size_t size);
1876+
1877+/** The max size of one frame's decoded output with current settings.
1878+ *  Use that to determine an appropriate minimum buffer size for decoding one frame.
1879+ *  \param mh handle
1880+ *  \return maximum decoded data size in bytes
1881+ */
1882+MPG123_EXPORT size_t mpg123_outblock(mpg123_handle *mh);
1883+
1884+/** Replace low-level stream access functions; read and lseek as known in POSIX.
1885+ *  You can use this to make any fancy file opening/closing yourself,
1886+ *  using mpg123_open_fd() to set the file descriptor for your read/lseek
1887+ *  (doesn't need to be a "real" file descriptor...).
1888+ *  Setting a function to NULL means that the default internal read is
1889+ *  used (active from next mpg123_open call on).
1890+ *  Note: As it would be troublesome to mess with this while having a file open,
1891+ *  this implies mpg123_close().
1892+ * \param mh handle
1893+ * \param r_read callback for reading (behaviour like POSIX read)
1894+ * \param r_lseek callback for seeking (like POSIX lseek)
1895+ * \return MPG123_OK on success
1896+ */
1897+MPG123_EXPORT int mpg123_replace_reader( mpg123_handle *mh
1898+,	ssize_t (*r_read) (int, void *, size_t)
1899+,	off_t (*r_lseek)(int, off_t, int)
1900+);
1901+
1902+/** Replace I/O functions with your own ones operating on some kind of
1903+ *  handle instead of integer descriptors.
1904+ *  The handle is a void pointer, so you can pass any data you want...
1905+ *  mpg123_open_handle() is the call you make to use the I/O defined here.
1906+ *  There is no fallback to internal read/seek here.
1907+ *  Note: As it would be troublesome to mess with this while having a file open,
1908+ *  this mpg123_close() is implied here.
1909+ *  \param mh handle
1910+ *  \param r_read callback for reading (behaviour like POSIX read)
1911+ *  \param r_lseek callback for seeking (like POSIX lseek)
1912+ *  \param cleanup A callback to clean up an I/O handle on mpg123_close,
1913+ *         can be NULL for none (you take care of cleaning your handles).
1914+ * \return MPG123_OK on success
1915+ */
1916+MPG123_EXPORT int mpg123_replace_reader_handle( mpg123_handle *mh
1917+,	ssize_t (*r_read) (void *, void *, size_t)
1918+,	off_t (*r_lseek)(void *, off_t, int)
1919+,	void (*cleanup)(void*) );
1920+
1921+/* @} */
1922+
1923+#ifdef __cplusplus
1924+}
1925+#endif
1926+
1927+#endif
1928diff -ruN mpg123-1.25.6.orig/Android.mk mpg123-1.25.6/Android.mk
1929--- mpg123-1.25.6.orig/Android.mk	1969-12-31 16:00:00.000000000 -0800
1930+++ mpg123-1.25.6/Android.mk	2017-12-07 08:47:05.654383428 -0800
1931@@ -0,0 +1,226 @@
1932+LOCAL_PATH := $(call my-dir)
1933+
1934+include $(CLEAR_VARS)
1935+
1936+LOCAL_MODULE := libmpg123
1937+
1938+LOCAL_C_INCLUDES := $(LOCAL_PATH)/android \
1939+                    $(LOCAL_PATH)/src \
1940+                    $(LOCAL_PATH)/src/compat \
1941+                    $(LOCAL_PATH)/src/libmpg123 \
1942+
1943+DECODER_CFLAGS_NEON := -DOPT_NEON -DREAL_IS_FLOAT
1944+
1945+DECODER_SRC_NEON := \
1946+    src/libmpg123/stringbuf.c \
1947+    src/libmpg123/icy.c \
1948+    src/libmpg123/icy2utf8.c \
1949+    src/libmpg123/ntom.c \
1950+    src/libmpg123/synth.c \
1951+    src/libmpg123/synth_8bit.c \
1952+    src/libmpg123/layer1.c \
1953+    src/libmpg123/layer2.c \
1954+    src/libmpg123/layer3.c \
1955+    src/libmpg123/dct36_neon.S \
1956+    src/libmpg123/dct64_neon_float.S \
1957+    src/libmpg123/synth_neon_float.S \
1958+    src/libmpg123/synth_neon_s32.S \
1959+    src/libmpg123/synth_stereo_neon_float.S \
1960+    src/libmpg123/synth_stereo_neon_s32.S \
1961+    src/libmpg123/dct64_neon.S \
1962+    src/libmpg123/synth_neon.S \
1963+    src/libmpg123/synth_stereo_neon.S \
1964+    src/libmpg123/synth_s32.c \
1965+    src/libmpg123/synth_real.c \
1966+    src/libmpg123/feature.c \
1967+
1968+DECODER_CFLAGS_NEON64 := -DOPT_MULTI -DOPT_GENERIC -DOPT_GENERIC_DITHER -DOPT_NEON64 -DREAL_IS_FLOAT
1969+
1970+DECODER_SRC_NEON64 := \
1971+    src/libmpg123/stringbuf.c \
1972+    src/libmpg123/icy.c \
1973+    src/libmpg123/icy2utf8.c \
1974+    src/libmpg123/ntom.c \
1975+    src/libmpg123/synth.c \
1976+    src/libmpg123/synth_8bit.c \
1977+    src/libmpg123/layer1.c \
1978+    src/libmpg123/layer2.c \
1979+    src/libmpg123/layer3.c \
1980+    src/libmpg123/dct36_neon64.S \
1981+    src/libmpg123/dct64_neon64_float.S \
1982+    src/libmpg123/synth_neon64_float.S \
1983+    src/libmpg123/synth_neon64_s32.S \
1984+    src/libmpg123/synth_stereo_neon64_float.S \
1985+    src/libmpg123/synth_stereo_neon64_s32.S \
1986+    src/libmpg123/dct64_neon64.S \
1987+    src/libmpg123/synth_neon64.S \
1988+    src/libmpg123/synth_stereo_neon64.S \
1989+    src/libmpg123/synth_s32.c \
1990+    src/libmpg123/synth_real.c \
1991+    src/libmpg123/dither.c \
1992+    src/libmpg123/getcpuflags_arm.c \
1993+    src/libmpg123/check_neon.S \
1994+    src/libmpg123/feature.c \
1995+
1996+# Unfortunately the assembly isn't relocatable so doesn't work on modern
1997+# Android devices
1998+DECODER_CFLAGS_X86 := -DOPT_GENERIC -DREAL_IS_FLOAT
1999+DECODER_CFLAGS_X86_ASM := -DOPT_MULTI -DOPT_GENERIC -DOPT_GENERIC_DITHER -DOPT_I386 -DOPT_I586 -DOPT_I586_DITHER -DOPT_MMX -DOPT_3DNOW -DOPT_3DNOW_VINTAGE -DOPT_3DNOWEXT -DOPT_3DNOWEXT_VINTAGE -DOPT_SSE -DOPT_SSE_VINTAGE -DREAL_IS_FLOAT
2000+
2001+DECODER_SRC_X86 := \
2002+    src/libmpg123/feature.c \
2003+    src/libmpg123/icy2utf8.c \
2004+    src/libmpg123/icy.c \
2005+    src/libmpg123/layer1.c \
2006+    src/libmpg123/layer2.c \
2007+    src/libmpg123/layer3.c \
2008+    src/libmpg123/ntom.c \
2009+    src/libmpg123/stringbuf.c \
2010+    src/libmpg123/synth_8bit.c \
2011+    src/libmpg123/synth.c \
2012+    src/libmpg123/synth_real.c \
2013+    src/libmpg123/synth_s32.c \
2014+    src/libmpg123/dither.c \
2015+
2016+DECODER_SRC_X86_ASM := \
2017+    src/libmpg123/stringbuf.c \
2018+    src/libmpg123/icy.c \
2019+    src/libmpg123/icy2utf8.c \
2020+    src/libmpg123/ntom.c \
2021+    src/libmpg123/synth.c \
2022+    src/libmpg123/synth_8bit.c \
2023+    src/libmpg123/layer1.c \
2024+    src/libmpg123/layer2.c \
2025+    src/libmpg123/layer3.c \
2026+    src/libmpg123/synth_s32.c \
2027+    src/libmpg123/synth_real.c \
2028+    src/libmpg123/dct64_i386.c \
2029+    src/libmpg123/synth_i586.S \
2030+    src/libmpg123/synth_i586_dither.S \
2031+    src/libmpg123/dct64_mmx.S \
2032+    src/libmpg123/tabinit_mmx.S \
2033+    src/libmpg123/synth_mmx.S \
2034+    src/libmpg123/synth_3dnow.S \
2035+    src/libmpg123/dct64_3dnow.S \
2036+    src/libmpg123/equalizer_3dnow.S \
2037+    src/libmpg123/dct36_3dnow.S \
2038+    src/libmpg123/dct64_3dnowext.S \
2039+    src/libmpg123/synth_3dnowext.S \
2040+    src/libmpg123/dct36_3dnowext.S \
2041+    src/libmpg123/dct64_sse_float.S \
2042+    src/libmpg123/synth_sse_float.S \
2043+    src/libmpg123/synth_stereo_sse_float.S \
2044+    src/libmpg123/synth_sse_s32.S \
2045+    src/libmpg123/synth_stereo_sse_s32.S \
2046+    src/libmpg123/dct36_sse.S \
2047+    src/libmpg123/dct64_sse.S \
2048+    src/libmpg123/synth_sse.S \
2049+    src/libmpg123/getcpuflags.S \
2050+    src/libmpg123/dither.c \
2051+    src/libmpg123/feature.c \
2052+
2053+DECODER_CFLAGS_X64 := -DOPT_MULTI -DOPT_X86_64 -DOPT_GENERIC -DOPT_GENERIC_DITHER -DREAL_IS_FLOAT -DOPT_AVX
2054+
2055+DECODER_SRC_X64 := \
2056+    src/libmpg123/stringbuf.c \
2057+    src/libmpg123/icy.c \
2058+    src/libmpg123/icy.h \
2059+    src/libmpg123/icy2utf8.c \
2060+    src/libmpg123/icy2utf8.h \
2061+    src/libmpg123/ntom.c \
2062+    src/libmpg123/synth.c \
2063+    src/libmpg123/synth.h \
2064+    src/libmpg123/synth_8bit.c \
2065+    src/libmpg123/synth_8bit.h \
2066+    src/libmpg123/layer1.c \
2067+    src/libmpg123/layer2.c \
2068+    src/libmpg123/layer3.c \
2069+    src/libmpg123/synth_s32.c \
2070+    src/libmpg123/synth_real.c \
2071+    src/libmpg123/dct36_x86_64.S \
2072+    src/libmpg123/dct64_x86_64_float.S \
2073+    src/libmpg123/synth_x86_64_float.S \
2074+    src/libmpg123/synth_x86_64_s32.S \
2075+    src/libmpg123/synth_stereo_x86_64_float.S \
2076+    src/libmpg123/synth_stereo_x86_64_s32.S \
2077+    src/libmpg123/synth_x86_64.S \
2078+    src/libmpg123/dct64_x86_64.S \
2079+    src/libmpg123/synth_stereo_x86_64.S \
2080+    src/libmpg123/dither.c \
2081+    src/libmpg123/dither.h \
2082+    src/libmpg123/getcpuflags_x86_64.S \
2083+    src/libmpg123/dct36_avx.S \
2084+    src/libmpg123/dct64_avx_float.S \
2085+    src/libmpg123/synth_stereo_avx_float.S \
2086+    src/libmpg123/synth_stereo_avx_s32.S \
2087+    src/libmpg123/dct64_avx.S \
2088+    src/libmpg123/synth_stereo_avx.S \
2089+    src/libmpg123/feature.c
2090+
2091+DECODER_CFLAGS_MIPS := -DOPT_GENERIC -DREAL_IS_FLOAT
2092+
2093+DECODER_SRC_MIPS := \
2094+    src/libmpg123/stringbuf.c \
2095+    src/libmpg123/icy.c \
2096+    src/libmpg123/icy2utf8.c \
2097+    src/libmpg123/ntom.c \
2098+    src/libmpg123/synth.c \
2099+    src/libmpg123/synth_8bit.c \
2100+    src/libmpg123/layer1.c \
2101+    src/libmpg123/layer2.c \
2102+    src/libmpg123/layer3.c \
2103+    src/libmpg123/synth_s32.c \
2104+    src/libmpg123/synth_real.c \
2105+    src/libmpg123/feature.c
2106+
2107+ifeq ($(TARGET_ARCH_ABI),armeabi)
2108+DECODER_CFLAGS := $(DECODER_CFLAGS_NEON)
2109+DECODER_SRC := $(DECODER_SRC_NEON)
2110+endif
2111+ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
2112+DECODER_CFLAGS := $(DECODER_CFLAGS_NEON)
2113+DECODER_SRC := $(DECODER_SRC_NEON)
2114+endif
2115+ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
2116+DECODER_CFLAGS := $(DECODER_CFLAGS_NEON64)
2117+DECODER_SRC := $(DECODER_SRC_NEON64)
2118+endif
2119+ifeq ($(TARGET_ARCH_ABI),x86)
2120+DECODER_CFLAGS := $(DECODER_CFLAGS_X86)
2121+DECODER_SRC := $(DECODER_SRC_X86)
2122+endif
2123+ifeq ($(TARGET_ARCH_ABI),x86_64)
2124+DECODER_CFLAGS := $(DECODER_CFLAGS_X64)
2125+DECODER_SRC := $(DECODER_SRC_X64)
2126+endif
2127+ifeq ($(TARGET_ARCH_ABI),mips)
2128+DECODER_CFLAGS := $(DECODER_CFLAGS_MIPS)
2129+DECODER_SRC := $(DECODER_SRC_MIPS)
2130+endif
2131+ifeq ($(TARGET_ARCH_ABI),mips64)
2132+DECODER_CFLAGS := $(DECODER_CFLAGS_MIPS)
2133+DECODER_SRC := $(DECODER_SRC_MIPS)
2134+endif
2135+
2136+LOCAL_CFLAGS := $(DECODER_CFLAGS)
2137+
2138+LOCAL_SRC_FILES := \
2139+    src/libmpg123/parse.c \
2140+    src/libmpg123/frame.c \
2141+    src/libmpg123/format.c \
2142+    src/libmpg123/dct64.c \
2143+    src/libmpg123/equalizer.c \
2144+    src/libmpg123/id3.c \
2145+    src/libmpg123/optimize.c \
2146+    src/libmpg123/readers.c \
2147+    src/libmpg123/tabinit.c \
2148+    src/libmpg123/libmpg123.c \
2149+    src/libmpg123/index.c \
2150+    src/compat/compat_str.c \
2151+    src/compat/compat.c \
2152+    $(DECODER_SRC)
2153+
2154+
2155+LOCAL_EXPORT_C_INCLUDES += $(LOCAL_C_INCLUDES)
2156+
2157+include $(BUILD_SHARED_LIBRARY)
2158