ReactOS  r76032
mpg123 library and handle setup

Typedefs

typedef struct mpg123_handle_struct mpg123_handle
 

Enumerations

enum  mpg123_parms {
  MPG123_VERBOSE = 0, MPG123_FLAGS, MPG123_ADD_FLAGS, MPG123_FORCE_RATE,
  MPG123_DOWN_SAMPLE, MPG123_RVA, MPG123_DOWNSPEED, MPG123_UPSPEED,
  MPG123_START_FRAME, MPG123_DECODE_FRAMES, MPG123_ICY_INTERVAL, MPG123_OUTSCALE,
  MPG123_TIMEOUT, MPG123_REMOVE_FLAGS, MPG123_RESYNC_LIMIT, MPG123_INDEX_SIZE,
  MPG123_PREFRAMES, MPG123_FEEDPOOL, MPG123_FEEDBUFFER
}
 
enum  mpg123_param_flags {
  MPG123_FORCE_MONO = 0x7, MPG123_MONO_LEFT = 0x1, MPG123_MONO_RIGHT = 0x2, MPG123_MONO_MIX = 0x4,
  MPG123_FORCE_STEREO = 0x8, MPG123_FORCE_8BIT = 0x10, MPG123_QUIET = 0x20, MPG123_GAPLESS = 0x40,
  MPG123_NO_RESYNC = 0x80, MPG123_SEEKBUFFER = 0x100, MPG123_FUZZY = 0x200, MPG123_FORCE_FLOAT = 0x400,
  MPG123_PLAIN_ID3TEXT = 0x800, MPG123_IGNORE_STREAMLENGTH = 0x1000, MPG123_SKIP_ID3V2 = 0x2000, MPG123_IGNORE_INFOFRAME = 0x4000,
  MPG123_AUTO_RESAMPLE = 0x8000, MPG123_PICTURE = 0x10000, MPG123_NO_PEEK_END = 0x20000, MPG123_FORCE_SEEKABLE = 0x40000
}
 
enum  mpg123_param_rva { MPG123_RVA_OFF = 0, MPG123_RVA_MIX = 1, MPG123_RVA_ALBUM = 2, MPG123_RVA_MAX = MPG123_RVA_ALBUM }
 
enum  mpg123_feature_set {
  MPG123_FEATURE_ABI_UTF8OPEN = 0, MPG123_FEATURE_OUTPUT_8BIT, MPG123_FEATURE_OUTPUT_16BIT, MPG123_FEATURE_OUTPUT_32BIT,
  MPG123_FEATURE_INDEX, MPG123_FEATURE_PARSE_ID3V2, MPG123_FEATURE_DECODE_LAYER1, MPG123_FEATURE_DECODE_LAYER2,
  MPG123_FEATURE_DECODE_LAYER3, MPG123_FEATURE_DECODE_ACCURATE, MPG123_FEATURE_DECODE_DOWNSAMPLE, MPG123_FEATURE_DECODE_NTOM,
  MPG123_FEATURE_PARSE_ICY, MPG123_FEATURE_TIMEOUT_READ, MPG123_FEATURE_EQUALIZER
}
 

Functions

MPG123_EXPORT int mpg123_init (void)
 
MPG123_EXPORT void mpg123_exit (void)
 
MPG123_EXPORT mpg123_handlempg123_new (const char *decoder, int *error)
 
MPG123_EXPORT void mpg123_delete (mpg123_handle *mh)
 
MPG123_EXPORT int mpg123_param (mpg123_handle *mh, enum mpg123_parms type, long value, double fvalue)
 
MPG123_EXPORT int mpg123_getparam (mpg123_handle *mh, enum mpg123_parms type, long *value, double *fvalue)
 
MPG123_EXPORT int mpg123_feature (const enum mpg123_feature_set key)
 

Detailed Description

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...

Typedef Documentation

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.

Definition at line 139 of file mpg123.h.

Enumeration Type Documentation

Feature set available for query with mpg123_feature.

Enumerator
MPG123_FEATURE_ABI_UTF8OPEN 

mpg123 expects path names to be given in UTF-8 encoding instead of plain native.

MPG123_FEATURE_OUTPUT_8BIT 

8bit output

MPG123_FEATURE_OUTPUT_16BIT 

16bit output

MPG123_FEATURE_OUTPUT_32BIT 

32bit output

MPG123_FEATURE_INDEX 

support for building a frame index for accurate seeking

MPG123_FEATURE_PARSE_ID3V2 

id3v2 parsing

MPG123_FEATURE_DECODE_LAYER1 

mpeg layer-1 decoder enabled

MPG123_FEATURE_DECODE_LAYER2 

mpeg layer-2 decoder enabled

MPG123_FEATURE_DECODE_LAYER3 

