ReactOS  r75907
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 *value, double *fvalue)
 

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

Parameters
mpparameter handle

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:513
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
mpparameter handle
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 404 of file format.c.

Referenced by mpg123_format().

405 {
406  int ie, ic, ratei;
407  int ch[2] = {0, 1};
408  if(mp == NULL) return MPG123_BAD_PARS;
410 
411  if(PVERB(mp,3)) fprintf(stderr, "Note: Want to enable format %li/%i for encodings 0x%x.\n", rate, channels, encodings);
412 
413  if(!(channels & MPG123_STEREO)) ch[1] = 0; /* {0,0} */
414  else if(!(channels & MPG123_MONO)) ch[0] = 1; /* {1,1} */
415  ratei = rate2num(mp, rate);
416  if(ratei < 0) return MPG123_BAD_RATE;
417 
418  /* now match the encodings */
419  for(ic = 0; ic < 2; ++ic)
420  {
421  for(ie = 0; ie < MPG123_ENCODINGS; ++ie)
422  if(good_enc(my_encodings[ie]) && ((my_encodings[ie] & encodings) == my_encodings[ie]))
423  mp->audio_caps[ch[ic]][ratei][ie] = 1;
424 
425  if(ch[0] == ch[1]) break; /* no need to do it again */
426  }
427 
428  return MPG123_OK;
429 }
#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:80
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:513
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:133
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.

Parameters
mpparameter handle
Returns
MPG123_OK on success

Definition at line 379 of file format.c.

Referenced by frame_default_pars(), and mpg123_format_all().

380 {
381  size_t rate, ch, enc;
382  if(mp == NULL) return MPG123_BAD_PARS;
383 
384  if(PVERB(mp,3)) fprintf(stderr, "Note: Enabling all formats.\n");
385 
386  for(ch=0; ch < NUM_CHANNELS; ++ch)
387  for(rate=0; rate < MPG123_RATES+1; ++rate)
388  for(enc=0; enc < MPG123_ENCODINGS; ++enc)
389  mp->audio_caps[ch][rate][enc] = good_enc(my_encodings[enc]) ? 1 : 0;
390 
391  return MPG123_OK;
392 }
#define PVERB(mp, level)
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73
int rate
Definition: pcmconverter.c:80
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:513
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

Parameters
mpparameter handle
Returns
MPG123_OK on success

Definition at line 358 of file format.c.

Referenced by mpg123_format_none().

359 {
360  if(mp == NULL) return MPG123_BAD_PARS;
361 
362  if(PVERB(mp,3)) fprintf(stderr, "Note: Disabling all formats.\n");
363 
364  memset(mp->audio_caps,0,sizeof(mp->audio_caps));
365  return MPG123_OK;
366 }
#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:513
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.

Parameters
mpparameter handle
ratesampling rate
encodingencoding
Returns
0 for no support (that includes invalid parameters), MPG123_STEREO, MPG123_MONO or MPG123_STEREO|MPG123_MONO.

Definition at line 437 of file format.c.

Referenced by mpg123_format_support().

438 {
439  int ch = 0;
440  int ratei, enci;
441  ratei = rate2num(mp, rate);
442  enci = enc2num(encoding);
443  if(mp == NULL || ratei < 0 || enci < 0) return 0;
444  if(mp->audio_caps[0][ratei][enci]) ch |= MPG123_MONO;
445  if(mp->audio_caps[1][ratei][enci]) ch |= MPG123_STEREO;
446  return ch;
447 }
static int enc2num(int encoding)
Definition: format.c:144
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:80
smooth NULL
Definition: ftsmooth.c:513
static int rate2num(mpg123_pars *mp, long r)
Definition: format.c:133
MPG123_EXPORT int mpg123_getpar ( mpg123_pars mp,
enum mpg123_parms  type,
long value,
double fvalue 
)

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

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

Definition at line 272 of file libmpg123.c.

Referenced by mpg123_getparam().

