Am Tue, 12 Jun 2012 09:25:07 +0200
schrieb Max Kellermann <m...@duempel.org>: 

> On 2012/06/12 09:20, Thomas Orgis <thomas-fo...@orgis.org> wrote:
> > Does plain mpg123 play the file?
> > 
> > shell$ mpg123 /path/to/file.mp3
> 
> No, same problem.

That is good: It means I can debug and fix without touching mpd;-) Attached is 
a hotfix patch that limits the attempts to guess free format frame size. I'm 
not totally sure about a followup detail about cleaner abort (it's in mpg123 
trunk in addition to the patch), but you can expect mpg123-1.14.3 sometime in 
the near future with a fix.

Meanwhile, can you test the attached patch if it helps, or grab 
http://mpg123.org/snapshot for a prepared tarball of the trunk.


Alrighty then,

Thomas

Index: trunk/src/libmpg123/parse.c
===================================================================
--- trunk/src/libmpg123/parse.c	(Revision 3190)
+++ trunk/src/libmpg123/parse.c	(Revision 3191)
@@ -61,7 +61,7 @@
 
 static const long freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };
 
-static int decode_header(mpg123_handle *fr,unsigned long newhead);
+static int decode_header(mpg123_handle *fr,unsigned long newhead, int *freeformat_count);
 static int skip_junk(mpg123_handle *fr, unsigned long *newheadp, long *headcount);
 static int do_readahead(mpg123_handle *fr, unsigned long newhead);
 static int wetwork(mpg123_handle *fr, unsigned long *newheadp);
@@ -445,6 +445,7 @@
 int read_frame(mpg123_handle *fr)
 {
 	/* TODO: rework this thing */
+	int freeformat_count = 0;
 	unsigned long newhead;
 	off_t framepos;
 	int ret;
@@ -495,7 +496,7 @@
 #endif
 
 	ret = head_check(newhead);
-	if(ret) ret = decode_header(fr, newhead);
+	if(ret) ret = decode_header(fr, newhead, &freeformat_count);
 
 	JUMP_CONCLUSION(ret); /* That only continues for ret == 0 or 1 */
 	if(ret == 0)
@@ -667,7 +668,7 @@
  * <0: some error
  * You are required to do a head_check() before calling!
  */
-static int decode_header(mpg123_handle *fr,unsigned long newhead)
+static int decode_header(mpg123_handle *fr,unsigned long newhead, int *freeformat_count)
 {
 #ifdef DEBUG /* Do not waste cycles checking the header twice all the time. */
 	if(!head_check(newhead))
@@ -724,6 +725,12 @@
 		if(fr->freeformat_framesize < 0)
 		{
 			int ret;
+			*freeformat_count += 1;
+			if(*freeformat_count > 5)
+			{
+				if(VERBOSE3) error("You fooled me too often. Refusing to guess free format frame size _again_.");
+				return 0;
+			}
 			ret = guess_freeformat_framesize(fr);
 			if(ret>0)
 			{
@@ -1015,6 +1022,7 @@
 static int skip_junk(mpg123_handle *fr, unsigned long *newheadp, long *headcount)
 {
 	int ret;
+	int freeformat_count = 0;
 	long limit = 65536;
 	unsigned long newhead = *newheadp;
 	/* check for id3v2; first three bytes (of 4) are "ID3" */
@@ -1064,7 +1072,7 @@
 
 		if((ret=fr->rd->head_shift(fr,&newhead))<=0) return ret;
 
-		if(head_check(newhead) && (ret=decode_header(fr, newhead))) break;
+		if(head_check(newhead) && (ret=decode_header(fr, newhead, &freeformat_count))) break;
 	} while(1);
 	if(ret<0) return ret;
 

Attachment: signature.asc
Description: PGP signature

_______________________________________________
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-multimedia-maintainers

Reply via email to