ReactOS  r74405
mpg123 advanced parameter API

Typedefs

typedef struct mpg123_pars_struct mpg123_pars
 

Functions

MPG123_EXPORT mpg123_handlempg123_parnew (mpg123_pars *mp, const char *decoder, int *error)
 
MPG123_EXPORT mpg123_parsmpg123_new_pars (int *error)
 
MPG123_EXPORT void mpg123_delete_pars (mpg123_pars *mp)
 
MPG123_EXPORT int mpg123_fmt_none (mpg123_pars *mp)
 
MPG123_EXPORT int mpg123_fmt_all (mpg123_pars *mp)
 
MPG123_EXPORT int mpg123_fmt (mpg123_pars *mp, long rate, int channels, int encodings)
 
MPG123_EXPORT int mpg123_fmt_support (mpg123_pars *mp, long rate, int encoding)
 
MPG123_EXPORT int mpg123_par (mpg123_pars *mp, enum mpg123_parms type, long value, double fvalue)
 
MPG123_EXPORT int mpg123_getpar (mpg123_pars *mp, enum mpg123_parms type, long *val, double *fval)
 

Detailed Description

Direct access to a parameter set without full handle around it. Possible uses:

The functions for handling mpg123_pars (mpg123_par() and mpg123_fmt() family) directly return a fully qualified mpg123 error code, the ones operating on full handles normally MPG123_OK or MPG123_ERR, storing the specific error code itseld inside the handle.

Typedef Documentation

Opaque structure for the libmpg123 decoder parameters.

Definition at line 1112 of file mpg123.h.

Function Documentation

MPG123_EXPORT void mpg123_delete_pars ( mpg123_pars mp)

Delete and free up memory used by a mpg123_pars data structure

Definition at line 162 of file frame.c.

163 {
164  if(mp != NULL) free(mp);
165 }
#define free
Definition: debug_ros.c:5
smooth NULL
Definition: ftsmooth.c:464
MPG123_EXPORT int mpg123_fmt ( mpg123_pars mp,
long  rate,
int  channels,
int  encodings 
)

Set the audio format support of a mpg123_pars in detail:

Parameters
rateThe sample rate value (in Hertz).
channelsA combination of MPG123_STEREO and MPG123_MONO.
encodingsA combination of accepted encodings for rate and channels, p.ex MPG123_ENC_SIGNED16|MPG123_ENC_ULAW_8 (or 0 for no support).
Returns
MPG123_OK on success

Definition at line 415 of file format.c.

Referenced by mpg123_format().

416 {
417  int ie, ic, ratei;
418  int ch[2] = {0, 1};
419  if(mp == NULL) return MPG123_BAD_PARS;
421 
422  if(PVERB(mp,3)) fprintf(stderr, "Note: Want to enable format %li/%i for encodings 0x%x.\n", rate, channels, encodings);
423 
424  if(!(channels & MPG123_STEREO)) ch[1] = 0; /* {0,0} */
425  else if(!(channels & MPG123_MONO)) ch[0] = 1; /* {1,1} */
426  ratei = rate2num(mp, rate);
427  if(ratei < 0) return MPG123_BAD_RATE;
428 
429  /* now match the encodings */
430  for(ic = 0; ic < 2; ++ic)
431  {
432  for(ie = 0; ie < MPG123_ENCODINGS; ++ie)
433  if(good_enc(my_encodings[ie]) && ((my_encodings[ie] & encodings) == my_encodings[ie]))
434  mp->audio_caps[ch[ic]][ratei][ie] = 1;
435 
436  if(ch[0] == ch[1]) break; /* no need to do it again */
437  }
438 
439  return MPG123_OK;
440 }
#define PVERB(mp, level)
int This channels
Definition: rdpsnd_libao.c:37
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73
int rate
Definition: pcmconverter.c:77
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:464
static int good_enc(const int enc)
Definition: format.c:104
static const int my_encodings[MPG123_ENCODINGS]
Definition: format.c:39
static int rate2num(mpg123_pars *mp, long r)
Definition: format.c:144
FILE * stderr
#define MPG123_ENCODINGS
MPG123_EXPORT int mpg123_fmt_all ( mpg123_pars mp)

Configure mpg123 parameters to accept all formats (also any custom rate you may set) – this is default.

Returns
MPG123_OK on success

Definition at line 390 of file format.c.

Referenced by frame_default_pars(), and mpg123_format_all().