273 {
274  int ret = 0;
275 
276  if(mp == NULL) return MPG123_BAD_PARS;
277  switch(key)
278  {
279  case MPG123_VERBOSE:
280  if(val) *val = mp->verbose;
281  break;
282  case MPG123_FLAGS:
283  case MPG123_ADD_FLAGS:
284  if(val) *val = mp->flags;
285  break;
286  case MPG123_FORCE_RATE:
287  if(val)
288 #ifdef NO_NTOM
289  *val = 0;
290 #else
291  *val = mp->force_rate;
292 #endif
293  break;
294  case MPG123_DOWN_SAMPLE:
295  if(val) *val = mp->down_sample;
296  break;
297  case MPG123_RVA:
298  if(val) *val = mp->rva;
299  break;
300  case MPG123_DOWNSPEED:
301  if(val) *val = mp->halfspeed;
302  break;
303  case MPG123_UPSPEED:
304  if(val) *val = mp->doublespeed;
305  break;
306  case MPG123_ICY_INTERVAL:
307 #ifndef NO_ICY
308  if(val) *val = (long)mp->icy_interval;
309 #else
310  if(val) *val = 0;
311 #endif
312  break;
313  case MPG123_OUTSCALE:
314  if(fval) *fval = mp->outscale;
315  if(val) *val = (long)(mp->outscale*SHORT_SCALE);
316  break;
317  case MPG123_RESYNC_LIMIT:
318  if(val) *val = mp->resync_limit;
319  break;
320  case MPG123_INDEX_SIZE:
321  if(val)
322 #ifdef FRAME_INDEX
323  *val = mp->index_size;
324 #else
325  *val = 0; /* graceful fallback: no index is index of zero size */
326 #endif
327  break;
328  case MPG123_PREFRAMES:
329  *val = mp->preframes;
330  break;
331  case MPG123_FEEDPOOL:
332 #ifndef NO_FEEDER
333  *val = mp->feedpool;
334 #else
336 #endif
337  break;
338  case MPG123_FEEDBUFFER:
339 #ifndef NO_FEEDER
340  *val = mp->feedbuffer;
341 #else
343 #endif
344  break;
345  default:
346  ret = MPG123_BAD_PARAM;
347  }
348  return ret;
349 }
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:513
unsigned long
Definition: typeof.h:99
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

Parameters
errorerror code return address
Returns
new parameter handle

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:513
#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.

Parameters
mpparameter handle
typeparameter choice
valueinteger value
fvaluefloating point value
Returns
MPG123_OK on success

Definition at line 150 of file libmpg123.c.

Referenced by mpg123_param().