mpeg layer-3 decoder enabled

MPG123_FEATURE_DECODE_ACCURATE 

accurate decoder rounding

MPG123_FEATURE_DECODE_DOWNSAMPLE 

downsample (sample omit)

MPG123_FEATURE_DECODE_NTOM 

flexible rate decoding

MPG123_FEATURE_PARSE_ICY 

ICY support

MPG123_FEATURE_TIMEOUT_READ 

Reader with timeout (network).

MPG123_FEATURE_EQUALIZER 

tunable equalizer

Definition at line 253 of file mpg123.h.

Flag bits for MPG123_FLAGS, use the usual binary or to combine.

Enumerator
MPG123_FORCE_MONO 

0111 Force some mono mode: This is a test bitmask for seeing if any mono forcing is active.

MPG123_MONO_LEFT 

0001 Force playback of left channel only.

MPG123_MONO_RIGHT 

0010 Force playback of right channel only.

MPG123_MONO_MIX 

0100 Force playback of mixed mono.

MPG123_FORCE_STEREO 

1000 Force stereo output.

MPG123_FORCE_8BIT 

00010000 Force 8bit formats.

MPG123_QUIET 

00100000 Suppress any printouts (overrules verbose).

MPG123_GAPLESS 

01000000 Enable gapless decoding (default on if libmpg123 has support).

MPG123_NO_RESYNC 

10000000 Disable resync stream after error.

MPG123_SEEKBUFFER 

000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync).

MPG123_FUZZY 

001000000000 Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC)

MPG123_FORCE_FLOAT 

010000000000 Force floating point output (32 or 64 bits depends on mpg123 internal precision).

MPG123_PLAIN_ID3TEXT 

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.

MPG123_IGNORE_STREAMLENGTH 

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

MPG123_SKIP_ID3V2 

10 0000 0000 0000 Do not parse ID3v2 tags, just skip them.

MPG123_IGNORE_INFOFRAME 

100 0000 0000 0000 Do not parse the LAME/Xing info frame, treat it as normal MPEG data.

MPG123_AUTO_RESAMPLE 

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.

MPG123_PICTURE 

17th bit: Enable storage of pictures from tags (ID3v2 APIC).

MPG123_NO_PEEK_END 

18th bit: Do not seek to the end of the stream in order to probe the stream length and search for the id3v1 field. This also means the file size is unknown unless set using mpg123_set_filesize() and the stream is assumed as non-seekable unless overridden.

MPG123_FORCE_SEEKABLE 

19th bit: Force the stream to be seekable.

Definition at line 192 of file mpg123.h.

193 {
194  MPG123_FORCE_MONO = 0x7
195  ,MPG123_MONO_LEFT = 0x1
196  ,MPG123_MONO_RIGHT = 0x2
197  ,MPG123_MONO_MIX = 0x4
198  ,MPG123_FORCE_STEREO = 0x8
199  ,MPG123_FORCE_8BIT = 0x10
200  ,MPG123_QUIET = 0x20
201  ,MPG123_GAPLESS = 0x40
202  ,MPG123_NO_RESYNC = 0x80
203  ,MPG123_SEEKBUFFER = 0x100
204  ,MPG123_FUZZY = 0x200
205  ,MPG123_FORCE_FLOAT = 0x400
206  ,MPG123_PLAIN_ID3TEXT = 0x800
207  ,MPG123_IGNORE_STREAMLENGTH = 0x1000
208  ,MPG123_SKIP_ID3V2 = 0x2000
209  ,MPG123_IGNORE_INFOFRAME = 0x4000
210  ,MPG123_AUTO_RESAMPLE = 0x8000
211  ,MPG123_PICTURE = 0x10000
212  ,MPG123_NO_PEEK_END = 0x20000
218  ,MPG123_FORCE_SEEKABLE = 0x40000
219 };

choices for MPG123_RVA

Enumerator
MPG123_RVA_OFF 

RVA disabled (default).

MPG123_RVA_MIX 

Use mix/track/radio gain.

MPG123_RVA_ALBUM 

Use album/audiophile gain

MPG123_RVA_MAX 

The maximum RVA code, may increase in future.

Definition at line 222 of file mpg123.h.

Enumeration of the parameters types that it is possible to set/get.

Enumerator
MPG123_VERBOSE 

set verbosity value for enabling messages to stderr, >= 0 makes sense (integer)

MPG123_FLAGS 

set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX (integer)

MPG123_ADD_FLAGS 

add some flags (integer)

MPG123_FORCE_RATE 

when value > 0, force output rate to that value (integer)

MPG123_DOWN_SAMPLE 

0=native rate, 1=half rate, 2=quarter rate (integer)

MPG123_RVA 

one of the RVA choices above (integer)

MPG123_DOWNSPEED 

