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 | #include <string.h> | 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 | #ifdef HAVE_LIBMAD | 19 | #ifdef HAVE_LIBMAD |
| 20 | #include <mad.h> | 20 | #include <mad.h> |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | #ifdef HAVE_LAME | 23 | #ifdef HAVE_LIBMP3LAME |
| 24 | #include <lame/lame.h> | 24 | #include <lame/lame.h> |
| 25 | #include <math.h> | 25 | #include <math.h> |
| 26 | #endif | 26 | #endif |
| @@ -38,9 +38,9 @@ struct mp3priv { · 11 unmodified lines | |||
| 38 | st_ssize_t cursamp; | 38 | st_ssize_t cursamp; |
| 39 | st_size_t FrameCount; | 39 | st_size_t FrameCount; |
| 40 | #endif /*HAVE_LIBMAD*/ | 40 | #endif /*HAVE_LIBMAD*/ |
| 41 | #ifdef HAVE_LAME | 41 | #ifdef HAVE_LIBMP3LAME |
| 42 | lame_global_flags *gfp; | 42 | lame_global_flags *gfp; |
| 43 | #endif /*HAVE_LAME*/ | 43 | #endif /*HAVE_LIBMP3LAME*/ |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | #ifdef HAVE_LIBMAD | 46 | #ifdef HAVE_LIBMAD |
| @@ -159,7 +159,7 @@ static int st_mp3_inputtag(ft_t ft) · 112 unmodified lines | |||
| 159 | return rc; | 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 | struct mp3priv *p = (struct mp3priv *) ft->priv; | 164 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 165 | size_t ReadSize; | 165 | size_t ReadSize; |
| @@ -279,12 +279,12 @@ error: · 113 unmodified lines | |||
| 279 | * Place in buf[]. | 279 | * Place in buf[]. |
| 280 | * Return number of samples read. | 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 | struct mp3priv *p = (struct mp3priv *) ft->priv; | 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 | mad_fixed_t sample; | 286 | mad_fixed_t sample; |
| 287 | int chan; | 287 | size_t chan; |
| 288 | 288 | ||
| 289 | do { | 289 | do { |
| 290 | donow=min(len,(p->Synth->pcm.length - p->cursamp)*ft->info.channels); | 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 | return done; | 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 | struct mp3priv *p=(struct mp3priv*) ft->priv; | 347 | struct mp3priv *p=(struct mp3priv*) ft->priv; |
| 348 | 348 | ||
| @@ -359,7 +359,7 @@ int st_mp3stopread(ft_t ft) · 10 unmodified lines | |||
| 359 | return ST_SUCCESS; | 359 | return ST_SUCCESS; |
| 360 | } | 360 | } |
| 361 | #else /*HAVE_LIBMAD*/ | 361 | #else /*HAVE_LIBMAD*/ |
| 362 | int st_mp3startread(ft_t ft) | 362 | static int st_mp3startread(ft_t ft) |
| 363 | { | 363 | { |
| 364 | st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support"); | 364 | st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support"); |
| 365 | return ST_EOF; | 365 | return ST_EOF; |
| @@ -378,17 +378,18 @@ int st_mp3stopread(ft_t ft) · 12 unmodified lines | |||
| 378 | } | 378 | } |
| 379 | #endif /*HAVE_LIBMAD*/ | 379 | #endif /*HAVE_LIBMAD*/ |
| 380 | 380 | ||
| 381 | #ifdef HAVE_LAME | 381 | #ifdef HAVE_LIBMP3LAME |
| 382 | void null_error_func(const char* string, va_list va){ | 382 | static void null_error_func(const char* string UNUSED, va_list va UNUSED) |
| 383 | { | ||
| 383 | return; | 384 | return; |
| 384 | } | 385 | } |
| 385 | 386 | ||
| 386 | int st_mp3startwrite(ft_t ft) | 387 | static int st_mp3startwrite(ft_t ft) |
| 387 | { | 388 | { |
| 388 | struct mp3priv *p = (struct mp3priv *) ft->priv; | 389 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 389 | 390 | ||
| 390 | if (ft->info.encoding != ST_ENCODING_MP3){ | 391 | if (ft->info.encoding != ST_ENCODING_MP3) { |
| 391 | if(ft->info.encoding != -1) | 392 | if(ft->info.encoding != ST_ENCODING_UNKNOWN) |
| 392 | st_report("Encoding forced to MP3"); | 393 | st_report("Encoding forced to MP3"); |
| 393 | ft->info.encoding = ST_ENCODING_MP3; | 394 | ft->info.encoding = ST_ENCODING_MP3; |
| 394 | } | 395 | } |
| @@ -399,7 +400,7 @@ int st_mp3startwrite(ft_t ft) · 4 unmodified lines | |||
| 399 | return(ST_EOF); | 400 | return(ST_EOF); |
| 400 | } | 401 | } |
| 401 | 402 | ||
| 402 | if (ft->info.channels != -1){ | 403 | if (ft->info.channels != ST_ENCODING_UNKNOWN) { |
| 403 | if ( (lame_set_num_channels(p->gfp,ft->info.channels)) < 0) { | 404 | if ( (lame_set_num_channels(p->gfp,ft->info.channels)) < 0) { |
| 404 | st_fail_errno(ft,ST_EOF,"Unsupported number of channels"); | 405 | st_fail_errno(ft,ST_EOF,"Unsupported number of channels"); |
| 405 | return(ST_EOF); | 406 | return(ST_EOF); |
| @@ -431,16 +432,16 @@ int st_mp3startwrite(ft_t ft) · 25 unmodified lines | |||
| 431 | return(ST_SUCCESS); | 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 | struct mp3priv *p = (struct mp3priv *)ft->priv; | 437 | struct mp3priv *p = (struct mp3priv *)ft->priv; |
| 437 | char *mp3buffer; | 438 | char *mp3buffer; |
| 438 | int mp3buffer_size; | 439 | st_size_t mp3buffer_size; |
| 439 | short signed int *buffer_l, *buffer_r = NULL; | 440 | short signed int *buffer_l, *buffer_r = NULL; |
| 440 | int nsamples = samp/ft->info.channels; | 441 | int nsamples = samp/ft->info.channels; |
| 441 | int i,j; | 442 | int i,j; |
| 442 | st_ssize_t done = 0; | 443 | st_ssize_t done = 0; |
| 443 | int written; | 444 | st_size_t written; |
| 444 | 445 | ||
| 445 | /* NOTE: This logic assumes that "short int" is 16-bits | 446 | /* NOTE: This logic assumes that "short int" is 16-bits |
| 446 | * on all platforms. It happens to be for all that I know | 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 | if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r, | 506 | if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r, |
| 506 | nsamples, (unsigned char *)mp3buffer, | 507 | nsamples, (unsigned char *)mp3buffer, |
| 507 | mp3buffer_size)) < 0){ | 508 | mp3buffer_size)) < mp3buffer_size){ |
| 508 | st_fail_errno(ft,ST_EOF,"Encoding failed"); | 509 | st_fail_errno(ft,ST_EOF,"Encoding failed"); |
| 509 | goto end; | 510 | goto end; |
| 510 | } | 511 | } |
| @@ -528,7 +529,7 @@ end4: · 17 unmodified lines | |||
| 528 | return done; | 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 | struct mp3priv *p = (struct mp3priv *) ft->priv; | 534 | struct mp3priv *p = (struct mp3priv *) ft->priv; |
| 534 | char mp3buffer[7200]; | 535 | char mp3buffer[7200]; |
| @@ -537,7 +538,7 @@ int st_mp3stopwrite(ft_t ft) · 2 unmodified lines | |||
| 537 | if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){ | 538 | if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){ |
| 538 | st_fail_errno(ft,ST_EOF,"Encoding failed"); | 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 | st_fail_errno(ft,ST_EOF,"File write failed"); | 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 | return ST_SUCCESS; | 546 | return ST_SUCCESS; |
| 546 | } | 547 | } |
| 547 | 548 | ||
| 548 | #else /* HAVE_LAME */ | 549 | #else /* HAVE_LIBMP3LAME */ |
| 549 | int st_mp3startwrite(ft_t ft) | 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 | return ST_EOF; | 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 | st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support"); |
| 558 | return ST_EOF; | 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 | return ST_EOF; | 565 | return ST_EOF; |
| 565 | } | 566 | } |
| 566 | #endif /* HAVE_LAME */ | 567 | #endif /* HAVE_LIBMP3LAME */ |
| 567 | 568 | ||
| 568 | /* MP3 */ | 569 | /* MP3 */ |
| 569 | static const char *mp3names[] = { | 570 | static const char *mp3names[] = { |