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
1414
1515 #include <string.h>
1616
17−#if defined(HAVE_LIBMAD) || defined(HAVE_LAME)
17+#if defined(HAVE_LIBMAD) || defined(HAVE_LIBMP3LAME)
1818
1919 #ifdef HAVE_LIBMAD
2020 #include <mad.h>
2121 #endif
2222
23−#ifdef HAVE_LAME
23+#ifdef HAVE_LIBMP3LAME
2424 #include <lame/lame.h>
2525 #include <math.h>
2626 #endif
@@ -38,9 +38,9 @@ struct mp3priv { · 11 unmodified lines
3838 st_ssize_t cursamp;
3939 st_size_t FrameCount;
4040 #endif /*HAVE_LIBMAD*/
41−#ifdef HAVE_LAME
41+#ifdef HAVE_LIBMP3LAME
4242 lame_global_flags *gfp;
43−#endif /*HAVE_LAME*/
43+#endif /*HAVE_LIBMP3LAME*/
4444 };
4545
4646 #ifdef HAVE_LIBMAD
@@ -159,7 +159,7 @@ static int st_mp3_inputtag(ft_t ft) · 112 unmodified lines
159159 return rc;
160160 }
161161
162−int st_mp3startread(ft_t ft)
162+static int st_mp3startread(ft_t ft)
163163 {
164164 struct mp3priv *p = (struct mp3priv *) ft->priv;
165165 size_t ReadSize;
@@ -279,12 +279,12 @@ error: · 113 unmodified lines
279279 * Place in buf[].
280280 * Return number of samples read.
281281 */
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)
283283 {
284284 struct mp3priv *p = (struct mp3priv *) ft->priv;
285− st_ssize_t donow,i,done=0;
285+ st_size_t donow,i,done=0;
286286 mad_fixed_t sample;
287− int chan;
287+ size_t chan;
288288
289289 do {
290290 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
342342 return done;
343343 }
344344
345−int st_mp3stopread(ft_t ft)
345+static int st_mp3stopread(ft_t ft)
346346 {
347347 struct mp3priv *p=(struct mp3priv*) ft->priv;
348348
@@ -359,7 +359,7 @@ int st_mp3stopread(ft_t ft) · 10 unmodified lines
359359 return ST_SUCCESS;
360360 }
361361 #else /*HAVE_LIBMAD*/
362−int st_mp3startread(ft_t ft)
362+static int st_mp3startread(ft_t ft)
363363 {
364364 st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support");
365365 return ST_EOF;
@@ -378,17 +378,18 @@ int st_mp3stopread(ft_t ft) · 12 unmodified lines
378378 }
379379 #endif /*HAVE_LIBMAD*/
380380
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+{
383384 return;
384385 }
385386
386−int st_mp3startwrite(ft_t ft)
387+static int st_mp3startwrite(ft_t ft)
387388 {
388389 struct mp3priv *p = (struct mp3priv *) ft->priv;
389390
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)
392393 st_report("Encoding forced to MP3");
393394 ft->info.encoding = ST_ENCODING_MP3;
394395 }
@@ -399,7 +400,7 @@ int st_mp3startwrite(ft_t ft) · 4 unmodified lines
399400 return(ST_EOF);
400401 }
401402
402− if (ft->info.channels != -1){
403+ if (ft->info.channels != ST_ENCODING_UNKNOWN) {
403404 if ( (lame_set_num_channels(p->gfp,ft->info.channels)) < 0) {
404405 st_fail_errno(ft,ST_EOF,"Unsupported number of channels");
405406 return(ST_EOF);
@@ -431,16 +432,16 @@ int st_mp3startwrite(ft_t ft) · 25 unmodified lines
431432 return(ST_SUCCESS);
432433 }
433434
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)
435436 {
436437 struct mp3priv *p = (struct mp3priv *)ft->priv;
437438 char *mp3buffer;
438− int mp3buffer_size;
439+ st_size_t mp3buffer_size;
439440 short signed int *buffer_l, *buffer_r = NULL;
440441 int nsamples = samp/ft->info.channels;
441442 int i,j;
442443 st_ssize_t done = 0;
443− int written;
444+ st_size_t written;
444445
445446 /* NOTE: This logic assumes that "short int" is 16-bits
446447 * 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
504505
505506 if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r,
506507 nsamples, (unsigned char *)mp3buffer,
507− mp3buffer_size)) < 0){
508+ mp3buffer_size)) < mp3buffer_size){
508509 st_fail_errno(ft,ST_EOF,"Encoding failed");
509510 goto end;
510511 }
@@ -528,7 +529,7 @@ end4: · 17 unmodified lines
528529 return done;
529530 }
530531
531−int st_mp3stopwrite(ft_t ft)
532+static int st_mp3stopwrite(ft_t ft)
532533 {
533534 struct mp3priv *p = (struct mp3priv *) ft->priv;
534535 char mp3buffer[7200];
@@ -537,7 +538,7 @@ int st_mp3stopwrite(ft_t ft) · 2 unmodified lines
537538 if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){
538539 st_fail_errno(ft,ST_EOF,"Encoding failed");
539540 }
540− else if (st_writebuf(ft, mp3buffer, 1, written) < written){
541+ else if ((int)st_writebuf(ft, mp3buffer, 1, written) < written){
541542 st_fail_errno(ft,ST_EOF,"File write failed");
542543 }
543544
@@ -545,25 +546,25 @@ int st_mp3stopwrite(ft_t ft) · 1 unmodified line
545546 return ST_SUCCESS;
546547 }
547548
548−#else /* HAVE_LAME */
549−int st_mp3startwrite(ft_t ft)
549+#else /* HAVE_LIBMP3LAME */
550+static int st_mp3startwrite(ft_t ft UNUSED)
550551 {
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");
552553 return ST_EOF;
553554 }
554555
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)
556557 {
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;
559560 }
560561
561−int st_mp3stopwrite(ft_t ft)
562+static int st_mp3stopwrite(ft_t ft)
562563 {
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");
564565 return ST_EOF;
565566 }
566−#endif /* HAVE_LAME */
567+#endif /* HAVE_LIBMP3LAME */
567568
568569 /* MP3 */
569570 static 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