391 {
392  size_t rate, ch, enc;
393  if(mp == NULL) return MPG123_BAD_PARS;
394 
395  if(PVERB(mp,3)) fprintf(stderr, "Note: Enabling all formats.\n");
396 
397  for(ch=0; ch < NUM_CHANNELS; ++ch)
398  for(rate=0; rate < MPG123_RATES+1; ++rate)
399  for(enc=0; enc < MPG123_ENCODINGS; ++enc)
400  mp->audio_caps[ch][rate][enc] = good_enc(my_encodings[enc]) ? 1 : 0;
401 
402  return MPG123_OK;
403 }
#define PVERB(mp, level)
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73
int rate
Definition: pcmconverter.c:77
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:464
static int good_enc(const int enc)
Definition: format.c:104
static const int my_encodings[MPG123_ENCODINGS]
Definition: format.c:39
#define NUM_CHANNELS
Definition: frame.h:72
#define MPG123_RATES
FILE * stderr
#define MPG123_ENCODINGS
MPG123_EXPORT int mpg123_fmt_none ( mpg123_pars mp)

Configure mpg123 parameters to accept no output format at all, use before specifying supported formats with mpg123_format

Returns
MPG123_OK on success

Definition at line 369 of file format.c.

Referenced by mpg123_format_none().

370 {
371  if(mp == NULL) return MPG123_BAD_PARS;
372 
373  if(PVERB(mp,3)) fprintf(stderr, "Note: Disabling all formats.\n");
374 
375  memset(mp->audio_caps,0,sizeof(mp->audio_caps));
376  return MPG123_OK;
377 }
#define PVERB(mp, level)
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:464
FILE * stderr
#define memset(x, y, z)
Definition: compat.h:39
MPG123_EXPORT int mpg123_fmt_support ( mpg123_pars mp,
long  rate,
int  encoding 
)

Check to see if a specific format at a specific rate is supported by mpg123_pars.

Returns
0 for no support (that includes invalid parameters), MPG123_STEREO, MPG123_MONO or MPG123_STEREO|MPG123_MONO.

Definition at line 448 of file format.c.

Referenced by mpg123_format_support().

449 {
450  int ch = 0;
451  int ratei, enci;
452  ratei = rate2num(mp, rate);
453  enci = enc2num(encoding);
454  if(mp == NULL || ratei < 0 || enci < 0) return 0;
455  if(mp->audio_caps[0][ratei][enci]) ch |= MPG123_MONO;
456  if(mp->audio_caps[1][ratei][enci]) ch |= MPG123_STEREO;
457  return ch;
458 }
static int enc2num(int encoding)
Definition: format.c:155
const XML_Char const XML_Char * encoding
Definition: expat.h:187
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73
int rate
Definition: pcmconverter.c:77
smooth NULL
Definition: ftsmooth.c:464
static int rate2num(mpg123_pars *mp, long r)
Definition: format.c:144
MPG123_EXPORT int mpg123_getpar ( mpg123_pars mp,
enum mpg123_parms  type,
long val,
double fval 
)

Get a specific parameter, for a specific mpg123_pars. See the mpg123_parms enumeration for a list of available parameters.

Definition at line 260 of file libmpg123.c.

Referenced by mpg123_getparam().

