4 * Plugin declarations and support.
6 * Note plugins mainly exist to make binary packagers' lives easier,
8 * Copyright (c) 2009 Nathan Keynes.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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.
21 #ifndef lxdream_plugin_H
22 #define lxdream_plugin_H
32 PLUGIN_AUDIO_DRIVER = 1,
33 PLUGIN_INPUT_DRIVER = 2,
36 #define PLUGIN_MIN_TYPE 1
37 #define PLUGIN_MAX_TYPE PLUGIN_INPUT_DRIVER
39 struct plugin_struct {
40 enum plugin_type type;
45 * Plugin registration function, called at load time (dynamic modules) or
46 * startup (static modules). This should register with the appropriate
48 * @return TRUE on success, FALSE on failure (although exactly how this
49 * can fail is unclear).
51 gboolean (*register_plugin)(void);
54 #define CONSTRUCTOR __attribute__((constructor))
57 #define DEFINE_PLUGIN(type,name,fn) struct plugin_struct lxdream_plugin_entry = { type, name, VERSION, fn }
58 #define AUDIO_DRIVER(name, driver) static gboolean __lxdream_plugin_init(void) { return audio_register_driver(&(driver)); } \
59 DEFINE_PLUGIN(PLUGIN_AUDIO_DRIVER, name, __lxdream_plugin_init)
61 #else /* !ENABLE_SHARED */
62 #define AUDIO_DRIVER(name,driver) static void CONSTRUCTOR __lxdream_static_constructor(void) { audio_register_driver(&(driver)); }
63 #define DEFINE_PLUGIN(type,name,fn) static void CONSTRUCTOR __lxdream_static_constructor(void) { fn(); }
65 #endif /* ENABLE_SHARED */
67 gboolean plugin_init(const gchar *path);
73 #endif /* !lxdream_plugin_H */
.