Mercurial > audlegacy
annotate src/audacious/effect.c @ 4667:2079f04c19e2
Use new Interface API.
| author | William Pitcock <nenolod@atheme.org> |
|---|---|
| date | Sun, 29 Jun 2008 00:45:55 -0500 |
| parents | 2b7a74fce100 |
| children | aa79a84627b9 |
| 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" | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
32 #include "pluginenum.h" |
| 2313 | 33 |
| 34 EffectPluginData ep_data = { | |
| 35 NULL, | |
| 2365 | 36 NULL |
| 2313 | 37 }; |
| 38 | |
|
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
|
39 gint |
| 2313 | 40 effect_do_mod_samples(gpointer * data, gint length, |
| 41 AFormat fmt, gint srate, gint nch) | |
| 42 { | |
| 43 GList *l = ep_data.enabled_list; | |
| 44 | |
| 45 while (l) { | |
| 46 if (l->data) { | |
| 47 EffectPlugin *ep = l->data; | |
| 48 if (ep->mod_samples) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
49 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
50 plugin_set_current((Plugin *)ep); |
| 2313 | 51 length = ep->mod_samples(data, length, fmt, srate, nch); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
52 } |
| 2313 | 53 } |
| 54 l = g_list_next(l); | |
| 55 } | |
| 56 | |
| 57 return length; | |
| 58 } | |
| 59 | |
|
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
|
60 void |
| 2313 | 61 effect_do_query_format(AFormat * fmt, gint * rate, gint * nch) |
| 62 { | |
| 63 GList *l = ep_data.enabled_list; | |
| 64 | |
| 65 while (l) { | |
| 66 if (l->data) { | |
| 67 EffectPlugin *ep = l->data; | |
| 68 if (ep->query_format) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
69 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
70 plugin_set_current((Plugin *)ep); |
| 2313 | 71 ep->query_format(fmt, rate, nch); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
72 } |
| 2313 | 73 } |
| 74 l = g_list_next(l); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 GList * | |
| 79 get_effect_enabled_list(void) | |
| 80 { | |
| 81 return ep_data.enabled_list; | |
| 82 } | |
| 83 | |
| 84 void | |
| 85 enable_effect_plugin(int i, gboolean enable) | |
| 86 { | |
| 87 GList *node = g_list_nth(ep_data.effect_list, i); | |
| 88 EffectPlugin *ep; | |
| 89 | |
| 90 if (!node || !(node->data)) | |
| 91 return; | |
| 92 ep = node->data; | |
| 93 | |
|
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
|
94 if (enable && !ep->enabled) { |
| 2313 | 95 ep_data.enabled_list = g_list_append(ep_data.enabled_list, ep); |
| 96 if (ep->init) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
97 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
98 plugin_set_current((Plugin *)ep); |
| 2313 | 99 ep->init(); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
100 } |
| 2313 | 101 } |
|
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
|
102 else if (!enable && ep->enabled) { |
| 2313 | 103 ep_data.enabled_list = g_list_remove(ep_data.enabled_list, ep); |
| 104 if (ep->cleanup) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
105 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
106 plugin_set_current((Plugin *)ep); |
| 2313 | 107 ep->cleanup(); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
108 } |
| 2313 | 109 } |
|
3675
65b9207fb7b2
Make effect plugins work again.
William Pitcock <nenolod@atheme.org>
parents:
3556
diff
changeset
|
110 |
|
65b9207fb7b2
Make effect plugins work again.
William Pitcock <nenolod@atheme.org>
parents:
3556
diff
changeset
|
111 ep->enabled = enable; |
| 2313 | 112 } |
| 113 | |
| 114 GList * | |
| 115 get_effect_list(void) | |
| 116 { | |
| 117 return ep_data.effect_list; | |
| 118 } | |
| 119 | |
| 120 gchar * | |
| 121 effect_stringify_enabled_list(void) | |
| 122 { | |
| 123 gchar *enalist = NULL, *temp, *temp2; | |
| 124 GList *node = ep_data.enabled_list; | |
| 125 | |
| 126 if (g_list_length(node)) { | |
| 127 enalist = | |
| 128 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
| 129 node = node->next; | |
| 130 while (node) { | |
| 131 temp = enalist; | |
| 132 temp2 = | |
| 133 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
| 134 enalist = g_strconcat(temp, ",", temp2, NULL); | |
| 135 g_free(temp); | |
| 136 g_free(temp2); | |
| 137 node = node->next; | |
| 138 } | |
| 139 } | |
| 140 return enalist; | |
| 141 } | |
| 142 | |
| 143 void | |
| 144 effect_enable_from_stringified_list(const gchar * list) | |
| 145 { | |
| 146 gchar **plugins, *base; | |
| 147 GList *node; | |
| 148 gint i; | |
| 149 EffectPlugin *ep; | |
| 150 | |
| 151 if (!list || !strcmp(list, "")) | |
| 152 return; | |
| 153 plugins = g_strsplit(list, ",", 0); | |
| 154 for (i = 0; plugins[i]; i++) { | |
| 155 node = ep_data.effect_list; | |
| 156 while (node) { | |
| 157 base = | |
| 158 g_path_get_basename((char *) ((EffectPlugin *) node-> | |
| 159 data)->filename); | |
| 160 if (!strcmp(plugins[i], base)) { | |
| 161 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
|
162 ep->enabled = TRUE; |
| 2313 | 163 ep_data.enabled_list = |
| 164 g_list_append(ep_data.enabled_list, ep); | |
| 165 if (ep->init) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
166 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
167 plugin_set_current((Plugin *)ep); |
| 2313 | 168 ep->init(); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3675
diff
changeset
|
169 } |
| 2313 | 170 } |
| 171 g_free(base); | |
| 172 node = node->next; | |
| 173 } | |
| 174 } | |
| 175 g_strfreev(plugins); | |
| 176 } | |
|
3555
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
177 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
178 void |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
179 effect_flow(FlowContext *context) |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
180 { |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
181 AFormat new_format; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
182 gint new_rate; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
183 gint new_nch; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
184 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
185 new_format = context->fmt; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
186 new_rate = context->srate; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
187 new_nch = context->channels; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
188 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
189 effect_do_query_format(&new_format, &new_rate, &new_nch); |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
190 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
191 if (new_format != context->fmt || |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
192 new_rate != context->srate || |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
193 new_nch != context->channels) |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
194 { |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
195 /* |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
196 * The effect plugin changes the stream format. Reopen the |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
197 * audio device. |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
198 */ |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
199 if (!output_open_audio(new_format, new_rate, new_nch)) |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
200 return; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
201 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
202 context->fmt = new_format; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
203 context->srate = new_rate; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
204 context->channels = new_nch; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
205 } |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
206 |
|
3556
23fcb140ee13
use ->len, not ->length.
William Pitcock <nenolod@atheme.org>
parents:
3555
diff
changeset
|
207 context->len = effect_do_mod_samples(&context->data, context->len, |
|
3555
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
208 context->fmt, context->srate, context->channels); |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
209 } |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
210 |