261 {
262  int ret = 0;
263 
264  if(mp == NULL) return MPG123_BAD_PARS;
265  switch(key)
266  {
267  case MPG123_VERBOSE:
268  if(val) *val = mp->verbose;
269  break;
270  case MPG123_FLAGS:
271  case MPG123_ADD_FLAGS:
272  if(val) *val = mp->flags;
273  break;
274  case MPG123_FORCE_RATE:
275  if(val)
276 #ifdef NO_NTOM
277  *val = 0;
278 #else
279  *val = mp->force_rate;
280 #endif
281  break;
282  case MPG123_DOWN_SAMPLE:
283  if(val) *val = mp->down_sample;
284  break;
285  case MPG123_RVA:
286  if(val) *val = mp->rva;
287  break;
288  case MPG123_DOWNSPEED:
289  if(val) *val = mp->halfspeed;
290  break;
291  case MPG123_UPSPEED:
292  if(val) *val = mp->doublespeed;
293  break;
294  case MPG123_ICY_INTERVAL:
295 #ifndef NO_ICY
296  if(val) *val = (long)mp->icy_interval;
297 #else
298  if(val) *val = 0;
299 #endif
300  break;
301  case MPG123_OUTSCALE:
302  if(fval) *fval = mp->outscale;
303  if(val) *val = (long)(mp->outscale*SHORT_SCALE);
304  break;
305  case MPG123_RESYNC_LIMIT:
306  if(val) *val = mp->resync_limit;
307  break;
308  case MPG123_INDEX_SIZE:
309  if(val)
310 #ifdef FRAME_INDEX
311  *val = mp->index_size;
312 #else
313  *val = 0; /* graceful fallback: no index is index of zero size */
314 #endif
315  break;
316  case MPG123_PREFRAMES:
317  *val = mp->preframes;
318  break;
319  case MPG123_FEEDPOOL:
320 #ifndef NO_FEEDER
321  *val = mp->feedpool;
322 #else
324 #endif
325  break;
326  case MPG123_FEEDBUFFER:
327 #ifndef NO_FEEDER
328  *val = mp->feedbuffer;
329 #else
331 #endif
332  break;
333  default:
334  ret = MPG123_BAD_PARAM;
335  }
336  return ret;
337 }
long index_size
Definition: frame.h:81
long preframes
Definition: frame.h:82
long feedbuffer
Definition: frame.h:85
long icy_interval
Definition: frame.h:77
long doublespeed
Definition: frame.h:70
long halfspeed
Definition: frame.h:69
smooth NULL
Definition: ftsmooth.c:464
unsigned long
Definition: typeof.h:98
GLuint GLfloat * val
Definition: glext.h:7180
long force_rate
Definition: frame.h:65
int ret
#define SHORT_SCALE
long resync_limit
Definition: frame.h:80
double outscale
Definition: frame.h:79
Definition: path.c:42
MPG123_EXPORT mpg123_pars* mpg123_new_pars ( int error)

Allocate memory for and return a pointer to a new mpg123_pars

Definition at line 154 of file frame.c.

155 {
156  mpg123_pars *mp = malloc(sizeof(struct mpg123_pars_struct));
157  if(mp != NULL){ frame_default_pars(mp); if(error != NULL) *error = MPG123_OK; }
158  else if(error != NULL) *error = MPG123_OUT_OF_MEM;
159  return mp;
160 }
static void frame_default_pars(mpg123_pars *mp)
Definition: frame.c:36
smooth NULL
Definition: ftsmooth.c:464
#define malloc
Definition: debug_ros.c:4
MPG123_EXPORT int mpg123_par ( mpg123_pars mp,
enum mpg123_parms  type,
long  value,
double  fvalue 
)

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

Definition at line 138 of file libmpg123.c.

Referenced by mpg123_param().

