43 #define FILENAME "plugin-registry"
55 GList * keys[INPUT_KEYS];
92 [INPUT_KEY_SCHEME] =
"scheme",
93 [INPUT_KEY_EXTENSION] =
"ext",
94 [INPUT_KEY_MIME] =
"mime"};
98 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
101 loaded,
int timestamp,
int type, Plugin * header)
146 g_list_foreach (plugin->
watches, (GFunc) g_free,
NULL);
156 g_list_foreach (plugin->
u.
p.
exts, (GFunc) g_free,
NULL);
157 g_list_free (plugin->
u.
p.
exts);
161 for (
int key = 0; key < INPUT_KEYS; key ++)
163 g_list_foreach (plugin->
u.
i.
keys[key], (GFunc) g_free,
NULL);
164 g_list_free (plugin->
u.
i.
keys[key]);
168 g_free (plugin->
path);
169 g_free (plugin->
name);
176 FILE * file = fopen (path, mode);
183 for (GList * node = plugin->
u.
t.
schemes; node; node = node->next)
184 fprintf (handle,
"scheme %s\n", (
const char *) node->data);
189 for (GList * node = plugin->
u.
p.
exts; node; node = node->next)
190 fprintf (handle,
"ext %s\n", (
const char *) node->data);
195 for (
int key = 0; key < INPUT_KEYS; key ++)
197 for (GList * node = plugin->
u.
i.
keys[key]; node; node = node->next)
202 fprintf (handle,
"images %d\n", plugin->
u.
i.
has_images);
211 fprintf (handle,
"stamp %d\n", plugin->
timestamp);
212 fprintf (handle,
"name %s\n", plugin->
name);
213 fprintf (handle,
"priority %d\n", plugin->
priority);
214 fprintf (handle,
"about %d\n", plugin->
has_about);
216 fprintf (handle,
"enabled %d\n", plugin->
enabled);
229 g_return_if_fail (handle);
231 fprintf (handle,
"format %d\n",
FORMAT);
289 plugin->
u.
p.
exts = g_list_prepend (plugin->
u.
p.
exts, value);
296 for (
int key = 0; key < INPUT_KEYS; key ++)
301 plugin->
u.
i.
keys[key] = g_list_prepend (plugin->
u.
i.
keys[key],
393 AUDDBG (
"Plugin not found: %s\n", plugin->
path);
424 return strcmp (plugin->
path, path);
429 GList * node = g_list_find_custom (
plugin_list, path, (GCompareFunc)
431 return node ? node->data :
NULL;
436 char * test = g_path_get_basename (plugin->
path);
438 char * dot = strrchr (test,
'.');
442 int ret = strcmp (test, basename);
452 GList * node = g_list_find_custom (
plugin_list, basename, (GCompareFunc)
454 return node ? node->data :
NULL;
462 AUDDBG (
"New plugin: %s\n", path);
468 g_return_if_fail (timestamp >= 0);
470 AUDDBG (
"Register plugin: %s\n", path);
476 AUDDBG (
"Rescan plugin: %s\n", path);
483 AUDDBG (
"Loaded plugin: %s\n", path);
489 g_return_if_fail (plugin->
type == header->type);
502 g_return_if_fail (timestamp >= 0);
505 header->type, header);
509 g_free (plugin->
name);
510 plugin->
name = g_strdup (header->name);
517 TransportPlugin * tp = (TransportPlugin *) header;
518 for (
int i = 0; tp->schemes[i]; i ++)
524 PlaylistPlugin * pp = (PlaylistPlugin *) header;
525 for (
int i = 0; pp->extensions[i]; i ++)
526 plugin->
u.
p.
exts = g_list_prepend (plugin->
u.
p.
exts, g_strdup
527 (pp->extensions[i]));
531 InputPlugin * ip = (InputPlugin *) header;
534 for (
int key = 0; key < INPUT_KEYS; key ++)
536 g_list_foreach (plugin->
u.
i.
keys[key], (GFunc) g_free,
NULL);
537 g_list_free (plugin->
u.
i.
keys[key]);
543 for (
int i = 0; ip->extensions[i]; i ++)
544 plugin->
u.
i.
keys[INPUT_KEY_EXTENSION] = g_list_prepend
545 (plugin->
u.
i.
keys[INPUT_KEY_EXTENSION], g_strdup
546 (ip->extensions[i]));
551 for (
int i = 0; ip->mimes[i]; i ++)
552 plugin->
u.
i.
keys[INPUT_KEY_MIME] = g_list_prepend
553 (plugin->
u.
i.
keys[INPUT_KEY_MIME], g_strdup (ip->mimes[i]));
558 for (
int i = 0; ip->schemes[i]; i ++)
559 plugin->
u.
i.
keys[INPUT_KEY_SCHEME] = g_list_prepend
560 (plugin->
u.
i.
keys[INPUT_KEY_SCHEME], g_strdup (ip->schemes[i]));
570 OutputPlugin * op = (OutputPlugin *) header;
571 plugin->
priority = 10 - op->probe_priority;
575 EffectPlugin * ep = (EffectPlugin *) header;
580 GeneralPlugin * gp = (GeneralPlugin *) header;
582 plugin->
enabled = gp->enabled_by_default;
598 pthread_mutex_lock (&
mutex);
606 pthread_mutex_unlock (&
mutex);
612 return (plugin->
header == header) ? 0 : -1;
617 GList * node = g_list_find_custom (
plugin_list, header, (GCompareFunc)
619 return node ? node->data :
NULL;
624 for (GList * node =
plugin_list; node; node = node->next)
628 if (! func (node->data, data))
655 for (GList * node = plugin->
watches; node; )
657 GList * next = node->next;
660 if (! watch->
func (plugin, watch->
data))
686 return state->
func (plugin, state->
data);
707 for (GList * node = plugin->
watches; node; )
709 GList * next = node->next;
712 if (watch->
func == func && watch->
data == data)
731 (GCompareFunc) g_ascii_strcasecmp))
754 if (! g_list_find_custom (plugin->
u.
p.
exts, state->
ext,
755 (GCompareFunc) g_ascii_strcasecmp))
780 if (! g_list_find_custom (plugin->
u.
i.
keys[state->
key], state->
value,
781 (GCompareFunc) g_ascii_strcasecmp))
784 return state->
func (plugin, state->
data);