[3297] | 1 | //roardl.h: |
---|
| 2 | |
---|
| 3 | /* |
---|
[5381] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2012 |
---|
[3297] | 5 | * |
---|
| 6 | * This file is part of libroar a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroar is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[3297] | 23 | * |
---|
| 24 | * NOTE for everyone want's to change something and send patches: |
---|
| 25 | * read README and HACKING! There a addition information on |
---|
| 26 | * the license of this document you need to read before you send |
---|
| 27 | * any patches. |
---|
| 28 | * |
---|
| 29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 30 | * or libpulse*: |
---|
| 31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
| 32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | #ifndef _LIBROARROARDL_H_ |
---|
| 37 | #define _LIBROARROARDL_H_ |
---|
| 38 | |
---|
| 39 | #include "libroar.h" |
---|
| 40 | |
---|
[5317] | 41 | #define ROAR_DL_FLAG_DEFAULTS -1 |
---|
[5427] | 42 | #define ROAR_DL_FLAG_PLUGIN -2 |
---|
[5317] | 43 | #define ROAR_DL_FLAG_NONE 0x0000 |
---|
| 44 | #define ROAR_DL_FLAG_STATIC 0x0001 /* plugins are linked statically -lfoo */ |
---|
[5344] | 45 | #define ROAR_DL_FLAG_LAZY 0x0002 |
---|
[5427] | 46 | #define ROAR_DL_FLAG_PLUGINPATH 0x0004 /* Use plugin search path */ |
---|
[3303] | 47 | |
---|
[3297] | 48 | #define ROAR_DL_HANDLE_DEFAULT ((struct roar_dl_lhandle*)(void*)0) |
---|
| 49 | #define ROAR_DL_HANDLE_NEXT ((struct roar_dl_lhandle*)(void*)1) |
---|
[5511] | 50 | #define ROAR_DL_HANDLE_LIBROAR ((struct roar_dl_lhandle*)(void*)2) |
---|
| 51 | #define ROAR_DL_HANDLE_APPLICATION ((struct roar_dl_lhandle*)(void*)3) |
---|
[3297] | 52 | |
---|
[5511] | 53 | #define ROAR_DL_FN_DSTR 0 /* VIO and DSTR drivers */ |
---|
| 54 | #define ROAR_DL_FN_CDRIVER 1 /* Client drivers, libroareio */ |
---|
| 55 | #define ROAR_DL_FN_TRANSCODER 2 /* Transcoder, libroardsp */ |
---|
| 56 | #define ROAR_DL_FN_DRIVER 3 /* Driver, roard? */ |
---|
| 57 | #define ROAR_DL_FN_SOURCE 4 /* Sources, roard? */ |
---|
| 58 | #define ROAR_DL_FN_FILTER 5 /* Filter, libroardsp */ |
---|
| 59 | #define ROAR_DL_FN_FF 6 /* file format??? */ |
---|
| 60 | #define ROAR_DL_FN_AUTH 7 /* Auth */ |
---|
| 61 | #define ROAR_DL_FN_BRIDGE 8 /* Bridges, roard? */ |
---|
[5734] | 62 | #define ROAR_DL_FN_ROARDSCHED 9 /* legacy, roard: Like appsched, but roard specific, old */ |
---|
| 63 | #define ROAR_DL_FN_APPSCHED 10 /* legacy: AppSched, old interface */ |
---|
| 64 | #define ROAR_DL_FN_PROTO 11 /* CPI, roard: Protocols */ |
---|
[5511] | 65 | #define ROAR_DL_FN_NOTIFY 12 /* ??? */ |
---|
[5317] | 66 | #define ROAR_DL_FN_INIT 13 /* global plugin instance init. should be avoided */ |
---|
[5511] | 67 | #define ROAR_DL_FN_REGFN 14 /* FN Registrations */ |
---|
| 68 | #define ROAR_DL_FN_APPLICATION 15 /* Application specific stuff */ |
---|
[5734] | 69 | #define ROAR_DL_FN_SERVICE 16 /* CSI: Services */ |
---|
[3299] | 70 | //#define ROAR_DL_FN_ 9 |
---|
[5275] | 71 | #define ROAR_DL_FN_MAX 24 |
---|
[3300] | 72 | |
---|
[5275] | 73 | #define ROAR_DL_LIBPARA_VERSION 1 |
---|
| 74 | #define ROAR_DL_LIBNAME_VERSION 0 |
---|
| 75 | #define ROAR_DL_LIBINST_VERSION 1 |
---|
[5347] | 76 | #define ROAR_DL_LIBDEP_VERSION 0 |
---|
[3300] | 77 | |
---|
| 78 | #define ROAR_DL_PLUGIN(lib) struct roar_dl_libraryinst * \ |
---|
[3306] | 79 | _##lib##_roaraudio_library_init(struct roar_dl_librarypara * para); \ |
---|
| 80 | struct roar_dl_libraryinst * \ |
---|
[3300] | 81 | _roaraudio_library_init(struct roar_dl_librarypara * para) { \ |
---|
| 82 | return _##lib##_roaraudio_library_init(para); \ |
---|
| 83 | } \ |
---|
| 84 | struct roar_dl_libraryinst * \ |
---|
| 85 | _##lib##_roaraudio_library_init(struct roar_dl_librarypara * para) \ |
---|
[3299] | 86 | |
---|
[3308] | 87 | #define ROAR_DL_PLUGIN_START(xlib) ROAR_DL_PLUGIN(xlib) { \ |
---|
| 88 | static int _inited = 0; \ |
---|
| 89 | static struct roar_dl_libraryinst lib; \ |
---|
[5275] | 90 | static struct roar_dl_libraryname libname; \ |
---|
[4681] | 91 | (void)para; \ |
---|
[3308] | 92 | if ( _inited ) \ |
---|
| 93 | return &lib; \ |
---|
[5501] | 94 | if ( para != NULL && \ |
---|
| 95 | (para->version != ROAR_DL_LIBPARA_VERSION || \ |
---|
| 96 | para->len < sizeof(struct roar_dl_librarypara)) ) { \ |
---|
[5512] | 97 | /* we should set ROAR_ERROR_NSVERSION here but can not */ \ |
---|
| 98 | /* because that would require the plugin to be linked */ \ |
---|
| 99 | /* aginst libroar */ \ |
---|
[5501] | 100 | return NULL; \ |
---|
| 101 | } \ |
---|
[3308] | 102 | memset(&lib, 0, sizeof(lib)); \ |
---|
| 103 | lib.version = ROAR_DL_LIBINST_VERSION; \ |
---|
| 104 | lib.len = sizeof(lib); \ |
---|
[5275] | 105 | memset(&libname, 0, sizeof(libname)); \ |
---|
| 106 | libname.version = ROAR_DL_LIBNAME_VERSION; \ |
---|
| 107 | libname.len = sizeof(libname); \ |
---|
| 108 | libname.name = #xlib; \ |
---|
| 109 | lib.libname = &libname; \ |
---|
[3308] | 110 | do |
---|
| 111 | |
---|
| 112 | #define ROAR_DL_PLUGIN_END while(0); \ |
---|
| 113 | _inited = 1; \ |
---|
| 114 | return &lib; \ |
---|
| 115 | } |
---|
| 116 | |
---|
[5335] | 117 | // general stuff: |
---|
[5275] | 118 | #define ROAR_DL_PLUGIN_ABORT_LOADING(err) roar_err_set((err)); return NULL |
---|
[5453] | 119 | #define ROAR_DL_PLUGIN_CHECK_VERSIONS(app,abi) (((lib.host_appname = (app)) != NULL) | \ |
---|
| 120 | ((lib.host_abiversion = (abi)) != NULL) ) |
---|
[5353] | 121 | // should we keep this macro at all? Is it helpfull at all? |
---|
| 122 | // if a plugin can handle multiple hosts it needs to call roar_dl_para_check_version() itself anyway. |
---|
| 123 | #define ROAR_DL_PLUGIN_CHECK_VERSIONS_NOW(app,abi) if ( roar_dl_para_check_version(para, (app), (abi)) == -1 ) return NULL |
---|
[5335] | 124 | |
---|
| 125 | // register stuff: |
---|
[3363] | 126 | #define ROAR_DL_PLUGIN_REG(fn, funcptr) (lib.func[(fn)] = (funcptr)) |
---|
[3360] | 127 | #define ROAR_DL_PLUGIN_REG_UNLOAD(func) (lib.unload = (func)) |
---|
[5317] | 128 | #define ROAR_DL_PLUGIN_REG_APPSCHED(sched) (lib.appsched = (sched)) |
---|
[5313] | 129 | #define ROAR_DL_PLUGIN_REG_GLOBAL_DATA(ptr,init) lib.global_data_len = sizeof((init)); \ |
---|
| 130 | lib.global_data_init = &(init); \ |
---|
| 131 | lib.global_data_pointer = (void*)&(ptr) |
---|
[5353] | 132 | #define ROAR_DL_PLUGIN_REG_LIBDEP(deps) (((lib.libdep = (deps)) == NULL) ? \ |
---|
[5347] | 133 | (ssize_t)-1 : \ |
---|
[5353] | 134 | (ssize_t)(lib.libdep_len = sizeof((deps))/sizeof(struct roar_dl_librarydep))) |
---|
[3314] | 135 | |
---|
[5582] | 136 | // register objects using FN: |
---|
[5578] | 137 | #define ROAR_DL_PLUGIN_REG_FN(subtype,obj,version) roar_dl_register_fn(NULL, -1, (subtype), &(obj), sizeof((obj)), (version), ROAR_DL_FNREG_OPT_NONE) |
---|
| 138 | |
---|
[5582] | 139 | // Do a FN reg callback registration: |
---|
| 140 | #define ROAR_DL_RFNREG(lhandle,obj) roar_dl_register_fn((lhandle), ROAR_DL_FN_REGFN, ROAR_DL_FNREG_SUBTYPE, &(obj), sizeof((obj)), ROAR_DL_FNREG_VERSION, ROAR_DL_FNREG_OPT_NONE) |
---|
| 141 | |
---|
[5335] | 142 | // meta data stuff: |
---|
| 143 | #define ROAR_DL_PLUGIN_META_PRODUCT(x) (libname.libname = (x)) |
---|
| 144 | #define ROAR_DL_PLUGIN_META_PRODUCT_NV(name,vendor) ROAR_DL_PLUGIN_META_PRODUCT(name " <" vendor ">") |
---|
[5338] | 145 | #define ROAR_DL_PLUGIN_META_PRODUCT_NIV_REAL(name,id,vendor) ROAR_DL_PLUGIN_META_PRODUCT(name " <" #id "/" vendor ">") |
---|
| 146 | #define ROAR_DL_PLUGIN_META_PRODUCT_NIV(name,id,vendor) ROAR_DL_PLUGIN_META_PRODUCT_NIV_REAL(name,id,vendor) |
---|
[5335] | 147 | #define ROAR_DL_PLUGIN_META_VERSION(x) (libname.libversion = (x)) |
---|
| 148 | #define ROAR_DL_PLUGIN_META_ABI(x) (libname.abiversion = (x)) |
---|
| 149 | #define ROAR_DL_PLUGIN_META_DESC(x) (libname.description = (x)) |
---|
| 150 | #define ROAR_DL_PLUGIN_META_CONTACT(x) (libname.contact = (x)) |
---|
| 151 | #define ROAR_DL_PLUGIN_META_CONTACT_FL(first,last) ROAR_DL_PLUGIN_META_CONTACT(first " " last) |
---|
| 152 | #define ROAR_DL_PLUGIN_META_CONTACT_FLE(first,last,email) ROAR_DL_PLUGIN_META_CONTACT(first " " last " <" email ">") |
---|
| 153 | #define ROAR_DL_PLUGIN_META_CONTACT_FLNE(first,last,nick,email) ROAR_DL_PLUGIN_META_CONTACT(first " \"" nick "\" " last " <" email ">") |
---|
| 154 | #define ROAR_DL_PLUGIN_META_AUTHORS(x) (libname.authors = (x)) |
---|
| 155 | #define ROAR_DL_PLUGIN_META_LICENSE(x) (libname.license = (x)) |
---|
| 156 | #define ROAR_DL_PLUGIN_META_LICENSE_TAG(x) ROAR_DL_PLUGIN_META_LICENSE(ROAR_LICENSE_ ## x) |
---|
| 157 | |
---|
[5322] | 158 | enum roar_dl_loadercmd { |
---|
[5327] | 159 | ROAR_DL_LOADER_NOOP = 0, |
---|
| 160 | ROAR_DL_LOADER_PRELOAD, |
---|
| 161 | ROAR_DL_LOADER_LOAD, |
---|
| 162 | ROAR_DL_LOADER_POSTLOAD, |
---|
| 163 | ROAR_DL_LOADER_PREUNLOAD, |
---|
| 164 | ROAR_DL_LOADER_UNLOAD, |
---|
| 165 | ROAR_DL_LOADER_POSTUNLOAD |
---|
[5322] | 166 | }; |
---|
| 167 | |
---|
[5335] | 168 | struct roar_plugincontainer; |
---|
| 169 | |
---|
[3297] | 170 | struct roar_dl_librarypara { |
---|
[5275] | 171 | int version; // version of this struct type (must be ROAR_DL_LIBPARA_VERSION) |
---|
| 172 | size_t len; // Length of this struct type (must be sizeof(struct roar_dl_librarypara) |
---|
| 173 | |
---|
| 174 | size_t refc; // Reference counter. |
---|
| 175 | |
---|
| 176 | size_t argc; // number of elements in argv |
---|
| 177 | struct roar_keyval * argv; // Parameter for the plugin |
---|
| 178 | void * args_store; // Storage area for argv's data. |
---|
| 179 | // If not NULL this and argv will be freed. |
---|
| 180 | // If NULL argv will be left untouched. |
---|
| 181 | |
---|
| 182 | void * binargv; // A pointer with binary data arguments. |
---|
| 183 | // This can be used to pass any non-string data to |
---|
| 184 | // the plugin. Normally this is NULL or the pointer |
---|
| 185 | // to a struct with members of whatever is needed. |
---|
| 186 | |
---|
| 187 | const char * appname; // application name in common format: |
---|
| 188 | // Product/Version <VendorID/VendorName> (comments) |
---|
| 189 | // Version and comment are optional and should be avoided. |
---|
| 190 | // When no vendor ID is registered use <VendorName>. |
---|
| 191 | // The VendorName MUST NOT contain a slash and SHOULD |
---|
| 192 | // be as unique as possible. |
---|
| 193 | // Examples: roard <0/RoarAudio>, MyAPP <myapp.org>, |
---|
| 194 | // AnAPP <Musterman GbR> |
---|
| 195 | const char * abiversion; // The ABI version. For libraries this should be the SONAME. |
---|
| 196 | // For applications this should be the version of the release |
---|
| 197 | // which introduced the current ABI. |
---|
| 198 | // Examples: libroar2, 0.5.1 |
---|
[5317] | 199 | struct roar_notify_core * notifycore; |
---|
[5335] | 200 | struct roar_plugincontainer * container; |
---|
| 201 | int (*loader)(struct roar_dl_librarypara * lhandle, void * loader_userdata, enum roar_dl_loadercmd cmd, void * argp); |
---|
| 202 | void * loader_userdata; |
---|
[5275] | 203 | }; |
---|
| 204 | |
---|
| 205 | struct roar_dl_libraryname { |
---|
| 206 | int version; |
---|
| 207 | size_t len; |
---|
| 208 | const char * name; //Format: shortname |
---|
[5317] | 209 | const char * libname; //This is the same as appname in struct roar_dl_librarypara. |
---|
| 210 | //Format: Product <VendorID/VendorName> (comments) |
---|
| 211 | const char * libversion; //This is the pure version number of the library. |
---|
| 212 | const char * abiversion; //This is the same as abiversion in struct roar_dl_librarypara. |
---|
| 213 | //Format: Version |
---|
[5275] | 214 | const char * description; //Free form. |
---|
| 215 | const char * contact; //Format: first ["']nick["'] last (comment) <email>/OpenPGPkey/Phone/Room |
---|
| 216 | const char * authors; //Other authors as free form. |
---|
| 217 | const char * license; //Format: LicenseName-Version (options) |
---|
| 218 | //Examples: GPL-3.0, LGPL-2.1, LGPL-3.0 (or later). |
---|
[3297] | 219 | }; |
---|
| 220 | |
---|
[5317] | 221 | struct roar_dl_librarydep { |
---|
| 222 | int version; |
---|
| 223 | size_t len; |
---|
[5335] | 224 | uint32_t flags; |
---|
[5317] | 225 | const char * name; |
---|
| 226 | const char * libname; |
---|
| 227 | const char * abiversion; |
---|
| 228 | }; |
---|
| 229 | |
---|
[5347] | 230 | #define ROAR_DL_DEP(__flags,__name,__libname,__abiversion) \ |
---|
| 231 | {.version = ROAR_DL_LIBDEP_VERSION, \ |
---|
| 232 | .len = sizeof(struct roar_dl_librarydep), \ |
---|
| 233 | .flags = __flags, \ |
---|
| 234 | .name = __name, \ |
---|
| 235 | .libname = __libname, \ |
---|
| 236 | .abiversion = __abiversion} |
---|
| 237 | |
---|
[3297] | 238 | struct roar_dl_libraryinst { |
---|
[3299] | 239 | int version; |
---|
| 240 | size_t len; |
---|
[3301] | 241 | int (*unload)(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); |
---|
[3299] | 242 | int (*func[ROAR_DL_FN_MAX])(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); |
---|
[5275] | 243 | struct roar_dl_libraryname * libname; |
---|
[5312] | 244 | size_t global_data_len; |
---|
| 245 | void * global_data_init; |
---|
| 246 | void ** global_data_pointer; |
---|
[5317] | 247 | struct roar_dl_librarydep * libdep; |
---|
| 248 | size_t libdep_len; |
---|
| 249 | struct roar_dl_appsched * appsched; |
---|
[5353] | 250 | const char * host_appname; |
---|
| 251 | const char * host_abiversion; |
---|
[3297] | 252 | }; |
---|
| 253 | |
---|
[5313] | 254 | struct roar_dl_appsched { |
---|
[5317] | 255 | int (*init) (struct roar_dl_librarypara * para); |
---|
| 256 | int (*free) (struct roar_dl_librarypara * para); |
---|
| 257 | int (*update)(struct roar_dl_librarypara * para); |
---|
[5335] | 258 | int (*tick) (struct roar_dl_librarypara * para); |
---|
| 259 | int (*wait) (struct roar_dl_librarypara * para); |
---|
[5317] | 260 | }; |
---|
| 261 | |
---|
| 262 | enum roar_dl_appsched_trigger { |
---|
| 263 | ROAR_DL_APPSCHED_INIT = 1, |
---|
| 264 | #define ROAR_DL_APPSCHED_INIT ROAR_DL_APPSCHED_INIT |
---|
| 265 | ROAR_DL_APPSCHED_FREE, |
---|
| 266 | #define ROAR_DL_APPSCHED_FREE ROAR_DL_APPSCHED_FREE |
---|
[5335] | 267 | ROAR_DL_APPSCHED_UPDATE, |
---|
[5317] | 268 | #define ROAR_DL_APPSCHED_UPDATE ROAR_DL_APPSCHED_UPDATE |
---|
[5335] | 269 | ROAR_DL_APPSCHED_TICK, |
---|
| 270 | #define ROAR_DL_APPSCHED_TICK ROAR_DL_APPSCHED_TICK |
---|
| 271 | ROAR_DL_APPSCHED_WAIT |
---|
| 272 | #define ROAR_DL_APPSCHED_WAIT ROAR_DL_APPSCHED_WAIT |
---|
[5313] | 273 | }; |
---|
| 274 | |
---|
[5312] | 275 | // parameter functions: |
---|
[5275] | 276 | struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv, |
---|
| 277 | const char * appname, const char * abiversion); |
---|
| 278 | int roar_dl_para_ref (struct roar_dl_librarypara * para); |
---|
| 279 | int roar_dl_para_unref (struct roar_dl_librarypara * para); |
---|
| 280 | int roar_dl_para_check_version (struct roar_dl_librarypara * para, |
---|
| 281 | const char * appname, const char * abiversion); |
---|
| 282 | |
---|
[5312] | 283 | // 'core' dynamic loader functions. |
---|
[5275] | 284 | struct roar_dl_lhandle * roar_dl_open (const char * filename, int flags, |
---|
| 285 | int ra_init, struct roar_dl_librarypara * para); |
---|
[5321] | 286 | int roar_dl_ref (struct roar_dl_lhandle * lhandle); |
---|
| 287 | int roar_dl_unref (struct roar_dl_lhandle * lhandle); |
---|
| 288 | #define roar_dl_close(x) roar_dl_unref((x)) |
---|
[3301] | 289 | |
---|
[5275] | 290 | void * roar_dl_getsym (struct roar_dl_lhandle * lhandle, const char * sym, int type); |
---|
[3297] | 291 | |
---|
[5275] | 292 | int roar_dl_ra_init(struct roar_dl_lhandle * lhandle, |
---|
| 293 | const char * prefix, |
---|
| 294 | struct roar_dl_librarypara * para); |
---|
[3297] | 295 | |
---|
[5275] | 296 | const char * roar_dl_errstr (struct roar_dl_lhandle * lhandle); |
---|
[3297] | 297 | |
---|
[5312] | 298 | // getting meta data: |
---|
[5275] | 299 | struct roar_dl_librarypara * roar_dl_getpara(struct roar_dl_lhandle * lhandle); |
---|
| 300 | const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle); |
---|
[3364] | 301 | |
---|
[5312] | 302 | // context switching: |
---|
| 303 | // _restore() is to switch from main to library context. _store() is to store library context |
---|
| 304 | // and switch back to main context. |
---|
| 305 | int roar_dl_context_restore(struct roar_dl_lhandle * lhandle); |
---|
| 306 | int roar_dl_context_store(struct roar_dl_lhandle * lhandle); |
---|
| 307 | |
---|
[5317] | 308 | // appsched: |
---|
| 309 | int roar_dl_appsched_trigger(struct roar_dl_lhandle * lhandle, enum roar_dl_appsched_trigger trigger); |
---|
| 310 | |
---|
[5511] | 311 | // FN Registration: |
---|
| 312 | |
---|
| 313 | // Actions objects can emit: |
---|
| 314 | enum roar_dl_fnreg_action { |
---|
| 315 | ROAR_DL_FNREG = 1, // The object is been registered |
---|
| 316 | ROAR_DL_FNUNREG = 2 // The object is been unregistered |
---|
| 317 | }; |
---|
| 318 | |
---|
| 319 | // Callback for registering/unregistering objects: |
---|
| 320 | struct roar_dl_fnreg { |
---|
| 321 | int fn; // Filter: The FN of the registering object or -1 for any. |
---|
| 322 | int subtype; // Filter: The subtype of the registering object or -1 for any. |
---|
| 323 | int version; // Filter: The version of the registering object or -1 for any. |
---|
| 324 | int (*callback)( // Callback to call on register/unregister. |
---|
| 325 | enum roar_dl_fnreg_action action, // The action happening |
---|
| 326 | int fn, // The FN of the object |
---|
| 327 | int subtype, // The subtype of the object |
---|
| 328 | const void * object, // Pointer to the object |
---|
| 329 | size_t objectlen, // Length of the object |
---|
| 330 | int version, // Version of the object |
---|
| 331 | int options, // Object Options. |
---|
| 332 | void * userdata, // User data for the callback. |
---|
| 333 | struct roar_dl_lhandle * lhandle // The registering handle. |
---|
| 334 | // This is valid until the object is unregistered. |
---|
[5606] | 335 | // Only roar_dl_context_restore(), roar_dl_context_store() |
---|
| 336 | // and roar_dl_getpara() may be used on this object. |
---|
| 337 | // Result of all other functions is undefined. |
---|
[5511] | 338 | ); |
---|
| 339 | void * userdata; // The user data pointer passed to the callback. |
---|
| 340 | }; |
---|
| 341 | |
---|
| 342 | // Parameters for FNREG registration: |
---|
| 343 | #define ROAR_DL_FNREG_SUBTYPE 0 |
---|
| 344 | #define ROAR_DL_FNREG_VERSION 0 |
---|
| 345 | #define ROAR_DL_FNREG_SIZE sizeof(struct roar_dl_fnreg) |
---|
| 346 | |
---|
| 347 | |
---|
[5736] | 348 | // Common protocol interface (CPI): |
---|
[5576] | 349 | struct roar_dl_proto { |
---|
| 350 | const int proto; |
---|
| 351 | const char * description; |
---|
| 352 | const int flags; |
---|
[5606] | 353 | int (*set_proto)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 354 | int (*unset_proto)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 355 | int (*handle)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 356 | int (*flush)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 357 | int (*flushed)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
| 358 | int (*status)(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); |
---|
[5576] | 359 | }; |
---|
| 360 | |
---|
| 361 | #define ROAR_DL_PROTO_FLAGS_NONE 0 |
---|
| 362 | |
---|
| 363 | #define ROAR_DL_PROTO_STATUS_RX_READY 0x0001 |
---|
| 364 | #define ROAR_DL_PROTO_STATUS_TX_READY 0x0002 |
---|
| 365 | #define ROAR_DL_PROTO_STATUS_WAIT_NOTIFY 0x0004 |
---|
| 366 | |
---|
| 367 | // Parameters for FNREG registration: |
---|
| 368 | #define ROAR_DL_PROTO_SUBTYPE 1 /* 0 = roard */ |
---|
| 369 | #define ROAR_DL_PROTO_VERSION 0 |
---|
| 370 | #define ROAR_DL_PROTO_SIZE sizeof(struct roar_dl_proto) |
---|
| 371 | |
---|
[5735] | 372 | |
---|
| 373 | // Common Service Interface (CSI): |
---|
| 374 | struct roar_dl_service { |
---|
| 375 | // Name and ABI version of the application: |
---|
| 376 | // if appname is NULL this is a /universal/ service. |
---|
| 377 | // Such services MUST use APIs defined by the RoarAudio Project. |
---|
| 378 | // If a random Vendor needs a API universal to own applications |
---|
| 379 | // it should define a virtual application name for this. |
---|
| 380 | const char * appname; |
---|
| 381 | const char * appabi; |
---|
| 382 | // Name and ABI/API version of service: |
---|
| 383 | const char * servicename; |
---|
| 384 | const char * serviceabi; |
---|
| 385 | // Description: |
---|
| 386 | const char * description; |
---|
| 387 | // Flags (see below for defined flags): |
---|
| 388 | const int flags; |
---|
| 389 | // Userdata: |
---|
| 390 | // This is some kind of constant data. |
---|
| 391 | // It can bed used ba the functions below for internal stuff. |
---|
[5768] | 392 | const void * userdata; |
---|
[5735] | 393 | // Functions: |
---|
| 394 | // get_api returns a pointer to a struct with the API. |
---|
| 395 | // The api is specific to [appname, appabi, servicename, serviceabi]. |
---|
[5769] | 396 | const void * (*get_api)(const struct roar_dl_service * service, struct roar_dl_librarypara * para); |
---|
[5735] | 397 | }; |
---|
| 398 | |
---|
| 399 | #define ROAR_DL_SERVICE_FLAGS_NONE 0x0000 |
---|
| 400 | |
---|
| 401 | #define ROAR_DL_SERVICE_SUBTYPE 0 |
---|
| 402 | #define ROAR_DL_SERVICE_VERSION 0 |
---|
| 403 | #define ROAR_DL_SERVICE_SIZE sizeof(struct roar_dl_service) |
---|
| 404 | |
---|
[5511] | 405 | // Reg FN: |
---|
| 406 | |
---|
| 407 | // Options: |
---|
| 408 | #define ROAR_DL_FNREG_OPT_NONE 0 /* no options */ |
---|
| 409 | |
---|
| 410 | // Register an FN. |
---|
| 411 | int roar_dl_register_fn(struct roar_dl_lhandle * lhandle, int fn, int subtype, const void * object, size_t objectlen, int version, int options); |
---|
| 412 | |
---|
| 413 | // Unregister FN for the given plugin. |
---|
| 414 | // This should not be called directly and is called internally when needed. |
---|
| 415 | int roar_dl_unregister_fn(struct roar_dl_lhandle * lhandle); |
---|
| 416 | |
---|
[3297] | 417 | #endif |
---|
| 418 | |
---|
| 419 | //ll |
---|