Mercurial > audlegacy
annotate src/audacious/effect.c @ 3476:9152829f3c19 trunk
Allow non-active playlist to be saved to file
| author | Kieran Clancy <clancy.kieran+audacious@gmail.com> |
|---|---|
| date | Mon, 10 Sep 2007 13:47:16 +0930 |
| parents | f6b25d4d2245 |
| children | 96baf555b449 |
| rev | line source |
|---|---|
| 2313 | 1 /* |
| 2 * Audacious - Cross-platform multimedia player | |
| 3 * Copyright (C) 2005-2007 Audacious dvelopment team. | |
| 4 * | |
| 5 * Based on BMP: | |
| 6 * Copyright (C) 2003-2004 BMP development team. | |
| 7 * | |
| 8 * Based on XMMS: | |
| 9 * Copyright (C) 1998-2003 XMMS development team. | |
| 10 * | |
| 11 * This program is free software; you can redistribute it and/or modify | |
| 12 * it under the terms of the GNU General Public License as published by | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2365
diff
changeset
|
13 * the Free Software Foundation; under version 3 of the License. |
| 2313 | 14 * |
| 15 * This program is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 * GNU General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU General Public License | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2365
diff
changeset
|
21 * along with this program. If not, see <http://www.gnu.org/licenses>. |
|
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * The Audacious team does not consider modular code linking to |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
24 * Audacious or using our public API to be a derived work. |
| 2313 | 25 */ |
| 26 | |
| 27 #include "effect.h" | |
| 28 | |
| 29 #include <glib.h> | |
| 30 #include <string.h> | |
| 31 #include "plugin.h" | |
| 32 | |
| 33 EffectPluginData ep_data = { | |
| 34 NULL, | |
| 2365 | 35 NULL |
| 2313 | 36 }; |
| 37 | |
| 38 static gint | |
| 39 effect_do_mod_samples(gpointer * data, gint length, | |
| 40 AFormat fmt, gint srate, gint nch) | |
| 41 { | |
| 42 GList *l = ep_data.enabled_list; | |
| 43 | |
| 44 while (l) { | |
| 45 if (l->data) { | |
| 46 EffectPlugin *ep = l->data; | |
| 47 if (ep->mod_samples) | |
| 48 length = ep->mod_samples(data, length, fmt, srate, nch); | |
| 49 } | |
| 50 l = g_list_next(l); | |
| 51 } | |
| 52 | |
| 53 return length; | |
| 54 } | |
| 55 | |
| 56 static void | |
| 57 effect_do_query_format(AFormat * fmt, gint * rate, gint * nch) | |
| 58 { | |
| 59 GList *l = ep_data.enabled_list; | |
| 60 | |
| 61 while (l) { | |
| 62 if (l->data) { | |
| 63 EffectPlugin *ep = l->data; | |
| 64 if (ep->query_format) | |
| 65 ep->query_format(fmt, rate, nch); | |
| 66 } | |
| 67 l = g_list_next(l); | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 static EffectPlugin pseudo_effect_plugin = { | |
| 72 NULL, | |
| 73 NULL, | |
| 74 "XMMS Multiple Effects Support", | |
| 75 NULL, | |
| 76 NULL, | |
| 77 NULL, | |
| 78 NULL, | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
79 TRUE, |
| 2313 | 80 effect_do_mod_samples, |
| 81 effect_do_query_format | |
| 82 }; | |
| 83 | |
| 84 /* get_current_effect_plugin() and effects_enabled() are still to be used by | |
| 85 * output plugins as they were when we only supported one effects plugin at | |
| 86 * a time. We now had a pseudo-effects-plugin that chains all the enabled | |
| 87 * plugins. -- Jakdaw */ | |
| 88 | |
| 89 EffectPlugin * | |
| 90 get_current_effect_plugin(void) | |
| 91 { | |
| 92 return &pseudo_effect_plugin; | |
| 93 } | |
| 94 | |
| 95 gboolean | |
| 96 effects_enabled(void) | |
| 97 { | |
| 98 return TRUE; | |
| 99 } | |
| 100 | |
| 101 GList * | |
| 102 get_effect_enabled_list(void) | |
| 103 { | |
| 104 return ep_data.enabled_list; | |
| 105 } | |
| 106 | |
| 107 void | |
| 108 enable_effect_plugin(int i, gboolean enable) | |
| 109 { | |
| 110 GList *node = g_list_nth(ep_data.effect_list, i); | |
| 111 EffectPlugin *ep; | |
| 112 | |
| 113 if (!node || !(node->data)) | |
| 114 return; | |
| 115 ep = node->data; | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
116 ep->enabled = enable; |
| 2313 | 117 |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
118 if (enable && !ep->enabled) { |
| 2313 | 119 ep_data.enabled_list = g_list_append(ep_data.enabled_list, ep); |
| 120 if (ep->init) | |
| 121 ep->init(); | |
| 122 } | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
123 else if (!enable && ep->enabled) { |
| 2313 | 124 ep_data.enabled_list = g_list_remove(ep_data.enabled_list, ep); |
| 125 if (ep->cleanup) | |
| 126 ep->cleanup(); | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 GList * | |
| 131 get_effect_list(void) | |
| 132 { | |
| 133 return ep_data.effect_list; | |
| 134 } | |
| 135 | |
| 136 gchar * | |
| 137 effect_stringify_enabled_list(void) | |
| 138 { | |
| 139 gchar *enalist = NULL, *temp, *temp2; | |
| 140 GList *node = ep_data.enabled_list; | |
| 141 | |
| 142 if (g_list_length(node)) { | |
| 143 enalist = | |
| 144 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
| 145 node = node->next; | |
| 146 while (node) { | |
| 147 temp = enalist; | |
| 148 temp2 = | |
| 149 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
| 150 enalist = g_strconcat(temp, ",", temp2, NULL); | |
| 151 g_free(temp); | |
| 152 g_free(temp2); | |
| 153 node = node->next; | |
| 154 } | |
| 155 } | |
| 156 return enalist; | |
| 157 } | |
| 158 | |
| 159 void | |
| 160 effect_enable_from_stringified_list(const gchar * list) | |
| 161 { | |
| 162 gchar **plugins, *base; | |
| 163 GList *node; | |
| 164 gint i; | |
| 165 EffectPlugin *ep; | |
| 166 | |
| 167 if (!list || !strcmp(list, "")) | |
| 168 return; | |
| 169 plugins = g_strsplit(list, ",", 0); | |
| 170 for (i = 0; plugins[i]; i++) { | |
| 171 node = ep_data.effect_list; | |
| 172 while (node) { | |
| 173 base = | |
| 174 g_path_get_basename((char *) ((EffectPlugin *) node-> | |
| 175 data)->filename); | |
| 176 if (!strcmp(plugins[i], base)) { | |
| 177 ep = node->data; | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
178 ep->enabled = TRUE; |
| 2313 | 179 ep_data.enabled_list = |
| 180 g_list_append(ep_data.enabled_list, ep); | |
| 181 if (ep->init) | |
| 182 ep->init(); | |
| 183 } | |
| 184 g_free(base); | |
| 185 node = node->next; | |
| 186 } | |
| 187 } | |
| 188 g_strfreev(plugins); | |
| 189 } |
