ref: af6968bff6431d751ed9792c1245e2406e2555b3
parent: 30d829e27b4123315444185a5a02b409101a74e6
author: robs <robs>
date: Sun Nov 2 15:43:34 EST 2008
fix problems reading short mp3 files
--- a/ChangeLog
+++ b/ChangeLog
@@ -42,6 +42,7 @@
o New `.sox' native format intended for intermediate files. (robs)
o Fix WAV write on 64-bit arch. (robs)
o Fix writing PRC ADPCM files. (Silas Brown)
+ o Fix problems reading short mp3 files. (robs)
Effects:
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -168,6 +168,7 @@
if (ft->seekable) {
#if HAVE_ID3TAG && HAVE_UNISTD_H
read_comments(ft);
+ rewind(ft->fp);
if (!ft->signal.length)
#endif
ft->signal.length = mp3_duration_ms(ft->fp, p->InputBuffer);
@@ -185,11 +186,8 @@
* can be processed later.
*/
ReadSize = lsx_readbuf(ft, p->InputBuffer, INPUT_BUFFER_SIZE);
- if (ReadSize < INPUT_BUFFER_SIZE) {
- if (lsx_eof(ft))
- lsx_fail_errno(ft, SOX_EOF, "input file too short");
+ if (ReadSize != INPUT_BUFFER_SIZE && ferror(ft->fp))
return SOX_EOF;
- }
mad_stream_buffer(&p->Stream, p->InputBuffer, ReadSize);