151 {
152  int ret = MPG123_OK;
153 
154  if(mp == NULL) return MPG123_BAD_PARS;
155  switch(key)
156  {
157  case MPG123_VERBOSE:
158  mp->verbose = val;
159  break;
160  case MPG123_FLAGS:
161 #ifndef GAPLESS
163 #endif
164  if(ret == MPG123_OK) mp->flags = val;
165  debug1("set flags to 0x%lx", (unsigned long) mp->flags);
166  break;
167  case MPG123_ADD_FLAGS:
168 #ifndef GAPLESS
169  /* Enabling of gapless mode doesn't work when it's not there, but disabling (below) is no problem. */
170  if(val & MPG123_GAPLESS) ret = MPG123_NO_GAPLESS;
171  else
172 #endif
173  mp->flags |= val;
174  debug1("set flags to 0x%lx", (unsigned long) mp->flags);
175  break;
176  case MPG123_REMOVE_FLAGS:
177  mp->flags &= ~val;
178  debug1("set flags to 0x%lx", (unsigned long) mp->flags);
179  break;
180  case MPG123_FORCE_RATE: /* should this trigger something? */
181 #ifdef NO_NTOM
182  if(val > 0)
183  ret = MPG123_BAD_RATE;
184 #else
185  if(val > 96000) ret = MPG123_BAD_RATE;
186  else mp->force_rate = val < 0 ? 0 : val; /* >0 means enable, 0 disable */
187 #endif
188  break;
189  case MPG123_DOWN_SAMPLE:
190 #ifdef NO_DOWNSAMPLE
191  if(val != 0) ret = MPG123_BAD_RATE;
192 #else
193  if(val < 0 || val > 2) ret = MPG123_BAD_RATE;
194  else mp->down_sample = (int)val;
195 #endif
196  break;
197  case MPG123_RVA:
199  else mp->rva = (int)val;
200  break;
201  case MPG123_DOWNSPEED:
202  mp->halfspeed = val < 0 ? 0 : val;
203  break;
204  case MPG123_UPSPEED:
205  mp->doublespeed = val < 0 ? 0 : val;
206  break;
207  case MPG123_ICY_INTERVAL:
208 #ifndef NO_ICY
209  mp->icy_interval = val > 0 ? val : 0;
210 #else
211  if(val > 0) ret = MPG123_BAD_PARAM;
212 #endif
213  break;
214  case MPG123_OUTSCALE:
215  /* Choose the value that is non-zero, if any.
216  Downscaling integers to 1.0 . */
217  mp->outscale = val == 0 ? fval : (double)val/SHORT_SCALE;
218  break;
219  case MPG123_TIMEOUT:
220 #ifdef TIMEOUT_READ
221  mp->timeout = val >= 0 ? val : 0;
222 #else
223  if(val > 0) ret = MPG123_NO_TIMEOUT;
224 #endif
225  break;
226  case MPG123_RESYNC_LIMIT:
227  mp->resync_limit = val;
228  break;
229  case MPG123_INDEX_SIZE:
230 #ifdef FRAME_INDEX
231  mp->index_size = val;
232 #else
233  ret = MPG123_NO_INDEX;
234 #endif
235  break;
236  case MPG123_PREFRAMES:
237  if(val >= 0) mp->preframes = val;
238  else ret = MPG123_BAD_VALUE;
239  break;
240  case MPG123_FEEDPOOL:
241 #ifndef NO_FEEDER
242  if(val >= 0) mp->feedpool = val;
243  else ret = MPG123_BAD_VALUE;
244 #else
246 #endif
247  break;
248  case MPG123_FEEDBUFFER:
249 #ifndef NO_FEEDER
250  if(val > 0) mp->feedbuffer = val;
251  else ret = MPG123_BAD_VALUE;
252 #else
254 #endif
255  break;
256  default:
257  ret = MPG123_BAD_PARAM;
258  }
259  return ret;
260 }
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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:79
smooth NULL
Definition: ftsmooth.c:513
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
#define debug1(s, a)
Definition: debug.h:52
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.

Parameters
mpparameter handle
decoderdecoder choice
errorerror code return address
Returns
mpg123 handle

Definition at line 61 of file libmpg123.c.

Referenced by mpg123_new().

62 {
63  mpg123_handle *fr = NULL;
64  int err = MPG123_OK;
65 
66  if(initialized) fr = (mpg123_handle*) malloc(sizeof(mpg123_handle));
67  else err = MPG123_NOT_INITIALIZED;
68  if(fr != NULL)
69  {
70  frame_init_par(fr, mp);
71  debug("cpu opt setting");
72  if(frame_cpu_opt(fr, decoder) != 1)
73  {
74  err = MPG123_BAD_DECODER;
75  frame_exit(fr);
76  free(fr);
77  fr = NULL;
78  }
79  }
80  if(fr != NULL)
81  {
82  fr->decoder_change = 1;
83  }
84  else if(err == MPG123_OK) err = MPG123_OUT_OF_MEM;
85 
86  if(error != NULL) *error = err;
87  return fr;
88 }
#define frame_init_par
Definition: intsym.h:169
static int initialized
Definition: libmpg123.c:20
#define free
Definition: debug_ros.c:5
#define frame_exit
Definition: intsym.h:175
int int int * err
Definition: fci.h:172
smooth NULL
Definition: ftsmooth.c:513
#define err(...)
#define debug(msg)
Definition: key_call.c:71
#define frame_cpu_opt
Definition: intsym.h:221
#define malloc
Definition: debug_ros.c:4