play a frame N times (integer)

MPG123_UPSPEED 

play every Nth frame (integer)

MPG123_START_FRAME 

start with this frame (skip frames before that, integer)

MPG123_DECODE_FRAMES 

decode only this number of frames (integer)

MPG123_ICY_INTERVAL 

stream contains ICY metadata with this interval (integer)

MPG123_OUTSCALE 

the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer)

MPG123_TIMEOUT 

timeout for reading from a stream (not supported on win32, integer)

MPG123_REMOVE_FLAGS 

remove some flags (inverse of MPG123_ADD_FLAGS, integer)

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).

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.

MPG123_PREFRAMES 

Decode/ignore that many frames in advance for layer 3. This is needed to fill bit reservoir after seeking, for example (but also at least one frame in advance is needed to have all "normal" data for layer 3). Give a positive integer value, please.

MPG123_FEEDPOOL 

For feeder mode, keep that many buffers in a pool to avoid frequent malloc/free. The pool is allocated on mpg123_open_feed(). If you change this parameter afterwards, you can trigger growth and shrinkage during decoding. The default value could change any time. If you care about this, then set it. (integer)

MPG123_FEEDBUFFER 

Minimal size of one internal feeder buffer, again, the default value is subject to change. (integer)

Definition at line 168 of file mpg123.h.

Function Documentation

MPG123_EXPORT void mpg123_delete ( mpg123_handle mh)

Delete handle, mh is either a valid mpg123 handle or NULL.

Parameters
mhhandle

Definition at line 1620 of file libmpg123.c.

1621 {
1622  if(mh != NULL)
1623  {
1624  mpg123_close(mh);
1625  frame_exit(mh); /* free buffers in frame */
1626  free(mh); /* free struct; cast? */
1627  }
1628 }
#define free
Definition: debug_ros.c:5
#define frame_exit
Definition: intsym.h:175
int attribute_align_arg mpg123_close(mpg123_handle *mh)
Definition: libmpg123.c:1602
smooth NULL
Definition: ftsmooth.c:557
MPG123_EXPORT void mpg123_exit ( void  )

Function to close down the mpg123 library. This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library.

Definition at line 49 of file libmpg123.c.

50 {
51  /* nothing yet, but something later perhaps */
52 }
MPG123_EXPORT int mpg123_feature ( const enum mpg123_feature_set  key)

Query libmpg123 features.

Parameters
keyfeature selection
Returns
1 for success, 0 for unimplemented functions

Definition at line 3 of file feature.c.

