diff src/audacious/pluginenum.c @ 3934:e924c9ee3958

when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 15 Nov 2007 16:34:09 +0900
parents bf6b1c5091d5
children a575c29cee05
line wrap: on
line diff
--- a/src/audacious/pluginenum.c	Wed Nov 14 17:32:02 2007 +0100
+++ b/src/audacious/pluginenum.c	Thu Nov 15 16:34:09 2007 +0900
@@ -68,6 +68,8 @@
     NULL
 };
 
+GHashTable *ext_hash = NULL;
+
 /*****************************************************************/
 
 static struct _AudaciousFuncTableV1 _aud_papi_v1 = {
@@ -517,6 +519,14 @@
     /* XXX: we need something better than p->filename if plugins
        will eventually provide multiple plugins --nenolod */
     mowgli_dictionary_add(plugin_dict, g_basename(p->filename), p);
+
+    /* build the extension hash table */
+    gint i;
+    if(p->vfs_extensions) {
+        for(i = 0; p->vfs_extensions[i] != NULL; i++) {
+            g_hash_table_replace(ext_hash, g_strdup(p->vfs_extensions[i]), g_strdup(p->description));
+        }
+    }
 }
 
 static void
@@ -752,6 +762,9 @@
 
     plugin_dict = mowgli_dictionary_create(g_ascii_strcasecmp);
 
+    /* make extension hash */
+    ext_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+
 #ifndef DISABLE_USER_PLUGIN_DIR
     scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]);
     /*
@@ -1030,4 +1043,5 @@
     }
 
     mowgli_dictionary_destroy(plugin_dict, NULL, NULL);
+    g_hash_table_remove_all(ext_hash);
 }