2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "input_init.h"
22 #include "input_plugin.h"
23 #include "input_registry.h"
25 #include "glib_compat.h"
32 return g_quark_from_static_string("input");
36 * Find the "input" configuration block for the specified plugin.
38 * @param plugin_name the name of the input plugin
39 * @return the configuration block, or NULL if none was configured
41 static const struct config_param
*
42 input_plugin_config(const char *plugin_name
, GError
**error_r
)
44 const struct config_param
*param
= NULL
;
46 while ((param
= config_get_next_param(CONF_INPUT
, param
)) != NULL
) {
48 config_get_block_string(param
, "plugin", NULL
);
50 g_set_error(error_r
, input_quark(), 0,
51 "input configuration without 'plugin' name in line %d",
56 if (strcmp(name
, plugin_name
) == 0)
64 input_stream_global_init(GError
**error_r
)
68 for (unsigned i
= 0; input_plugins
[i
] != NULL
; ++i
) {
69 const struct input_plugin
*plugin
= input_plugins
[i
];
70 const struct config_param
*param
=
71 input_plugin_config(plugin
->name
, &error
);
72 if (param
== NULL
&& error
!= NULL
) {
73 g_propagate_error(error_r
, error
);
77 if (!config_get_block_bool(param
, "enabled", true))
78 /* the plugin is disabled in mpd.conf */
81 if (plugin
->init
== NULL
|| plugin
->init(param
, &error
))
82 input_plugins_enabled
[i
] = true;
84 g_propagate_prefixed_error(error_r
, error
,
85 "Failed to initialize input plugin '%s': ",
94 void input_stream_global_finish(void)
96 for (unsigned i
= 0; input_plugins
[i
] != NULL
; ++i
)
97 if (input_plugins_enabled
[i
] &&
98 input_plugins
[i
]->finish
!= NULL
)
99 input_plugins
[i
]->finish();