To support this change, turn on lots more compiler warnings, and fix all the warnings generated.
Showing the changes to src/mp3.c (1 of 93 files). Show all
Unified · Split
| @@ -14,13 +14,13 @@ · 13 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | #include <string.h> |
| 16 | 16 | |
| 17 | −#if defined(HAVE_LIBMAD) || defined(HAVE_LAME) | |
| 17 | +#if defined(HAVE_LIBMAD) || defined(HAVE_LIBMP3LAME) | |
| 18 | 18 | |
| 19 | 19 | #ifdef HAVE_LIBMAD |
| 20 | 20 | #include <mad.h> |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | −#ifdef HAVE_LAME | |
| 23 | +#ifdef HAVE_LIBMP3LAME | |
| 24 | 24 | #include <lame/lame.h> |
| 25 | 25 | #include <math.h> |
| 26 | 26 | #endif |
| @@ -38,9 +38,9 @@ struct mp3priv { · 11 unmodified lines | ||
| 38 | 38 | st_ssize_t cursamp; |
| 39 | 39 | st_size_t FrameCount; |
| 40 | 40 | #endif /*HAVE_LIBMAD*/ |
| 41 | −#ifdef HAVE_LAME | |
| 41 | +#ifdef HAVE_LIBMP3LAME | |
| 42 | 42 | lame_global_flags *gfp; |
| 43 | −#endif /*HAVE_LAME*/ | |
| 43 | +#endif /*HAVE_LIBMP3LAME*/ | |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | #ifdef HAVE_LIBMAD |
| @@ -159,7 +159,7 @@ static int st_mp3_inputtag(ft_t ft) · 112 unmodified lines | ||
| 159 | 159 | return rc; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | −int st_mp3startread(ft_t ft) | |
| 162 | +static int st_mp3startread(ft_t ft) | |
| 163 | 163 | { |
| 164 | 164 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 165 | 165 | size_t ReadSize; |
| @@ -279,12 +279,12 @@ error: · 113 unmodified lines | ||
| 279 | 279 | * Place in buf[]. |
| 280 | 280 | * Return number of samples read. |
| 281 | 281 | */ |
| 282 | −st_ssize_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len) | |
| 282 | +static st_size_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len) | |
| 283 | 283 | { |
| 284 | 284 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 285 | − st_ssize_t donow,i,done=0; | |
| 285 | + st_size_t donow,i,done=0; | |
| 286 | 286 | mad_fixed_t sample; |
| 287 | − int chan; | |
| 287 | + size_t chan; | |
| 288 | 288 | |
| 289 | 289 | do { |
| 290 | 290 | donow=min(len,(p->Synth->pcm.length - p->cursamp)*ft->info.channels); |
| @@ -342,7 +342,7 @@ st_ssize_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len) · 51 unmodified lines | ||
| 342 | 342 | return done; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | −int st_mp3stopread(ft_t ft) | |
| 345 | +static int st_mp3stopread(ft_t ft) | |
| 346 | 346 | { |
| 347 | 347 | struct mp3priv *p=(struct mp3priv*) ft->priv; |
| 348 | 348 | |
| @@ -359,7 +359,7 @@ int st_mp3stopread(ft_t ft) · 10 unmodified lines | ||
| 359 | 359 | return ST_SUCCESS; |
| 360 | 360 | } |
| 361 | 361 | #else /*HAVE_LIBMAD*/ |
| 362 | −int st_mp3startread(ft_t ft) | |
| 362 | +static int st_mp3startread(ft_t ft) | |
| 363 | 363 | { |
| 364 | 364 | st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support"); |
| 365 | 365 | return ST_EOF; |
| @@ -378,17 +378,18 @@ int st_mp3stopread(ft_t ft) · 12 unmodified lines | ||
| 378 | 378 | } |
| 379 | 379 | #endif /*HAVE_LIBMAD*/ |
| 380 | 380 | |
| 381 | −#ifdef HAVE_LAME | |
| 382 | −void null_error_func(const char* string, va_list va){ | |
| 381 | +#ifdef HAVE_LIBMP3LAME | |
| 382 | +static void null_error_func(const char* string UNUSED, va_list va UNUSED) | |
| 383 | +{ | |
| 383 | 384 | return; |
| 384 | 385 | } |
| 385 | 386 | |
| 386 | −int st_mp3startwrite(ft_t ft) | |
| 387 | +static int st_mp3startwrite(ft_t ft) | |
| 387 | 388 | { |
| 388 | 389 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 389 | 390 | |
| 390 | − if (ft->info.encoding != ST_ENCODING_MP3){ | |
| 391 | − if(ft->info.encoding != -1) | |
| 391 | + if (ft->info.encoding != ST_ENCODING_MP3) { | |
| 392 | + if(ft->info.encoding != ST_ENCODING_UNKNOWN) | |
| 392 | 393 | st_report("Encoding forced to MP3"); |
| 393 | 394 | ft->info.encoding = ST_ENCODING_MP3; |
| 394 | 395 | } |
| @@ -399,7 +400,7 @@ int st_mp3startwrite(ft_t ft) · 4 unmodified lines | ||
| 399 | 400 | return(ST_EOF); |
| 400 | 401 | } |
| 401 | 402 | |
| 402 | − if (ft->info.channels != -1){ | |
| 403 | + if (ft->info.channels != ST_ENCODING_UNKNOWN) { | |
| 403 | 404 | if ( (lame_set_num_channels(p->gfp,ft->info.channels)) < 0) { |
| 404 | 405 | st_fail_errno(ft,ST_EOF,"Unsupported number of channels"); |
| 405 | 406 | return(ST_EOF); |
| @@ -431,16 +432,16 @@ int st_mp3startwrite(ft_t ft) · 25 unmodified lines | ||
| 431 | 432 | return(ST_SUCCESS); |
| 432 | 433 | } |
| 433 | 434 | |
| 434 | −st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp) | |
| 435 | +static st_size_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp) | |
| 435 | 436 | { |
| 436 | 437 | struct mp3priv *p = (struct mp3priv *)ft->priv; |
| 437 | 438 | char *mp3buffer; |
| 438 | − int mp3buffer_size; | |
| 439 | + st_size_t mp3buffer_size; | |
| 439 | 440 | short signed int *buffer_l, *buffer_r = NULL; |
| 440 | 441 | int nsamples = samp/ft->info.channels; |
| 441 | 442 | int i,j; |
| 442 | 443 | st_ssize_t done = 0; |
| 443 | − int written; | |
| 444 | + st_size_t written; | |
| 444 | 445 | |
| 445 | 446 | /* NOTE: This logic assumes that "short int" is 16-bits |
| 446 | 447 | * on all platforms. It happens to be for all that I know |
| @@ -504,7 +505,7 @@ st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp) · 57 unmodified lines | ||
| 504 | 505 | |
| 505 | 506 | if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r, |
| 506 | 507 | nsamples, (unsigned char *)mp3buffer, |
| 507 | − mp3buffer_size)) < 0){ | |
| 508 | + mp3buffer_size)) < mp3buffer_size){ | |
| 508 | 509 | st_fail_errno(ft,ST_EOF,"Encoding failed"); |
| 509 | 510 | goto end; |
| 510 | 511 | } |
| @@ -528,7 +529,7 @@ end4: · 17 unmodified lines | ||
| 528 | 529 | return done; |
| 529 | 530 | } |
| 530 | 531 | |
| 531 | −int st_mp3stopwrite(ft_t ft) | |
| 532 | +static int st_mp3stopwrite(ft_t ft) | |
| 532 | 533 | { |
| 533 | 534 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 534 | 535 | char mp3buffer[7200]; |
| @@ -537,7 +538,7 @@ int st_mp3stopwrite(ft_t ft) · 2 unmodified lines | ||
| 537 | 538 | if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){ |
| 538 | 539 | st_fail_errno(ft,ST_EOF,"Encoding failed"); |
| 539 | 540 | } |
| 540 | − else if (st_writebuf(ft, mp3buffer, 1, written) < written){ | |
| 541 | + else if ((int)st_writebuf(ft, mp3buffer, 1, written) < written){ | |
| 541 | 542 | st_fail_errno(ft,ST_EOF,"File write failed"); |
| 542 | 543 | } |
| 543 | 544 | |
| @@ -545,25 +546,25 @@ int st_mp3stopwrite(ft_t ft) · 1 unmodified line | ||
| 545 | 546 | return ST_SUCCESS; |
| 546 | 547 | } |
| 547 | 548 | |
| 548 | −#else /* HAVE_LAME */ | |
| 549 | −int st_mp3startwrite(ft_t ft) | |
| 549 | +#else /* HAVE_LIBMP3LAME */ | |
| 550 | +static int st_mp3startwrite(ft_t ft UNUSED) | |
| 550 | 551 | { |
| 551 | − st_fail_errno(ft,ST_EOF,"Sorry, no MP3 encoding support"); | |
| 552 | + st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support"); | |
| 552 | 553 | return ST_EOF; |
| 553 | 554 | } |
| 554 | 555 | |
| 555 | −st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp) | |
| 556 | +static st_size_t st_mp3write(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t samp UNUSED) | |
| 556 | 557 | { |
| 557 | − st_fail_errno(ft,ST_EOF,"Sorry, no MP3 encoding support"); | |
| 558 | − return ST_EOF; | |
| 558 | + st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support"); | |
| 559 | + return 0; | |
| 559 | 560 | } |
| 560 | 561 | |
| 561 | −int st_mp3stopwrite(ft_t ft) | |
| 562 | +static int st_mp3stopwrite(ft_t ft) | |
| 562 | 563 | { |
| 563 | − st_fail_errno(ft,ST_EOF,"Sorry, no MP3 encoding support"); | |
| 564 | + st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support"); | |
| 564 | 565 | return ST_EOF; |
| 565 | 566 | } |
| 566 | −#endif /* HAVE_LAME */ | |
| 567 | +#endif /* HAVE_LIBMP3LAME */ | |
| 567 | 568 | |
| 568 | 569 | /* MP3 */ |
| 569 | 570 | static const char *mp3names[] = { |