changeset 2112:81c744358bab trunk

[svn] - improved logic for extension assist
author nenolod
date Tue, 12 Dec 2006 19:51:25 -0800
parents 82a6284108c1
children d1e4f54fb9f5
files ChangeLog audacious/input.c
diffstat 2 files changed, 45 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 12 19:29:15 2006 -0800
+++ b/ChangeLog	Tue Dec 12 19:51:25 2006 -0800
@@ -1,3 +1,11 @@
+2006-12-13 03:29:15 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [3227]
+  - put this back the way it was
+  
+  trunk/audacious/plugin.h |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2006-12-13 03:15:23 +0000  William Pitcock <nenolod@nenolod.net>
   revision [3225]
   - specifically define this as a table
--- a/audacious/input.c	Tue Dec 12 19:29:15 2006 -0800
+++ b/audacious/input.c	Tue Dec 12 19:51:25 2006 -0800
@@ -415,10 +415,13 @@
     InputPlugin *ip;
     gchar *filename_proxy;
     gint ret = 1;
+    gchar *ext;
 
     filename_proxy = g_strdup(filename);
     fd = vfs_fopen(filename, "rb");
 
+    ext = strrchr(filename) + 1;
+
     for (node = get_input_list(); node != NULL; node = g_list_next(node))
     {
         ip = INPUT_PLUGIN(node->data);
@@ -427,50 +430,47 @@
             continue;
 
         vfs_fseek(fd, 0, SEEK_SET);
-        if (cfg.use_extension_probing != TRUE || ip->vfs_extensions == NULL)
-        {
 
-            if (ip->is_our_file_from_vfs != NULL)
-            {
-                ret = ip->is_our_file_from_vfs(filename_proxy, fd);
-
-                if (ret > 0)
-                {
-                    g_free(filename_proxy);
-                    vfs_fclose(fd);
-                    return ip;
-                }
-            }
-            else if (ip->is_our_file != NULL)
-            {
-                ret = ip->is_our_file(filename_proxy);
-
-                if (ret > 0)
-                {
-                    g_free(filename_proxy);
-                    vfs_fclose(fd);
-                    return ip;
-                }
-            }
-        }
-        else
+        if (cfg.use_extension_probing == TRUE && ip->vfs_extensions != NULL
+		&& ext != NULL && ext != 1)
         {
             gint i;
-            gchar *ext = strrchr(filename_proxy, '.');
-
-            if (ext == NULL)
-                continue;
-
-            ext++;
+            gboolean is_our_ext = FALSE;
 
             for (i = 0; ip->vfs_extensions[i] != NULL; i++)
             {
                 if (!g_strcasecmp(ip->vfs_extensions[i], ext))
-                {
-                    g_free(filename_proxy);
-                    vfs_fclose(fd);
-                    return ip;
-                }
+	        {
+		    is_our_ext = TRUE;
+		    break;
+		}
+            }
+
+            /* not a plugin that supports this extension */
+            if (is_our_ext == FALSE) 
+                continue;
+        }
+
+        if (ip->is_our_file_from_vfs != NULL)
+        {
+            ret = ip->is_our_file_from_vfs(filename_proxy, fd);
+
+            if (ret > 0)
+            {
+                g_free(filename_proxy);
+                vfs_fclose(fd);
+                return ip;
+            }
+        }
+        else if (ip->is_our_file != NULL)
+        {
+            ret = ip->is_our_file(filename_proxy);
+
+            if (ret > 0)
+            {
+                g_free(filename_proxy);
+                vfs_fclose(fd);
+                return ip;
             }
         }