📄 mpg123.h.in
字号:
/* libmpg123: MPEG Audio Decoder library (version @PACKAGE_VERSION@) copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org*/#ifndef MPG123_LIB_H#define MPG123_LIB_H/** \file mpg123.h The header file for the libmpg123 MPEG Audio decoder *//* These aren't actually in use... seems to work without using libtool. */#ifdef BUILD_MPG123_DLL/* The dll exports. */#define EXPORT __declspec(dllexport)#else#ifdef LINK_MPG123_DLL/* The exe imports. */#define EXPORT __declspec(dllimport)#else/* Nothing on normal/UNIX builds */#define EXPORT#endif#endif@INCLUDE_STDLIB_H@@INCLUDE_SYS_TYPE_H@#ifdef __cplusplusextern "C" {#endif/** \defgroup mpg123_init mpg123 library and handle setup * * Functions to initialise and shutdown the mpg123 library and handles. * The parameters of handles have workable defaults, you only have to tune them when you want to tune something;-) * Tip: Use a RVA setting... * * @{ *//** Opaque structure for the libmpg123 decoder handle. */struct mpg123_handle_struct;/** Opaque structure for the libmpg123 decoder handle. * Most functions take a pointer to a mpg123_handle as first argument and operate on its data in an object-oriented manner. */typedef struct mpg123_handle_struct mpg123_handle;/** Function to initialise the mpg123 library. * This function is not thread-safe. Call it exactly once before any other work with the library. * * \return MPG123_OK if successful, otherwise an error number. */EXPORT int mpg123_init(void);/** Function to close down the mpg123 library. * This function is not thread-safe. Call it exactly once after any work with the library. */EXPORT void mpg123_exit(void);/** Create a handle with optional choice of decoder (named by a string, see mpg123_decoders() or mpg123_supported_decoders()). * and optional retrieval of an error code to feed to mpg123_plain_strerror(). * Optional means: Any of or both the parameters may be NULL. * * \return Non-NULL pointer when successful. */EXPORT mpg123_handle *mpg123_new(const char* decoder, int *error);/** Delete handle, mh is either a valid mpg123 handle or NULL. */EXPORT void mpg123_delete(mpg123_handle *mh);/** Enumeration of the parameters types that it is possible to set/get. */enum mpg123_parms{ MPG123_VERBOSE, /**< set verbosity value for enabling messages to stderr, >= 0 makes sense */ MPG123_FLAGS, /**< set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX */ MPG123_ADD_FLAGS, /**< add some flags */ MPG123_FORCE_RATE, /**< when value > 0, force output rate to that value */ MPG123_DOWN_SAMPLE, /**< 0=native rate, 1=half rate, 2=quarter rate */ MPG123_RVA, /**< one of the RVA choices above */ MPG123_DOWNSPEED, /**< play a frame N times */ MPG123_UPSPEED, /**< play every Nth frame */ MPG123_START_FRAME, /**< start with this frame (skip frames before that) */ MPG123_DECODE_FRAMES, /**< decode only this number of frames */ MPG123_ICY_INTERVAL, /**< stream contains ICY metadata with this interval */ MPG123_OUTSCALE, /**< the scale for output samples (amplitude) */ MPG123_TIMEOUT, /**< timeout for reading from a stream (not supported on win32) */ MPG123_REMOVE_FLAGS, /**< remove some flags (inverse of MPG123_ADD_FLAGS) */ MPG123_RESYNC_LIMIT /**< Try resync on frame parsing for that many bytes or until end of stream (<0). */};/** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */enum mpg123_param_flags{ MPG123_FORCE_MONO = 0x7 /**< 0111 Force some mono mode: This is a test bitmask for seeing if any mono forcing is active. */ ,MPG123_MONO_LEFT = 0x1 /**< 0001 Force playback of left channel only. */ ,MPG123_MONO_RIGHT = 0x2 /**< 0010 Force playback of right channel only. */ ,MPG123_MONO_MIX = 0x4 /**< 0100 Force playback of mixed mono. */ ,MPG123_FORCE_STEREO = 0x8 /**< 1000 Force stereo output. */ ,MPG123_FORCE_8BIT = 0x10 /**< 00010000 Force 8bit formats. */ ,MPG123_QUIET = 0x20 /**< 00100000 Suppress any printouts (overrules verbose). */ ,MPG123_GAPLESS = 0x40 /**< 01000000 Enable gapless decoding (default on if libmpg123 has support). */ ,MPG123_NO_RESYNC = 0x80 /**< 10000000 Disable resync stream after error. */ ,MPG123_SEEKBUFFER = 0x100 /**< 000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync). */};/** choices for MPG123_RVA */enum mpg123_param_rva{ MPG123_RVA_OFF = 0 /**< RVA disabled (default). */ ,MPG123_RVA_MIX = 1 /**< Use mix/track/radio gain. */ ,MPG123_RVA_ALBUM = 2 /**< Use album/audiophile gain */ ,MPG123_RVA_MAX = MPG123_RVA_ALBUM /**< The maximum RVA code, may increase in future. */};/* TODO: Assess the possibilities and troubles of changing parameters during playback. *//** Set a specific parameter, for a specific mpg123_handle, using a parameter * type key chosen from the mpg123_parms enumeration, to the specified value. */EXPORT int mpg123_param(mpg123_handle *mh, enum mpg123_parms type, long value, double fvalue);/** Get a specific parameter, for a specific mpg123_handle. * See the mpg123_parms enumeration for a list of available parameters. */EXPORT int mpg123_getparam(mpg123_handle *mh, enum mpg123_parms type, long *val, double *fval);/* @} *//** \defgroup mpg123_error mpg123 error handling * * Functions to get text version of the error numbers and an enumeration * of the error codes returned by libmpg123. * * Most functions operating on a mpg123_handle simply return MPG123_OK on success and MPG123_ERR on failure (setting the internal error variable of the handle to the specific error code). * Decoding/seek functions may also return message codes MPG123_DONE, MPG123_NEW_FORMAT and MPG123_NEED_MORE. * The positive range of return values is used for "useful" values when appropriate. * * @{ *//** Enumeration of the message and error codes and returned by libmpg123 functions. */enum mpg123_errors{ MPG123_DONE=-12, /**< Message: Track ended. */ MPG123_NEW_FORMAT=-11, /**< Message: Output format will be different on next call. */ MPG123_NEED_MORE=-10, /**< Message: For feed reader: "Feed me more!" */ MPG123_ERR=-1, /**< Generic Error */ MPG123_OK=0, /**< Success */ MPG123_BAD_OUTFORMAT, /**< Unable to set up output format! */ MPG123_BAD_CHANNEL, /**< Invalid channel number specified. */ MPG123_BAD_RATE, /**< Invalid sample rate specified. */ MPG123_ERR_16TO8TABLE, /**< Unable to allocate memory for 16 to 8 converter table! */ MPG123_BAD_PARAM, /**< Bad parameter id! */ MPG123_BAD_BUFFER, /**< Bad buffer given -- invalid pointer or too small size. */ MPG123_OUT_OF_MEM, /**< Out of memory -- some malloc() failed. */ MPG123_NOT_INITIALIZED, /**< You didn't initialize the library! */ MPG123_BAD_DECODER, /**< Invalid decoder choice. */ MPG123_BAD_HANDLE, /**< Invalid mpg123 handle. */ MPG123_NO_BUFFERS, /**< Unable to initialize frame buffers (out of memory?). */ MPG123_BAD_RVA, /**< Invalid RVA mode. */ MPG123_NO_GAPLESS, /**< This build doesn't support gapless decoding. */ MPG123_NO_SPACE, /**< Not enough buffer space. */ MPG123_BAD_TYPES, /**< Incompatible numeric data types. */ MPG123_BAD_BAND, /**< Bad equalizer band. */ MPG123_ERR_NULL, /**< Null pointer given where valid storage address needed. */ MPG123_ERR_READER, /**< Error reading the stream. */ MPG123_NO_SEEK_FROM_END,/**< Cannot seek from end (end is not known). */ MPG123_BAD_WHENCE, /**< Invalid 'whence' for seek function.*/ MPG123_NO_TIMEOUT, /**< Build does not support stream timeouts. */ MPG123_BAD_FILE, /**< File access error. */ MPG123_NO_SEEK, /**< Seek not supported by stream. */ MPG123_NO_READER, /**< No stream opened. */ MPG123_BAD_PARS, /**< Bad parameter handle. */ MPG123_BAD_INDEX_PAR, /**< Bad parameters to mpg123_index() */ MPG123_OUT_OF_SYNC, /**< Lost track in bytestream and did not try to resync. */ MPG123_RESYNC_FAIL /**< Resync failed to find valid MPEG data. */};/** Return a string describing that error errcode means. */EXPORT const char* mpg123_plain_strerror(int errcode);/** Give string describing what error has occured in the context of handle mh. * When a function operating on an mpg123 handle returns MPG123_ERR, you should check for the actual reason via * char *errmsg = mpg123_strerror(mh) * This function will catch mh == NULL and return the message for MPG123_BAD_HANDLE. */EXPORT const char* mpg123_strerror(mpg123_handle *mh);/** Return the plain errcode intead of a string. */EXPORT int mpg123_errcode(mpg123_handle *mh);/*@}*//** \defgroup mpg123_decoder mpg123 decoder selection * * Functions to list and select the available decoders. * Perhaps the most prominent feature of mpg123: You have several (optimized) decoders to choose from (on x86 and PPC (MacOS) systems, that is). * * @{ *//** Return a NULL-terminated array of generally available decoder names (plain 8bit ASCII). */EXPORT char **mpg123_decoders();/** Return a NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII). */EXPORT char **mpg123_supported_decoders();/** Set the chosen decoder to 'decoder_name' */EXPORT int mpg123_decoder(mpg123_handle *mh, const char* decoder_name);/*@}*//** \defgroup mpg123_output mpg123 output audio format * * Functions to get and select the format of the decoded audio. * * @{ *//** 16 or 8 bits, signed or unsigned... all flags fit into 8 bits, float/double are not yet standard and special anyway */enum mpg123_enc_enum{ MPG123_ENC_16 = 0x40 /**< 0100 0000 Some 16 bit encoding... */ ,MPG123_ENC_SIGNED = 0x80 /**< 1000 0000 Some signed encoding... */ ,MPG123_ENC_8 = 0x0f /**< 0000 1111 Some 8 bit encoding... */ ,MPG123_ENC_SIGNED_16 = (MPG123_ENC_16|MPG123_ENC_SIGNED|0x10) /**< 1101 0000 signed 16 bit */ ,MPG123_ENC_UNSIGNED_16 = (MPG123_ENC_16|0x20) /**< 0110 0000 unsigned 16 bit*/ ,MPG123_ENC_UNSIGNED_8 = 0x01 /**< 0000 0001 unsigned 8 bit*/ ,MPG123_ENC_SIGNED_8 = (MPG123_ENC_SIGNED|0x02) /**< 1000 0010 signed 8 bit*/ ,MPG123_ENC_ULAW_8 = 0x04 /**< 0000 0100 ulaw 8 bit*/ ,MPG123_ENC_ALAW_8 = 0x08 /**< 0000 1000 alaw 8 bit */ ,MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16 | MPG123_ENC_UNSIGNED_16 | MPG123_ENC_UNSIGNED_8 | MPG123_ENC_SIGNED_8 | MPG123_ENC_ULAW_8 | MPG123_ENC_ALAW_8 ) /**< any encoding */};/** They can be combined into one number (3) to indicate mono and stereo... */enum mpg123_channelcount{ MPG123_MONO = 1 ,MPG123_STEREO = 2};/** An array of supported standard sample rates * These are possible native sample rates of MPEG audio files.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -