ReactOS 0.4.15-dev-7942-gd23573b
Collaboration diagram for mpg123 advanced parameter API:

Modules

 mpg123 low level I/O
 

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_fmt2 (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

◆ mpg123_pars

Opaque structure for the libmpg123 decoder parameters.

Definition at line 1538 of file mpg123.h.

Function Documentation

◆ mpg123_delete_pars()

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 167 of file frame.c.

168{
169 if(mp != NULL) free(mp);
170}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112

◆ mpg123_fmt()

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 524 of file format.c.

525{
526 return (rate == 0)
528 : mpg123_fmt2(mp, rate, channels, encodings);
529}
int attribute_align_arg mpg123_fmt2(mpg123_pars *mp, long rate, int channels, int encodings)
Definition: format.c:485
@ MPG123_BAD_RATE
Definition: mpg123.h:386
int rate
Definition: pcmconverter.c:97
int This channels
Definition: rdpsnd_libao.c:37

◆ mpg123_fmt2()

MPG123_EXPORT int mpg123_fmt2 ( 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). Special value 0 means all rates (reason for this variant of mpg123_fmt).
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 485 of file format.c.

486{
487 int ie, ic, ratei, r1, r2;
488 int ch[2] = {0, 1};
489 if(mp == NULL) return MPG123_BAD_PARS;
491
492 if(PVERB(mp,3)) fprintf(stderr, "Note: Want to enable format %li/%i for encodings 0x%x.\n", rate, channels, encodings);
493
494 if(!(channels & MPG123_STEREO)) ch[1] = 0; /* {0,0} */
495 else if(!(channels & MPG123_MONO)) ch[0] = 1; /* {1,1} */
496 if(rate)
497 {
498 r1 = rate2num(mp, rate);
499 r2 = r1+1;
500 }
501 else
502 {
503 r1 = 0;
504 r2 = MPG123_RATES+1; /* including forced rate */
505 }
506
507 if(r1 < 0) return MPG123_BAD_RATE;
508
509 /* now match the encodings */
510 for(ratei = r1; ratei < r2; ++ratei)
511 for(ic = 0; ic < 2; ++ic)
512 {
513 for(ie = 0; ie < MPG123_ENCODINGS; ++ie)
514 if(good_enc(my_encodings[ie]) && ((my_encodings[ie] & encodings) == my_encodings[ie]))
515 mp->audio_caps[ch[ic]][ratei][ie] = 1;
516
517 if(ch[0] == ch[1]) break; /* no need to do it again */
518 }
519
520 return MPG123_OK;
521}
@ MPG123_BAD_CHANNEL
Definition: mpg123.h:385
@ MPG123_BAD_PARS
Definition: mpg123.h:408
@ MPG123_OK
Definition: mpg123.h:383
@ MPG123_STEREO
Definition: mpg123.h:518
@ MPG123_MONO
Definition: mpg123.h:517
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38
#define MPG123_RATES
#define PVERB(mp, level)
#define MPG123_ENCODINGS
static int good_enc(const int enc)
Definition: format.c:109
static int rate2num(mpg123_pars *mp, long r)
Definition: format.c:138
static const int my_encodings[MPG123_ENCODINGS]
Definition: format.c:40
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73

Referenced by mpg123_fmt(), and mpg123_format2().

◆ mpg123_fmt_all()

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 449 of file format.c.

450{
451 size_t rate, ch, enc;
452 if(mp == NULL) return MPG123_BAD_PARS;
453
454 if(PVERB(mp,3)) fprintf(stderr, "Note: Enabling all formats.\n");
455
456 for(ch=0; ch < NUM_CHANNELS; ++ch)
457 for(rate=0; rate < MPG123_RATES+1; ++rate)
458 for(enc=0; enc < MPG123_ENCODINGS; ++enc)
459 mp->audio_caps[ch][rate][enc] = good_enc(my_encodings[enc]) ? 1 : 0;
460
461 return MPG123_OK;
462}
#define NUM_CHANNELS
Definition: frame.h:72

Referenced by frame_default_pars(), and mpg123_format_all().

◆ mpg123_fmt_none()

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 428 of file format.c.

429{
430 if(mp == NULL) return MPG123_BAD_PARS;
431
432 if(PVERB(mp,3)) fprintf(stderr, "Note: Disabling all formats.\n");
433
434 memset(mp->audio_caps,0,sizeof(mp->audio_caps));
435 return MPG123_OK;
436}
#define memset(x, y, z)
Definition: compat.h:39

Referenced by mpg123_format_none().

◆ mpg123_fmt_support()

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 537 of file format.c.

538{
539 int ch = 0;
540 int ratei, enci;
541 ratei = rate2num(mp, rate);
542 enci = enc2num(encoding);
543 if(mp == NULL || ratei < 0 || enci < 0) return 0;
544 if(mp->audio_caps[0][ratei][enci]) ch |= MPG123_MONO;
545 if(mp->audio_caps[1][ratei][enci]) ch |= MPG123_STEREO;
546 return ch;
547}
static int enc2num(int encoding)
Definition: format.c:149
static char * encoding
Definition: xmllint.c:155

Referenced by mpg123_format_support().

◆ mpg123_getpar()

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 278 of file libmpg123.c.

279{
280 int ret = 0;
281
282 if(mp == NULL) return MPG123_BAD_PARS;
283 switch(key)
284 {
285 case MPG123_VERBOSE:
286 if(val) *val = mp->verbose;
287 break;
288 case MPG123_FLAGS:
289 case MPG123_ADD_FLAGS:
290 if(val) *val = mp->flags;
291 break;
293 if(val)
294#ifdef NO_NTOM
295 *val = 0;
296#else
297 *val = mp->force_rate;
298#endif
299 break;
301 if(val) *val = mp->down_sample;
302 break;
303 case MPG123_RVA:
304 if(val) *val = mp->rva;
305 break;
306 case MPG123_DOWNSPEED:
307 if(val) *val = mp->halfspeed;
308 break;
309 case MPG123_UPSPEED:
310 if(val) *val = mp->doublespeed;
311 break;
313#ifndef NO_ICY
314 if(val) *val = (long)mp->icy_interval;
315#else
316 if(val) *val = 0;
317#endif
318 break;
319 case MPG123_OUTSCALE:
320 if(fval) *fval = mp->outscale;
321 if(val) *val = (long)(mp->outscale*SHORT_SCALE);
322 break;
324 if(val) *val = mp->resync_limit;
325 break;
327 if(val)
328#ifdef FRAME_INDEX
329 *val = mp->index_size;
330#else
331 *val = 0; /* graceful fallback: no index is index of zero size */
332#endif
333 break;
334 case MPG123_PREFRAMES:
335 *val = mp->preframes;
336 break;
337 case MPG123_FEEDPOOL:
338#ifndef NO_FEEDER
339 *val = mp->feedpool;
340#else
342#endif
343 break;
345#ifndef NO_FEEDER
346 *val = mp->feedbuffer;
347#else
349#endif
350 break;
353 break;
354 default:
356 }
357 return ret;
358}
GLuint GLfloat * val
Definition: glext.h:7180
@ MPG123_BAD_PARAM
Definition: mpg123.h:388
@ MPG123_MISSING_FEATURE
Definition: mpg123.h:421
@ MPG123_VERBOSE
Definition: mpg123.h:183
@ MPG123_UPSPEED
Definition: mpg123.h:190
@ MPG123_DOWNSPEED
Definition: mpg123.h:189
@ MPG123_DOWN_SAMPLE
Definition: mpg123.h:187
@ MPG123_RESYNC_LIMIT
Definition: mpg123.h:198
@ MPG123_INDEX_SIZE
Definition: mpg123.h:199
@ MPG123_ADD_FLAGS
Definition: mpg123.h:185
@ MPG123_OUTSCALE
Definition: mpg123.h:195
@ MPG123_FREEFORMAT_SIZE
Definition: mpg123.h:203
@ MPG123_ICY_INTERVAL
Definition: mpg123.h:193
@ MPG123_FEEDPOOL
Definition: mpg123.h:201
@ MPG123_FEEDBUFFER
Definition: mpg123.h:202
@ MPG123_FLAGS
Definition: mpg123.h:184
@ MPG123_FORCE_RATE
Definition: mpg123.h:186
@ MPG123_PREFRAMES
Definition: mpg123.h:200
@ MPG123_RVA
Definition: mpg123.h:188
#define SHORT_SCALE
#define long
Definition: qsort.c:33
Definition: copy.c:22
long index_size
Definition: frame.h:81
long doublespeed
Definition: frame.h:70
long halfspeed
Definition: frame.h:69
long force_rate
Definition: frame.h:65
long preframes
Definition: frame.h:82
long freeformat_framesize
Definition: frame.h:87
long icy_interval
Definition: frame.h:77
double outscale
Definition: frame.h:79
long resync_limit
Definition: frame.h:80
long feedbuffer
Definition: frame.h:85
int ret

Referenced by mpg123_getparam().

◆ mpg123_new_pars()

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 159 of file frame.c.

160{
161 mpg123_pars *mp = malloc(sizeof(struct mpg123_pars_struct));
162 if(mp != NULL){ frame_default_pars(mp); if(error != NULL) *error = MPG123_OK; }
163 else if(error != NULL) *error = MPG123_OUT_OF_MEM;
164 return mp;
165}
#define malloc
Definition: debug_ros.c:4
@ MPG123_OUT_OF_MEM
Definition: mpg123.h:390
#define error(str)
Definition: mkdosfs.c:1605
static void frame_default_pars(mpg123_pars *mp)
Definition: frame.c:36

◆ mpg123_par()

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 152 of file libmpg123.c.

153{
154 int ret = MPG123_OK;
155
156 if(mp == NULL) return MPG123_BAD_PARS;
157 switch(key)
158 {
159 case MPG123_VERBOSE:
160 mp->verbose = val;
161 break;
162 case MPG123_FLAGS:
163#ifndef GAPLESS
165#endif
166 if(ret == MPG123_OK) mp->flags = val;
167 debug1("set flags to 0x%lx", (unsigned long) mp->flags);
168 break;
169 case MPG123_ADD_FLAGS:
170#ifndef GAPLESS
171 /* Enabling of gapless mode doesn't work when it's not there, but disabling (below) is no problem. */
173 else
174#endif
175 mp->flags |= val;
176 debug1("set flags to 0x%lx", (unsigned long) mp->flags);
177 break;
179 mp->flags &= ~val;
180 debug1("set flags to 0x%lx", (unsigned long) mp->flags);
181 break;
182 case MPG123_FORCE_RATE: /* should this trigger something? */
183#ifdef NO_NTOM
184 if(val > 0)
186#else
187 if(val > 96000) ret = MPG123_BAD_RATE;
188 else mp->force_rate = val < 0 ? 0 : val; /* >0 means enable, 0 disable */
189#endif
190 break;
192#ifdef NO_DOWNSAMPLE
193 if(val != 0) ret = MPG123_BAD_RATE;
194#else
195 if(val < 0 || val > 2) ret = MPG123_BAD_RATE;
196 else mp->down_sample = (int)val;
197#endif
198 break;
199 case MPG123_RVA:
200 if(val < 0 || val > MPG123_RVA_MAX) ret = MPG123_BAD_RVA;
201 else mp->rva = (int)val;
202 break;
203 case MPG123_DOWNSPEED:
204 mp->halfspeed = val < 0 ? 0 : val;
205 break;
206 case MPG123_UPSPEED:
207 mp->doublespeed = val < 0 ? 0 : val;
208 break;
210#ifndef NO_ICY
211 mp->icy_interval = val > 0 ? val : 0;
212#else
213 if(val > 0) ret = MPG123_BAD_PARAM;
214#endif
215 break;
216 case MPG123_OUTSCALE:
217 /* Choose the value that is non-zero, if any.
218 Downscaling integers to 1.0 . */
219 mp->outscale = val == 0 ? fval : (double)val/SHORT_SCALE;
220 break;
221 case MPG123_TIMEOUT:
222#ifdef TIMEOUT_READ
223 mp->timeout = val >= 0 ? val : 0;
224#else
225 if(val > 0) ret = MPG123_NO_TIMEOUT;
226#endif
227 break;
229 mp->resync_limit = val;
230 break;
232#ifdef FRAME_INDEX
233 mp->index_size = val;
234#else
235 if(val) // It is only an eror if you want to enable the index.
237#endif
238 break;
239 case MPG123_PREFRAMES:
240 if(val >= 0) mp->preframes = val;
241 else ret = MPG123_BAD_VALUE;
242 break;
243 case MPG123_FEEDPOOL:
244#ifndef NO_FEEDER
245 if(val >= 0) mp->feedpool = val;
246 else ret = MPG123_BAD_VALUE;
247#else
249#endif
250 break;
252#ifndef NO_FEEDER
253 if(val > 0) mp->feedbuffer = val;
254 else ret = MPG123_BAD_VALUE;
255#else
257#endif
258 break;
261 break;
262 default:
264 }
265 return ret;
266}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
@ MPG123_NO_TIMEOUT
Definition: mpg123.h:404
@ MPG123_BAD_RVA
Definition: mpg123.h:395
@ MPG123_NO_INDEX
Definition: mpg123.h:418
@ MPG123_NO_GAPLESS
Definition: mpg123.h:396
@ MPG123_BAD_VALUE
Definition: mpg123.h:422
@ MPG123_GAPLESS
Definition: mpg123.h:220
@ MPG123_TIMEOUT
Definition: mpg123.h:196
@ MPG123_REMOVE_FLAGS
Definition: mpg123.h:197
@ MPG123_RVA_MAX
Definition: mpg123.h:277
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define debug1(s, a)
Definition: debug.h:61

Referenced by mpg123_param().

◆ mpg123_parnew()

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 63 of file libmpg123.c.

64{
65 mpg123_handle *fr = NULL;
66 int err = MPG123_OK;
67
68 if(initialized) fr = (mpg123_handle*) malloc(sizeof(mpg123_handle));
70 if(fr != NULL)
71 {
72 frame_init_par(fr, mp);
73 debug("cpu opt setting");
74 if(frame_cpu_opt(fr, decoder) != 1)
75 {
77 frame_exit(fr);
78 free(fr);
79 fr = NULL;
80 }
81 }
82 if(fr != NULL)
83 {
84 fr->decoder_change = 1;
85 }
86 else if(err == MPG123_OK) err = MPG123_OUT_OF_MEM;
87
88 if(error != NULL) *error = err;
89 return fr;
90}
@ MPG123_NOT_INITIALIZED
Definition: mpg123.h:391
@ MPG123_BAD_DECODER
Definition: mpg123.h:392
#define frame_cpu_opt
Definition: intsym.h:231
#define frame_exit
Definition: intsym.h:186
#define frame_init_par
Definition: intsym.h:180
#define debug(msg)
Definition: key_call.c:71
static int initialized
Definition: libmpg123.c:21
#define err(...)

Referenced by mpg123_new().