4 {
5  switch(key)
6  {
8 #ifdef WANT_WIN32_UNICODE
9  return 1;
10 #else
11  return 0;
12 #endif /* WANT_WIN32_UNICODE */
13 
15 #ifdef NO_8BIT
16  return 0;
17 #else
18  return 1;
19 #endif /* mpg123_output_8bit */
20 
22 #ifdef NO_16BIT
23  return 0;
24 #else
25  return 1;
26 #endif /* mpg123_output_16bit */
27 
29 #ifdef NO_32BIT
30  return 0;
31 #else
32  return 1;
33 #endif /* mpg123_output_32bit */
34 
36 #ifdef NO_ID3V2
37  return 0;
38 #else
39  return 1;
40 #endif /* NO_ID3V2 */
41 
43 #ifdef NO_LAYER1
44  return 0;
45 #else
46  return 1;
47 #endif /* NO_LAYER1 */
48 
50 #ifdef NO_LAYER2
51  return 0;
52 #else
53  return 1;
54 #endif /* NO_LAYER2 */
55 
57 #ifdef NO_LAYER3
58  return 0;
59 #else
60  return 1;
61 #endif /* NO_LAYER3 */
62 
64 #ifdef ACCURATE_ROUNDING
65  return 1;
66 #else
67  return 0;
68 #endif /* ACCURATE_ROUNDING */
69 
71 #ifdef NO_DOWNSAMPLE
72  return 0;
73 #else
74  return 1;
75 #endif /* NO_DOWNSAMPLE */
76 
78 #ifdef NO_NTOM
79  return 0;
80 #else
81  return 1;
82 #endif /* NO_NTOM */
83 
85 #ifdef NO_ICY
86  return 0;
87 #else
88  return 1;
89 #endif /* NO_ICY */
90 
92 #ifdef FRAME_INDEX
93  return 1;
94 #else
95  return 0;
96 #endif /* FRAME_INDEX */
98 #ifdef TIMEOUT_READ
99  return 1;
100 #else
101  return 0;
102 #endif
104 #ifndef NO_EQUALIZER
105  return 1;
106 #else
107  return 0;
108 #endif
109 
110  default: return 0;
111  }
112 }
Definition: path.c:42
MPG123_EXPORT int mpg123_getparam ( 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.

Parameters
mhhandle
typeparameter choice
valueinteger value return address
fvaluefloating point value return address
Returns
MPG123_OK on success

Definition at line 262 of file libmpg123.c.

263 {
264  int r;
265 
266  if(mh == NULL) return MPG123_BAD_HANDLE;
267  r = mpg123_getpar(&mh->p, key, val, fval);
268  if(r != MPG123_OK){ mh->err = r; r = MPG123_ERR; }
269  return r;
270 }
struct mpg123_pars_struct p
Definition: frame.h:287
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:557
GLuint GLfloat * val
Definition: glext.h:7180
int attribute_align_arg mpg123_getpar(mpg123_pars *mp, enum mpg123_parms key, long *val, double *fval)
Definition: libmpg123.c:272
Definition: path.c:42
MPG123_EXPORT int mpg123_init ( void  )

Function to initialise the mpg123 library. This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library.

Returns
MPG123_OK if successful, otherwise an error number.

Definition at line 22 of file libmpg123.c.

23 {
24  if((sizeof(short) != 2) || (sizeof(long) < 4)) return MPG123_BAD_TYPES;
25 
26  if(initialized) return MPG123_OK; /* no need to initialize twice */
27 
28 #ifndef NO_LAYER12
29  init_layer12(); /* inits also shared tables with layer1 */
30 #endif
31 #ifndef NO_LAYER3
32  init_layer3();
33 #endif
36  initialized = 1;
37 #if (defined REAL_IS_FLOAT) && (defined IEEE_FLOAT)
38  /* This is rather pointless but it eases my mind to check that we did
39  not enable the special rounding on a VAX or something. */
40  if(12346 != REAL_TO_SHORT_ACCURATE(12345.67f))
41  {
42  error("Bad IEEE 754 rounding. Re-build libmpg123 properly.");
43  return MPG123_ERR;
44  }
45 #endif
46  return MPG123_OK;
47 }
static int initialized
Definition: libmpg123.c:20
#define prepare_decode_tables
Definition: intsym.h:155
#define error(str)
Definition: mkdosfs.c:1605
GLfloat f
Definition: glext.h:7540
#define init_layer12
Definition: intsym.h:152
#define init_layer3
Definition: intsym.h:149
#define check_decoders
Definition: intsym.h:226
MPG123_EXPORT mpg123_handle* mpg123_new ( const char decoder,
int error 
)

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.

Parameters
decoderoptional choice of decoder variant (NULL for default)
erroroptional address to store error codes
Returns
Non-NULL pointer to fresh handle when successful.

Definition at line 55 of file libmpg123.c.

56 {
57  return mpg123_parnew(NULL, decoder, error);
58 }
smooth NULL
Definition: ftsmooth.c:557
mpg123_handle attribute_align_arg * mpg123_parnew(mpg123_pars *mp, const char *decoder, int *error)
Definition: libmpg123.c:61
MPG123_EXPORT int mpg123_param ( mpg123_handle mh,
enum mpg123_parms  type,
long  value,
double  fvalue 
)

Set a specific parameter, for a specific mpg123_handle, using a parameter type key chosen from the mpg123_parms enumeration, to the specified value.

Parameters
mhhandle
typeparameter choice
valueinteger value
fvaluefloating point value
Returns
MPG123_OK on success

Definition at line 125 of file libmpg123.c.

126 {
127  int r;
128 
129  if(mh == NULL) return MPG123_BAD_HANDLE;
130  r = mpg123_par(&mh->p, key, val, fval);
131  if(r != MPG123_OK){ mh->err = r; r = MPG123_ERR; }
132  else
133  { /* Special treatment for some settings. */
134 #ifdef FRAME_INDEX
135  if(key == MPG123_INDEX_SIZE)
136  { /* Apply frame index size and grow property on the fly. */
137  r = frame_index_setup(mh);
138  if(r != MPG123_OK) mh->err = MPG123_INDEX_FAIL;
139  }
140 #endif
141 #ifndef NO_FEEDER
142  /* Feeder pool size is applied right away, reader will react to that. */
144  bc_poolsize(&mh->rdat.buffer, mh->p.feedpool, mh->p.feedbuffer);
145 #endif
146  }
147  return r;
148 }
int attribute_align_arg mpg123_par(mpg123_pars *mp, enum mpg123_parms key, long val, double fval)
Definition: libmpg123.c:150
struct mpg123_pars_struct p
Definition: frame.h:287
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
struct reader_data rdat
Definition: frame.h:286
#define bc_poolsize
Definition: intsym.h:239
smooth NULL
Definition: ftsmooth.c:557
GLuint GLfloat * val
Definition: glext.h:7180
int frame_index_setup(mpg123_handle *fr)
Definition: path.c:42