139 {
140  int ret = MPG123_OK;
141 
142  if(mp == NULL) return MPG123_BAD_PARS;
143  switch(key)
144  {
145  case MPG123_VERBOSE:
146  mp->verbose = val;
147  break;
148  case MPG123_FLAGS:
149 #ifndef GAPLESS
151 #endif
152  if(ret == MPG123_OK) mp->flags = val;
153  debug1("set flags to 0x%lx", (unsigned long) mp->flags);
154  break;
155  case MPG123_ADD_FLAGS:
156 #ifndef GAPLESS
157  /* Enabling of gapless mode doesn't work when it's not there, but disabling (below) is no problem. */
158  if(val & MPG123_GAPLESS) ret = MPG123_NO_GAPLESS;
159  else
160 #endif
161  mp->flags |= val;
162  debug1("set flags to 0x%lx", (unsigned long) mp->flags);
163  break;
164  case MPG123_REMOVE_FLAGS:
165  mp->flags &= ~val;
166  debug1("set flags to 0x%lx", (unsigned long) mp->flags);
167  break;
168  case MPG123_FORCE_RATE: /* should this trigger something? */
169 #ifdef NO_NTOM
170  if(val > 0)
171  ret = MPG123_BAD_RATE;
172 #else
173  if(val > 96000) ret = MPG123_BAD_RATE;
174  else mp->force_rate = val < 0 ? 0 : val; /* >0 means enable, 0 disable */
175 #endif
176  break;
177  case MPG123_DOWN_SAMPLE:
178 #ifdef NO_DOWNSAMPLE
179  if(val != 0) ret = MPG123_BAD_RATE;
180 #else
181  if(val < 0 || val > 2) ret = MPG123_BAD_RATE;
182  else mp->down_sample = (int)val;
183 #endif
184  break;
185  case MPG123_RVA:
187  else mp->rva = (int)val;
188  break;
189  case MPG123_DOWNSPEED:
190  mp->halfspeed = val < 0 ? 0 : val;
191  break;
192  case MPG123_UPSPEED:
193  mp->doublespeed = val < 0 ? 0 : val;
194  break;
195  case MPG123_ICY_INTERVAL:
196 #ifndef NO_ICY
197  mp->icy_interval = val > 0 ? val : 0;
198 #else
199  if(val > 0) ret = MPG123_BAD_PARAM;
200 #endif
201  break;
202  case MPG123_OUTSCALE:
203  /* Choose the value that is non-zero, if any.
204  Downscaling integers to 1.0 . */
205  mp->outscale = val == 0 ? fval : (double)val/SHORT_SCALE;
206  break;
207  case MPG123_TIMEOUT:
208 #ifdef TIMEOUT_READ
209  mp->timeout = val >= 0 ? val : 0;
210 #else
211  if(val > 0) ret = MPG123_NO_TIMEOUT;
212 #endif
213  break;
214  case MPG123_RESYNC_LIMIT:
215  mp->resync_limit = val;
216  break;
217  case MPG123_INDEX_SIZE:
218 #ifdef FRAME_INDEX
219  mp->index_size = val;
220 #else
221  ret = MPG123_NO_INDEX;
222 #endif
223  break;
224  case MPG123_PREFRAMES:
225  if(val >= 0) mp->preframes = val;
226  else ret = MPG123_BAD_VALUE;
227  break;
228  case MPG123_FEEDPOOL:
229 #ifndef NO_FEEDER
230  if(val >= 0) mp->feedpool = val;
231  else ret = MPG123_BAD_VALUE;
232 #else
234 #endif
235  break;
236  case MPG123_FEEDBUFFER:
237 #ifndef NO_FEEDER
238  if(val > 0) mp->feedbuffer = val;
239  else ret = MPG123_BAD_VALUE;
240 #else
242 #endif
243  break;
244  default:
245  ret = MPG123_BAD_PARAM;
246  }
247  return ret;
248 }
long index_size
Definition: frame.h:81
long preframes
Definition: frame.h:82
long feedbuffer
Definition: frame.h:85
long icy_interval
Definition: frame.h:77
long doublespeed
Definition: frame.h:70
long halfspeed
Definition: frame.h:69
smooth NULL
Definition: ftsmooth.c:464
GLuint GLfloat * val
Definition: glext.h:7180
long force_rate
Definition: frame.h:65
int ret
#define SHORT_SCALE
long resync_limit
Definition: frame.h:80
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:79
double outscale
Definition: frame.h:79
#define debug1(s, a)
Definition: debug.h:45
Definition: path.c:42
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
MPG123_EXPORT mpg123_handle* mpg123_parnew ( mpg123_pars mp,
const char decoder,
int error 
)

Create a handle with preset parameters.

Definition at line 49 of file libmpg123.c.

Referenced by mpg123_new().

50 {
51  mpg123_handle *fr = NULL;
52  int err = MPG123_OK;
53 
54  if(initialized) fr = (mpg123_handle*) malloc(sizeof(mpg123_handle));
55  else err = MPG123_NOT_INITIALIZED;
56  if(fr != NULL)
57  {
58  frame_init_par(fr, mp);
59  debug("cpu opt setting");
60  if(frame_cpu_opt(fr, decoder) != 1)
61  {
62  err = MPG123_BAD_DECODER;
63  frame_exit(fr);
64  free(fr);
65  fr = NULL;
66  }
67  }
68  if(fr != NULL)
69  {
70  fr->decoder_change = 1;
71  }
72  else if(err == MPG123_OK) err = MPG123_OUT_OF_MEM;
73 
74  if(error != NULL) *error = err;
75  return fr;
76 }
#define frame_init_par
Definition: intsym.h:154
static int initialized
Definition: libmpg123.c:17
#define free
Definition: debug_ros.c:5
#define frame_exit
Definition: intsym.h:160
int int int * err
Definition: fci.h:172
smooth NULL
Definition: ftsmooth.c:464
#define debug(s)
Definition: debug.h:44
#define err(...)
#define frame_cpu_opt
Definition: intsym.h:203
#define malloc
Definition: debug_ros.c:4