Mercurial > audlegacy
annotate src/audacious/effect.c @ 3486:96baf555b449 trunk
Get rid of "XMMS Multiple Effect Plugin support" hack. Effects processing is handled in produce_audio() now days.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Tue, 11 Sep 2007 05:14:38 -0500 |
parents | f6b25d4d2245 |
children | a73951b8cd9f |
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 | |
3486
96baf555b449
Get rid of "XMMS Multiple Effect Plugin support" hack. Effects processing is handled in produce_audio() now days.
William Pitcock <nenolod@atheme.org>
parents:
3455
diff
changeset
|
38 gint |
2313 | 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 | |
3486
96baf555b449
Get rid of "XMMS Multiple Effect Plugin support" hack. Effects processing is handled in produce_audio() now days.
William Pitcock <nenolod@atheme.org>
parents:
3455
diff
changeset
|
56 void |
2313 | 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 GList * | |
72 get_effect_enabled_list(void) | |
73 { | |
74 return ep_data.enabled_list; | |
75 } | |
76 | |
77 void | |
78 enable_effect_plugin(int i, gboolean enable) | |
79 { | |
80 GList *node = g_list_nth(ep_data.effect_list, i); | |
81 EffectPlugin *ep; | |
82 | |
83 if (!node || !(node->data)) | |
84 return; | |
85 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
|
86 ep->enabled = enable; |
2313 | 87 |
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
|
88 if (enable && !ep->enabled) { |
2313 | 89 ep_data.enabled_list = g_list_append(ep_data.enabled_list, ep); |
90 if (ep->init) | |
91 ep->init(); | |
92 } | |
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
|
93 else if (!enable && ep->enabled) { |
2313 | 94 ep_data.enabled_list = g_list_remove(ep_data.enabled_list, ep); |
95 if (ep->cleanup) | |
96 ep->cleanup(); | |
97 } | |
98 } | |
99 | |
100 GList * | |
101 get_effect_list(void) | |
102 { | |
103 return ep_data.effect_list; | |
104 } | |
105 | |
106 gchar * | |
107 effect_stringify_enabled_list(void) | |
108 { | |
109 gchar *enalist = NULL, *temp, *temp2; | |
110 GList *node = ep_data.enabled_list; | |
111 | |
112 if (g_list_length(node)) { | |
113 enalist = | |
114 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
115 node = node->next; | |
116 while (node) { | |
117 temp = enalist; | |
118 temp2 = | |
119 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
120 enalist = g_strconcat(temp, ",", temp2, NULL); | |
121 g_free(temp); | |
122 g_free(temp2); | |
123 node = node->next; | |
124 } | |
125 } | |
126 return enalist; | |
127 } | |
128 | |
129 void | |
130 effect_enable_from_stringified_list(const gchar * list) | |
131 { | |
132 gchar **plugins, *base; | |
133 GList *node; | |
134 gint i; | |
135 EffectPlugin *ep; | |
136 | |
137 if (!list || !strcmp(list, "")) | |
138 return; | |
139 plugins = g_strsplit(list, ",", 0); | |
140 for (i = 0; plugins[i]; i++) { | |
141 node = ep_data.effect_list; | |
142 while (node) { | |
143 base = | |
144 g_path_get_basename((char *) ((EffectPlugin *) node-> | |
145 data)->filename); | |
146 if (!strcmp(plugins[i], base)) { | |
147 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
|
148 ep->enabled = TRUE; |
2313 | 149 ep_data.enabled_list = |
150 g_list_append(ep_data.enabled_list, ep); | |
151 if (ep->init) | |
152 ep->init(); | |
153 } | |
154 g_free(base); | |
155 node = node->next; | |
156 } | |
157 } | |
158 g_strfreev(plugins); | |
159 } |