From 78a175b662f8e54c67a13ac56ddac52c6bd3ad1e Mon Sep 17 00:00:00 2001 From: thor Date: Mon, 16 Mar 2020 08:20:45 +0000 Subject: [PATCH] libmpg123: no MPG123_NEED_MORE for non-feeder git-svn-id: svn://scm.orgis.org/mpg123/trunk@4622 35dc7657-300d-0410-a2e5-dc2837fedb53 --- NEWS | 5 +++-- src/libmpg123/parse.c | 2 +- src/libmpg123/readers.c | 21 ++++++++------------- src/mpg123.c | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 870dea7a..35ab145a 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,6 @@ 1.26.0 ------ -TODO: avoid MPG123_NEED_MORE from non-feed reader reading frame - bodies or see it as a feature TODO: Figure out terminal printout encoding for Windows. TODO: Fix up --quiet: either all errors or none, I guess errors should still be shown, but only fatal ones (no junk in the beginning stuff) @@ -90,6 +88,9 @@ TODO: Make libout123 and/or mpg123 use that to convert on the fly. Optionally? opening. This was never recommened and only now should work at all. -- Also mpg123_decode_frame() now sets return buffer to NULL and returned byte count to zero in case of MPG123_NEED_MORE (or any other early abort). +-- MPG123_NEED_MORE not returned anymore for non-feeder streams. Got in + there for generic partial frame body reads, but was only intended for + feeder API. -- Added mpg123_set_moreinfo() to support the Lame project's frame analyzer, disabled by ./configure --disable-moreinfo. -- Added optional storage and retrieval of raw ID3 data. diff --git a/src/libmpg123/parse.c b/src/libmpg123/parse.c index 516bae68..fcfe21a2 100644 --- a/src/libmpg123/parse.c +++ b/src/libmpg123/parse.c @@ -565,7 +565,7 @@ init_resync: if((ret=fr->rd->read_frame_body(fr,newbuf,fr->framesize))<0) { /* if failed: flip back */ - debug("need more?"); + debug1("%s", ret == MPG123_NEED_MORE ? "need more" : "read error"); goto read_frame_bad; } fr->bsbufold = fr->bsbuf; diff --git a/src/libmpg123/readers.c b/src/libmpg123/readers.c index dba6a146..3376684e 100644 --- a/src/libmpg123/readers.c +++ b/src/libmpg123/readers.c @@ -384,18 +384,12 @@ static int stream_back_bytes(mpg123_handle *fr, off_t bytes) } -/* returns size on success... */ +/* returns size on success... otherwise an error code < 0 */ static int generic_read_frame_body(mpg123_handle *fr,unsigned char *buf, int size) { long l; - - if((l=fr->rd->fullread(fr,buf,size)) != size) - { - long ll = l; - if(ll <= 0) ll = 0; - return READER_MORE; - } - return l; + l=fr->rd->fullread(fr,buf,size); + return (l >= 0 && lrdat.buffer; ssize_t gotcount; + if(VERBOSE3) + mdebug("buffered_fullread: want %zd", count); if(bc->size - bc->pos < count) { /* Add more stuff to buffer. If hitting end of file, adjust count. */ unsigned char readbuf[4096]; @@ -881,9 +877,8 @@ static ssize_t buffered_fullread(mpg123_handle *fr, unsigned char *out, ssize_t count = bc->size - bc->pos; /* We want only what we got. */ } gotcount = bc_give(bc, out, count); - - if(VERBOSE3) debug2("wanted %li, got %li", (long)count, (long)gotcount); - + if(VERBOSE3) + mdebug("buffered_fullread: got %zd", gotcount); if(gotcount != count){ if(NOQUIET) error("gotcount != count"); return READER_ERROR; } else return gotcount; } @@ -1116,7 +1111,7 @@ static int default_init(mpg123_handle *fr) bc_init(&fr->rdat.buffer); fr->rdat.filelen = 0; /* We carry the offset, but never know how big the stream is. */ fr->rdat.flags |= READER_BUFFERED; -#endif /* NO_FEEDER */ +#endif /* NO_ICY */ } return 0; } diff --git a/src/mpg123.c b/src/mpg123.c index 5c686b1e..510d5af5 100644 --- a/src/mpg123.c +++ b/src/mpg123.c @@ -826,7 +826,7 @@ int play_frame(void) { if(!param.quiet && mc == MPG123_ERR) error1("...in decoding next frame: %s", mpg123_strerror(mh)); if(!param.quiet && mc == MPG123_NEED_MORE) - error("The decoder expected more. File cut off early?"); + error("The decoder expected more. Old libmpg123 that does this for non-feed readers?"); if(mc != MPG123_DONE && !got_played) got_played = -1; return 0;