Search
lxdream.org :: lxdream/src/plugin.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/plugin.h
changeset 1024:c67f2d61ab97
next1027:4e527bc96109
author nkeynes
date Sat Jun 13 00:50:48 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Build drivers with library dependencies as shared objects (ie plugins)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/plugin.h Sat Jun 13 00:50:48 2009 +0000
1.3 @@ -0,0 +1,73 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Plugin declarations and support.
1.8 + *
1.9 + * Note plugins mainly exist to make binary packagers' lives easier,
1.10 + *
1.11 + * Copyright (c) 2009 Nathan Keynes.
1.12 + *
1.13 + * This program is free software; you can redistribute it and/or modify
1.14 + * it under the terms of the GNU General Public License as published by
1.15 + * the Free Software Foundation; either version 2 of the License, or
1.16 + * (at your option) any later version.
1.17 + *
1.18 + * This program is distributed in the hope that it will be useful,
1.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.21 + * GNU General Public License for more details.
1.22 + */
1.23 +
1.24 +#ifndef lxdream_plugin_H
1.25 +#define lxdream_plugin_H
1.26 +
1.27 +#include "lxdream.h"
1.28 +
1.29 +#ifdef __cplusplus
1.30 +extern "C" {
1.31 +#endif
1.32 +
1.33 +enum plugin_type {
1.34 + PLUGIN_NONE = 0,
1.35 + PLUGIN_AUDIO_DRIVER = 1,
1.36 + PLUGIN_INPUT_DRIVER = 2,
1.37 +};
1.38 +
1.39 +#define PLUGIN_MIN_TYPE 1
1.40 +#define PLUGIN_MAX_TYPE PLUGIN_INPUT_DRIVER
1.41 +
1.42 +struct plugin_struct {
1.43 + enum plugin_type type;
1.44 + const char *name;
1.45 + const char *version;
1.46 +
1.47 + /**
1.48 + * Plugin registration function, called at load time (dynamic modules) or
1.49 + * startup (static modules). This should register with the appropriate
1.50 + * driver list.
1.51 + * @return TRUE on success, FALSE on failure (although exactly how this
1.52 + * can fail is unclear).
1.53 + */
1.54 + gboolean (*register_plugin)(void);
1.55 +};
1.56 +
1.57 +#define CONSTRUCTOR __attribute__((constructor))
1.58 +
1.59 +#ifdef PLUGIN
1.60 +#define DEFINE_PLUGIN(type,name,fn) struct plugin_struct lxdream_plugin_entry = { type, name, VERSION, fn }
1.61 +#define AUDIO_DRIVER(name, driver) static gboolean __lxdream_plugin_init(void) { return audio_register_driver(&(driver)); } \
1.62 + DEFINE_PLUGIN(PLUGIN_AUDIO_DRIVER, name, __lxdream_plugin_init)
1.63 +
1.64 +#else /* !ENABLE_SHARED */
1.65 +#define AUDIO_DRIVER(name,driver) static void CONSTRUCTOR __lxdream_static_constructor(void) { audio_register_driver(&(driver)); }
1.66 +#define DEFINE_PLUGIN(type,name,fn) static void CONSTRUCTOR __lxdream_static_constructor(void) { fn(); }
1.67 +
1.68 +#endif /* ENABLE_SHARED */
1.69 +
1.70 +gboolean plugin_init(const gchar *path);
1.71 +
1.72 +#ifdef __cplusplus
1.73 +}
1.74 +#endif
1.75 +
1.76 +#endif /* !lxdream_plugin_H */
1.77 \ No newline at end of file
.