1
/* XMMS2 - X Music Multiplexer System
2
* Copyright (C) 2003-2011 XMMS2 Team
4
* PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
17
#include "xmmspriv/xmms_xform.h"
18
#include "xmmspriv/xmms_xform_plugin.h"
19
#include "xmms/xmms_log.h"
21
struct xmms_xform_plugin_St {
23
xmms_xform_methods_t methods;
28
destroy (xmms_object_t *obj)
30
xmms_xform_plugin_t *plugin = (xmms_xform_plugin_t *) obj;
32
while (plugin->in_types) {
33
xmms_object_unref (plugin->in_types->data);
35
plugin->in_types = g_list_delete_link (plugin->in_types,
39
xmms_plugin_destroy ((xmms_plugin_t *) obj);
43
xmms_xform_plugin_new (void)
45
xmms_xform_plugin_t *res;
47
res = xmms_object_new (xmms_xform_plugin_t, destroy);
49
return (xmms_plugin_t *)res;
53
xmms_xform_plugin_methods_set (xmms_xform_plugin_t *plugin,
54
xmms_xform_methods_t *methods)
56
g_return_if_fail (plugin);
57
g_return_if_fail (plugin->plugin.type == XMMS_PLUGIN_TYPE_XFORM);
59
XMMS_DBG ("Registering xform '%s'",
60
xmms_plugin_shortname_get ((xmms_plugin_t *) plugin));
62
memcpy (&plugin->methods, methods, sizeof (xmms_xform_methods_t));
66
xmms_xform_plugin_verify (xmms_plugin_t *_plugin)
68
xmms_xform_plugin_t *plugin = (xmms_xform_plugin_t *) _plugin;
70
g_return_val_if_fail (plugin, FALSE);
71
g_return_val_if_fail (plugin->plugin.type == XMMS_PLUGIN_TYPE_XFORM, FALSE);
79
xmms_xform_plugin_indata_add (xmms_xform_plugin_t *plugin, ...)
81
xmms_stream_type_t *t;
83
gchar *config_key, config_value[32];
86
va_start (ap, plugin);
87
t = xmms_stream_type_parse (ap);
90
config_key = g_strconcat ("priority.",
91
xmms_stream_type_get_str (t, XMMS_STREAM_TYPE_NAME),
93
priority = xmms_stream_type_get_int (t, XMMS_STREAM_TYPE_PRIORITY);
94
g_snprintf (config_value, sizeof (config_value), "%d", priority);
95
xmms_xform_plugin_config_property_register (plugin, config_key,
96
config_value, NULL, NULL);
99
plugin->in_types = g_list_prepend (plugin->in_types, t);
103
xmms_xform_plugin_supports (const xmms_xform_plugin_t *plugin, xmms_stream_type_t *st,
108
g_return_val_if_fail (st, FALSE);
109
g_return_val_if_fail (plugin, FALSE);
110
g_return_val_if_fail (priority, FALSE);
112
for (t = plugin->in_types; t; t = g_list_next (t)) {
113
xmms_config_property_t *config_priority;
114
const gchar *type_name;
117
if (!xmms_stream_type_match (t->data, st)) {
121
type_name = xmms_stream_type_get_str (t->data, XMMS_STREAM_TYPE_NAME);
123
config_key = g_strconcat ("priority.", type_name, NULL);
124
config_priority = xmms_plugin_config_lookup ((xmms_plugin_t *) plugin,
128
if (config_priority) {
129
*priority = xmms_config_property_get_int (config_priority);
131
*priority = XMMS_STREAM_TYPE_PRIORITY_DEFAULT;
140
xmms_config_property_t *
141
xmms_xform_plugin_config_property_register (xmms_xform_plugin_t *xform_plugin,
143
const gchar *default_value,
144
xmms_object_handler_t cb,
147
xmms_plugin_t *plugin = (xmms_plugin_t *) xform_plugin;
149
return xmms_plugin_config_property_register (plugin, name,
155
xmms_xform_plugin_can_init (const xmms_xform_plugin_t *plugin)
157
return !!plugin->methods.init;
161
xmms_xform_plugin_can_read (const xmms_xform_plugin_t *plugin)
163
return !!plugin->methods.read;
167
xmms_xform_plugin_can_seek (const xmms_xform_plugin_t *plugin)
169
return !!plugin->methods.seek;
173
xmms_xform_plugin_can_browse (const xmms_xform_plugin_t *plugin)
175
return !!plugin->methods.browse;
179
xmms_xform_plugin_can_destroy (const xmms_xform_plugin_t *plugin)
181
return !!plugin->methods.destroy;
185
xmms_xform_plugin_init (const xmms_xform_plugin_t *plugin, xmms_xform_t *xform)
187
return plugin->methods.init (xform);
191
xmms_xform_plugin_read (const xmms_xform_plugin_t *plugin, xmms_xform_t *xform,
192
xmms_sample_t *buf, gint length, xmms_error_t *error)
194
return plugin->methods.read (xform, buf, length, error);
198
xmms_xform_plugin_seek (const xmms_xform_plugin_t *plugin, xmms_xform_t *xform,
199
gint64 offset, xmms_xform_seek_mode_t whence,
202
return plugin->methods.seek (xform, offset, whence, err);
207
xmms_xform_plugin_browse (const xmms_xform_plugin_t *plugin, xmms_xform_t *xform,
208
const gchar *url, xmms_error_t *error)
210
return plugin->methods.browse (xform, url, error);
214
xmms_xform_plugin_destroy (const xmms_xform_plugin_t *plugin, xmms_xform_t *xform)
216
plugin->methods.destroy (xform);