History

Fix read and write return types: now st_size_t, like the size inputs.

To support this change, turn on lots more compiler warnings, and fix all the warnings generated.

rrt committed 19 years ago

Commit 4d743c41 parent ce1f8f393 files · +875 −1236Browse files

Showing the changes to src/mp3.c (1 of 93 files). Show all

Unified · Split

src/mp3.c+32−31
@@ -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_LIBMAD19#ifdef HAVE_LIBMAD
20#include <mad.h>20#include <mad.h>
21#endif21#endif
22 22
23#ifdef HAVE_LAME23#ifdef HAVE_LIBMP3LAME
24#include <lame/lame.h>24#include <lame/lame.h>
25#include <math.h>25#include <math.h>
26#endif26#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_LAME41#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_LIBMAD46#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
162int st_mp3startread(ft_t ft) 162static 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 */
282st_ssize_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len)282static 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
345int st_mp3stopread(ft_t ft)345static 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*/
362int st_mp3startread(ft_t ft)362static 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_LAME381#ifdef HAVE_LIBMP3LAME
382void null_error_func(const char* string, va_list va){382static void null_error_func(const char* string UNUSED, va_list va UNUSED)
383{
383 return;384 return;
384}385}
385 386
386int st_mp3startwrite(ft_t ft)387static 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
434st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp)435static 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-bits446 /* NOTE: This logic assumes that "short int" is 16-bits
446 * on all platforms. It happens to be for all that I know447 * 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
531int st_mp3stopwrite(ft_t ft)532static 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 */
549int st_mp3startwrite(ft_t ft)550static 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
555st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp)556static 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
561int st_mp3stopwrite(ft_t ft)562static 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 */
569static const char *mp3names[] = {570static const char *mp3names[] = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t