diff Plugins/Input/mpg123/mpg123.c @ 1372:b861909ec6da trunk

[svn] mpgdec: - fix smart detection of MPEG streams/Xiph containers/MP3X containers/Fraunhofer VBRX containers - use smart detection instead of extension checking - avoid grabbing FLAC streams if mpgdec is loaded before libflac is.
author nenolod
date Tue, 04 Jul 2006 17:29:40 -0700
parents 9dc0ce1fd3cd
children 86242883ddc7
line wrap: on
line diff
--- a/Plugins/Input/mpg123/mpg123.c	Tue Jul 04 04:59:27 2006 -0700
+++ b/Plugins/Input/mpg123/mpg123.c	Tue Jul 04 17:29:40 2006 -0700
@@ -268,8 +268,7 @@
 }
 
 
-#if 0
-#define DET_BUF_SIZE 1024
+#define DET_BUF_SIZE 4096
 
 static gboolean
 mpgdec_detect_by_content(char *filename)
@@ -293,7 +292,7 @@
          * The mpeg-stream can start anywhere in the file,
          * so we check the entire file
 	 *
-	 * Incorrect! We give up past ten iterations of this
+	 * Incorrect! We give up past twenty iterations of this
 	 * code for safety's sake. Buffer overflows suck. --nenolod
          */
         /* Optimize this */
@@ -310,7 +309,7 @@
             }
         }
 
-        if (++cyc > 20)
+        if (++cyc > 1024)
 	    goto done;
     }
     if (mpgdec_decode_header(&fr, head)) {
@@ -332,19 +331,22 @@
     vfs_fclose(file);
     return ret;
 }
-#endif
 
 static int
 is_our_file(char *filename)
 {
     gchar *ext = strrchr(filename, '.');
 
-    if (!strncasecmp(filename, "http://", 7) && (ext && strncasecmp(ext, ".ogg", 4)))
+    if (!strncasecmp(filename, "http://", 7) && (ext && strncasecmp(ext, ".ogg", 4)) && (ext && strncasecmp(ext, ".flac", 5)))
 	return TRUE;
+    else if (mpgdec_detect_by_content(filename))
+        return TRUE;
+#if 0
     else if (ext && (!strncasecmp(ext, ".mp3", 4)
 	|| !strncasecmp(ext, ".mp2", 4)
 	|| !strncasecmp(ext, ".mpg", 4)))
         return TRUE;
+#endif
 
     return FALSE;
 }