Search
lxdream.org :: lxdream/src/plugin.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/plugin.h
changeset 1169:23a9613aceb1
prev1027:4e527bc96109
author nkeynes
date Wed Feb 04 08:38:23 2015 +1000 (9 years ago)
permissions -rw-r--r--
last change Fix assorted compile warnings reported by Clang
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Plugin declarations and support. 
     5  * 
     6  * Note plugins mainly exist to make binary packagers' lives easier, 
     7  *
     8  * Copyright (c) 2009 Nathan Keynes.
     9  *
    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.
    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  */
    21 #ifndef lxdream_plugin_H
    22 #define lxdream_plugin_H
    24 #include "lxdream.h"
    26 #ifdef __cplusplus
    27 extern "C" {
    28 #endif
    30 enum plugin_type {
    31     PLUGIN_NONE = 0,
    32     PLUGIN_AUDIO_DRIVER = 1,
    33     PLUGIN_INPUT_DRIVER = 2,
    34 };
    36 #define PLUGIN_MIN_TYPE 1
    37 #define PLUGIN_MAX_TYPE PLUGIN_INPUT_DRIVER
    39 struct plugin_struct {
    40     enum plugin_type type;
    41     const char *name;
    42     const char *version;
    44     /**
    45      * Plugin registration function, called at load time (dynamic modules) or 
    46      * startup (static modules). This should register with the appropriate 
    47      * driver list. 
    48      * @return TRUE on success, FALSE on failure (although exactly how this 
    49      * can fail is unclear).
    50      */
    51     gboolean (*register_plugin)(void);
    52 };
    54 #define CONSTRUCTOR __attribute__((constructor))
    56 #ifdef PLUGIN
    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();
    69 #ifdef __cplusplus
    70 }
    71 #endif
    73 #endif /* !lxdream_plugin_H */
.