Mercurial > audlegacy
annotate src/audacious/effect.c @ 4011:c19c8d47e221
vseparator in fileinfo came back
| author | Eugene Zagidullin <e.asphyx@gmail.com> |
|---|---|
| date | Sun, 25 Nov 2007 04:44:40 +0300 |
| parents | 65b9207fb7b2 |
| children | 2b7a74fce100 |
| 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; | |
| 86 | |
|
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
|
87 if (enable && !ep->enabled) { |
| 2313 | 88 ep_data.enabled_list = g_list_append(ep_data.enabled_list, ep); |
| 89 if (ep->init) | |
| 90 ep->init(); | |
| 91 } | |
|
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
|
92 else if (!enable && ep->enabled) { |
| 2313 | 93 ep_data.enabled_list = g_list_remove(ep_data.enabled_list, ep); |
| 94 if (ep->cleanup) | |
| 95 ep->cleanup(); | |
| 96 } | |
|
3675
65b9207fb7b2
Make effect plugins work again.
William Pitcock <nenolod@atheme.org>
parents:
3556
diff
changeset
|
97 |
|
65b9207fb7b2
Make effect plugins work again.
William Pitcock <nenolod@atheme.org>
parents:
3556
diff
changeset
|
98 ep->enabled = enable; |
| 2313 | 99 } |
| 100 | |
| 101 GList * | |
| 102 get_effect_list(void) | |
| 103 { | |
| 104 return ep_data.effect_list; | |
| 105 } | |
| 106 | |
| 107 gchar * | |
| 108 effect_stringify_enabled_list(void) | |
| 109 { | |
| 110 gchar *enalist = NULL, *temp, *temp2; | |
| 111 GList *node = ep_data.enabled_list; | |
| 112 | |
| 113 if (g_list_length(node)) { | |
| 114 enalist = | |
| 115 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
| 116 node = node->next; | |
| 117 while (node) { | |
| 118 temp = enalist; | |
| 119 temp2 = | |
| 120 g_strdup(g_basename(((EffectPlugin *) node->data)->filename)); | |
| 121 enalist = g_strconcat(temp, ",", temp2, NULL); | |
| 122 g_free(temp); | |
| 123 g_free(temp2); | |
| 124 node = node->next; | |
| 125 } | |
| 126 } | |
| 127 return enalist; | |
| 128 } | |
| 129 | |
| 130 void | |
| 131 effect_enable_from_stringified_list(const gchar * list) | |
| 132 { | |
| 133 gchar **plugins, *base; | |
| 134 GList *node; | |
| 135 gint i; | |
| 136 EffectPlugin *ep; | |
| 137 | |
| 138 if (!list || !strcmp(list, "")) | |
| 139 return; | |
| 140 plugins = g_strsplit(list, ",", 0); | |
| 141 for (i = 0; plugins[i]; i++) { | |
| 142 node = ep_data.effect_list; | |
| 143 while (node) { | |
| 144 base = | |
| 145 g_path_get_basename((char *) ((EffectPlugin *) node-> | |
| 146 data)->filename); | |
| 147 if (!strcmp(plugins[i], base)) { | |
| 148 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
|
149 ep->enabled = TRUE; |
| 2313 | 150 ep_data.enabled_list = |
| 151 g_list_append(ep_data.enabled_list, ep); | |
| 152 if (ep->init) | |
| 153 ep->init(); | |
| 154 } | |
| 155 g_free(base); | |
| 156 node = node->next; | |
| 157 } | |
| 158 } | |
| 159 g_strfreev(plugins); | |
| 160 } | |
|
3555
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
161 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
162 void |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
163 effect_flow(FlowContext *context) |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
164 { |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
165 AFormat new_format; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
166 gint new_rate; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
167 gint new_nch; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
168 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
169 new_format = context->fmt; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
170 new_rate = context->srate; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
171 new_nch = context->channels; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
172 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
173 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
|
174 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
175 if (new_format != context->fmt || |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
176 new_rate != context->srate || |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
177 new_nch != context->channels) |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
178 { |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
179 /* |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
180 * 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
|
181 * audio device. |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
182 */ |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
183 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
|
184 return; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
185 |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
186 context->fmt = new_format; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
187 context->srate = new_rate; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
188 context->channels = new_nch; |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
189 } |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
190 |
|
3556
23fcb140ee13
use ->len, not ->length.
William Pitcock <nenolod@atheme.org>
parents:
3555
diff
changeset
|
191 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
|
192 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
|
193 } |
|
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
194 |
