source: roaraudio/include/libroar/roardl.h @ 5836:81ccac5ddc61

Last change on this file since 5836:81ccac5ddc61 was 5836:81ccac5ddc61, checked in by phi, 11 years ago

Added half of the support for AppSched? Triggers ABOUT, HELP and PREFERENCES. This includes support in roarpluginrunner

File size: 24.7 KB
RevLine 
[3297]1//roardl.h:
2
3/*
[5823]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2013
[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)
[5770]52#define ROAR_DL_HANDLE_LIB              ((struct roar_dl_lhandle*)(void*)4)
[3297]53
[5819]54#define LIBROAR_DL_APPNAME              "libroar " ROAR_VSTR_ROARAUDIO
55#define LIBROAR_DL_ABIVERSION           "1.0beta9"
56
[5511]57#define ROAR_DL_FN_DSTR                 0 /* VIO and DSTR drivers */
58#define ROAR_DL_FN_CDRIVER              1 /* Client drivers, libroareio */
59#define ROAR_DL_FN_TRANSCODER           2 /* Transcoder, libroardsp */
60#define ROAR_DL_FN_DRIVER               3 /* Driver, roard? */
61#define ROAR_DL_FN_SOURCE               4 /* Sources, roard? */
62#define ROAR_DL_FN_FILTER               5 /* Filter, libroardsp */
63#define ROAR_DL_FN_FF                   6 /* file format??? */
64#define ROAR_DL_FN_AUTH                 7 /* Auth */
65#define ROAR_DL_FN_BRIDGE               8 /* Bridges, roard? */
[5734]66#define ROAR_DL_FN_ROARDSCHED           9 /* legacy, roard: Like appsched, but roard specific, old */
67#define ROAR_DL_FN_APPSCHED            10 /* legacy: AppSched, old interface */
68#define ROAR_DL_FN_PROTO               11 /* CPI, roard: Protocols */
[5511]69#define ROAR_DL_FN_NOTIFY              12 /* ??? */
[5317]70#define ROAR_DL_FN_INIT                13 /* global plugin instance init. should be avoided */
[5511]71#define ROAR_DL_FN_REGFN               14 /* FN Registrations */
72#define ROAR_DL_FN_APPLICATION         15 /* Application specific stuff */
[5734]73#define ROAR_DL_FN_SERVICE             16 /* CSI: Services */
[3299]74//#define ROAR_DL_FN_               9
[5275]75#define ROAR_DL_FN_MAX                 24
[3300]76
[5275]77#define ROAR_DL_LIBPARA_VERSION         1
78#define ROAR_DL_LIBNAME_VERSION         0
79#define ROAR_DL_LIBINST_VERSION         1
[5347]80#define ROAR_DL_LIBDEP_VERSION          0
[3300]81
82#define ROAR_DL_PLUGIN(lib) struct roar_dl_libraryinst *                                          \
[3306]83                             _##lib##_roaraudio_library_init(struct roar_dl_librarypara * para);  \
84                            struct roar_dl_libraryinst *                                          \
[3300]85                             _roaraudio_library_init(struct roar_dl_librarypara * para) {         \
86                              return _##lib##_roaraudio_library_init(para);                       \
87                            }                                                                     \
88                            struct roar_dl_libraryinst *                                          \
89                             _##lib##_roaraudio_library_init(struct roar_dl_librarypara * para)   \
[3299]90
[3308]91#define ROAR_DL_PLUGIN_START(xlib) ROAR_DL_PLUGIN(xlib) {                                         \
92                                     static int _inited = 0;                                      \
93                                     static struct roar_dl_libraryinst lib;                       \
[5275]94                                     static struct roar_dl_libraryname libname;                   \
[4681]95                                     (void)para;                                                  \
[3308]96                                     if ( _inited )                                               \
97                                      return &lib;                                                \
[5501]98                                     if ( para != NULL &&                                         \
99                                          (para->version != ROAR_DL_LIBPARA_VERSION ||            \
100                                           para->len < sizeof(struct roar_dl_librarypara)) ) {    \
[5512]101                                      /* we should set ROAR_ERROR_NSVERSION here but can not */   \
102                                      /* because that would require the plugin to be linked */    \
103                                      /* aginst libroar */                                        \
[5501]104                                      return NULL;                                                \
105                                     }                                                            \
[3308]106                                     memset(&lib, 0, sizeof(lib));                                \
107                                     lib.version = ROAR_DL_LIBINST_VERSION;                       \
108                                     lib.len     = sizeof(lib);                                   \
[5275]109                                     memset(&libname, 0, sizeof(libname));                        \
110                                     libname.version = ROAR_DL_LIBNAME_VERSION;                   \
111                                     libname.len     = sizeof(libname);                           \
112                                     libname.name = #xlib;                                        \
113                                     lib.libname  = &libname;                                     \
[3308]114                                     do
115
116#define ROAR_DL_PLUGIN_END          while(0);                                                     \
117                                    _inited = 1;                                                  \
118                                    return &lib;                                                  \
119                                   }
120
[5335]121// general stuff:
[5275]122#define ROAR_DL_PLUGIN_ABORT_LOADING(err) roar_err_set((err)); return NULL
[5453]123#define ROAR_DL_PLUGIN_CHECK_VERSIONS(app,abi) (((lib.host_appname = (app))    != NULL) | \
124                                                ((lib.host_abiversion = (abi)) != NULL) )
[5353]125// should we keep this macro at all? Is it helpfull at all?
126// if a plugin can handle multiple hosts it needs to call roar_dl_para_check_version() itself anyway.
127#define ROAR_DL_PLUGIN_CHECK_VERSIONS_NOW(app,abi) if ( roar_dl_para_check_version(para, (app), (abi)) == -1 ) return NULL
[5335]128
129// register stuff:
[3363]130#define ROAR_DL_PLUGIN_REG(fn, funcptr) (lib.func[(fn)] = (funcptr))
[3360]131#define ROAR_DL_PLUGIN_REG_UNLOAD(func) (lib.unload = (func))
[5317]132#define ROAR_DL_PLUGIN_REG_APPSCHED(sched) (lib.appsched = (sched))
[5313]133#define ROAR_DL_PLUGIN_REG_GLOBAL_DATA(ptr,init) lib.global_data_len = sizeof((init)); \
134                                                 lib.global_data_init = &(init);       \
135                                                 lib.global_data_pointer = (void*)&(ptr)
[5353]136#define ROAR_DL_PLUGIN_REG_LIBDEP(deps) (((lib.libdep = (deps)) == NULL) ? \
[5347]137                                           (ssize_t)-1 : \
[5353]138                                           (ssize_t)(lib.libdep_len = sizeof((deps))/sizeof(struct roar_dl_librarydep)))
[3314]139
[5582]140// register objects using FN:
[5578]141#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)
[5814]142#define ROAR_DL_PLUGIN_REG_FNFUNC(fn) ROAR_DL_PLUGIN_REG((fn), _roaraudio_library_ ## fn)
[5578]143
[5582]144// Do a FN reg callback registration:
145#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)
146
[5335]147// meta data stuff:
148#define ROAR_DL_PLUGIN_META_PRODUCT(x)      (libname.libname     = (x))
149#define ROAR_DL_PLUGIN_META_PRODUCT_NV(name,vendor)      ROAR_DL_PLUGIN_META_PRODUCT(name " <" vendor ">")
[5338]150#define ROAR_DL_PLUGIN_META_PRODUCT_NIV_REAL(name,id,vendor)  ROAR_DL_PLUGIN_META_PRODUCT(name " <" #id "/" vendor ">")
151#define ROAR_DL_PLUGIN_META_PRODUCT_NIV(name,id,vendor)  ROAR_DL_PLUGIN_META_PRODUCT_NIV_REAL(name,id,vendor)
[5335]152#define ROAR_DL_PLUGIN_META_VERSION(x)      (libname.libversion  = (x))
153#define ROAR_DL_PLUGIN_META_ABI(x)          (libname.abiversion  = (x))
154#define ROAR_DL_PLUGIN_META_DESC(x)         (libname.description = (x))
155#define ROAR_DL_PLUGIN_META_CONTACT(x)      (libname.contact = (x))
156#define ROAR_DL_PLUGIN_META_CONTACT_FL(first,last)        ROAR_DL_PLUGIN_META_CONTACT(first " " last)
157#define ROAR_DL_PLUGIN_META_CONTACT_FLE(first,last,email) ROAR_DL_PLUGIN_META_CONTACT(first " " last " <" email ">")
158#define ROAR_DL_PLUGIN_META_CONTACT_FLNE(first,last,nick,email) ROAR_DL_PLUGIN_META_CONTACT(first " \"" nick "\" " last " <" email ">")
159#define ROAR_DL_PLUGIN_META_AUTHORS(x)      (libname.authors = (x))
160#define ROAR_DL_PLUGIN_META_LICENSE(x)      (libname.license = (x))
161#define ROAR_DL_PLUGIN_META_LICENSE_TAG(x)  ROAR_DL_PLUGIN_META_LICENSE(ROAR_LICENSE_ ## x)
162
[5322]163enum roar_dl_loadercmd {
[5327]164 ROAR_DL_LOADER_NOOP = 0,
165 ROAR_DL_LOADER_PRELOAD,
166 ROAR_DL_LOADER_LOAD,
167 ROAR_DL_LOADER_POSTLOAD,
168 ROAR_DL_LOADER_PREUNLOAD,
169 ROAR_DL_LOADER_UNLOAD,
170 ROAR_DL_LOADER_POSTUNLOAD
[5322]171};
172
[5335]173struct roar_plugincontainer;
174
[3297]175struct roar_dl_librarypara {
[5275]176 int version;               // version of this struct type (must be ROAR_DL_LIBPARA_VERSION)
177 size_t len;                // Length of this struct type (must be sizeof(struct roar_dl_librarypara)
178
179 size_t refc;               // Reference counter.
180
181 size_t argc;               // number of elements in argv
182 struct roar_keyval * argv; // Parameter for the plugin
183 void * args_store;         // Storage area for argv's data.
184                            // If not NULL this and argv will be freed.
185                            // If NULL argv will be left untouched.
186
187 void * binargv;            // A pointer with binary data arguments.
188                            // This can be used to pass any non-string data to
189                            // the plugin. Normally this is NULL or the pointer
190                            // to a struct with members of whatever is needed.
191
192 const char * appname;      // application name in common format:
193                            // Product/Version <VendorID/VendorName> (comments)
194                            // Version and comment are optional and should be avoided.
195                            // When no vendor ID is registered use <VendorName>.
196                            // The VendorName MUST NOT contain a slash and SHOULD
197                            // be as unique as possible.
198                            // Examples: roard <0/RoarAudio>, MyAPP <myapp.org>,
199                            //           AnAPP <Musterman GbR>
200 const char * abiversion;   // The ABI version. For libraries this should be the SONAME.
201                            // For applications this should be the version of the release
202                            // which introduced the current ABI.
203                            // Examples: libroar2, 0.5.1
[5317]204 struct roar_notify_core * notifycore;
[5335]205 struct roar_plugincontainer * container;
206 int (*loader)(struct roar_dl_librarypara * lhandle, void * loader_userdata, enum roar_dl_loadercmd cmd, void * argp);
207 void * loader_userdata;
[5275]208};
209
210struct roar_dl_libraryname {
211 int      version;
212 size_t   len;
213 const char * name;        //Format: shortname
[5317]214 const char * libname;     //This is the same as appname in struct roar_dl_librarypara.
215                           //Format: Product <VendorID/VendorName> (comments)
216 const char * libversion;  //This is the pure version number of the library.
217 const char * abiversion;  //This is the same as abiversion in struct roar_dl_librarypara.
218                           //Format: Version
[5275]219 const char * description; //Free form.
220 const char * contact;     //Format: first ["']nick["'] last (comment) <email>/OpenPGPkey/Phone/Room
221 const char * authors;     //Other authors as free form.
222 const char * license;     //Format: LicenseName-Version (options)
223                           //Examples: GPL-3.0, LGPL-2.1, LGPL-3.0 (or later).
[3297]224};
225
[5317]226struct roar_dl_librarydep {
227 int      version;
228 size_t   len;
[5335]229 uint32_t flags;
[5317]230 const char * name;
231 const char * libname;
232 const char * abiversion;
233};
234
[5347]235#define ROAR_DL_DEP(__flags,__name,__libname,__abiversion) \
236                                                   {.version    = ROAR_DL_LIBDEP_VERSION,            \
237                                                    .len        = sizeof(struct roar_dl_librarydep), \
238                                                    .flags      = __flags,                           \
239                                                    .name       = __name,                            \
240                                                    .libname    = __libname,                         \
241                                                    .abiversion = __abiversion}
242
[3297]243struct roar_dl_libraryinst {
[3299]244 int      version;
245 size_t   len;
[3301]246 int    (*unload)(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib);
[3299]247 int    (*func[ROAR_DL_FN_MAX])(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib);
[5275]248 struct roar_dl_libraryname * libname;
[5312]249 size_t  global_data_len;
250 void *  global_data_init;
251 void ** global_data_pointer;
[5317]252 struct roar_dl_librarydep * libdep;
253 size_t libdep_len;
254 struct roar_dl_appsched * appsched;
[5353]255 const char * host_appname;
256 const char * host_abiversion;
[3297]257};
258
[5313]259struct roar_dl_appsched {
[5317]260 int (*init)  (struct roar_dl_librarypara * para);
261 int (*free)  (struct roar_dl_librarypara * para);
262 int (*update)(struct roar_dl_librarypara * para);
[5335]263 int (*tick)  (struct roar_dl_librarypara * para);
264 int (*wait)  (struct roar_dl_librarypara * para);
[5317]265};
266
267enum roar_dl_appsched_trigger {
268 ROAR_DL_APPSCHED_INIT = 1,
269#define ROAR_DL_APPSCHED_INIT ROAR_DL_APPSCHED_INIT
270 ROAR_DL_APPSCHED_FREE,
271#define ROAR_DL_APPSCHED_FREE ROAR_DL_APPSCHED_FREE
[5335]272 ROAR_DL_APPSCHED_UPDATE,
[5317]273#define ROAR_DL_APPSCHED_UPDATE ROAR_DL_APPSCHED_UPDATE
[5335]274 ROAR_DL_APPSCHED_TICK,
275#define ROAR_DL_APPSCHED_TICK ROAR_DL_APPSCHED_TICK
[5836]276 ROAR_DL_APPSCHED_WAIT,
[5335]277#define ROAR_DL_APPSCHED_WAIT ROAR_DL_APPSCHED_WAIT
[5836]278 ROAR_DL_APPSCHED_ABOUT,
279#define ROAR_DL_APPSCHED_ABOUT ROAR_DL_APPSCHED_ABOUT
280 ROAR_DL_APPSCHED_HELP,
281#define ROAR_DL_APPSCHED_HELP ROAR_DL_APPSCHED_HELP
282 ROAR_DL_APPSCHED_PREFERENCES
283#define ROAR_DL_APPSCHED_PREFERENCES ROAR_DL_APPSCHED_PREFERENCES
[5313]284};
285
[5312]286// parameter functions:
[5275]287struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv,
288                                              const char * appname, const char * abiversion);
289int roar_dl_para_ref                    (struct roar_dl_librarypara * para);
290int roar_dl_para_unref                  (struct roar_dl_librarypara * para);
291int roar_dl_para_check_version          (struct roar_dl_librarypara * para,
292                                         const char * appname, const char * abiversion);
293
[5312]294// 'core' dynamic loader functions.
[5275]295struct roar_dl_lhandle * roar_dl_open   (const char * filename, int flags,
296                                         int ra_init, struct roar_dl_librarypara * para);
[5321]297int                      roar_dl_ref    (struct roar_dl_lhandle * lhandle);
298int                      roar_dl_unref  (struct roar_dl_lhandle * lhandle);
299#define roar_dl_close(x) roar_dl_unref((x))
[3301]300
[5275]301void                   * roar_dl_getsym (struct roar_dl_lhandle * lhandle, const char * sym, int type);
[3297]302
[5275]303int                      roar_dl_ra_init(struct roar_dl_lhandle * lhandle,
304                                         const char * prefix,
305                                         struct roar_dl_librarypara * para);
[3297]306
[5275]307const char *             roar_dl_errstr (struct roar_dl_lhandle * lhandle);
[3297]308
[5312]309// getting meta data:
[5275]310struct roar_dl_librarypara       * roar_dl_getpara(struct roar_dl_lhandle * lhandle);
311const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle);
[3364]312
[5312]313// context switching:
314// _restore() is to switch from main to library context. _store() is to store library context
315// and switch back to main context.
316int                      roar_dl_context_restore(struct roar_dl_lhandle * lhandle);
317int                      roar_dl_context_store(struct roar_dl_lhandle * lhandle);
318
[5317]319// appsched:
320int                      roar_dl_appsched_trigger(struct roar_dl_lhandle * lhandle, enum roar_dl_appsched_trigger trigger);
321
[5511]322// FN Registration:
323
324// Actions objects can emit:
325enum roar_dl_fnreg_action {
[5809]326 ROAR_DL_FNREG   = 1, // The object is being registered
327 ROAR_DL_FNUNREG = 2  // The object is being unregistered
[5511]328};
329
330// Callback for registering/unregistering objects:
331struct roar_dl_fnreg {
332 int fn;          // Filter: The FN of the registering object or -1 for any.
333 int subtype;     // Filter: The subtype of the registering object or -1 for any.
334 int version;     // Filter: The version of the registering object or -1 for any.
335 int (*callback)( // Callback to call on register/unregister.
336   enum roar_dl_fnreg_action action, // The action happening
337   int fn,                           // The FN of the object
338   int subtype,                      // The subtype of the object
339   const void * object,              // Pointer to the object
340   size_t objectlen,                 // Length of the object
341   int version,                      // Version of the object
342   int options,                      // Object Options.
343   void * userdata,                  // User data for the callback.
344   struct roar_dl_lhandle * lhandle  // The registering handle.
345                                     // This is valid until the object is unregistered.
[5606]346                                     // Only roar_dl_context_restore(), roar_dl_context_store()
347                                     // and roar_dl_getpara() may be used on this object.
348                                     // Result of all other functions is undefined.
[5511]349 );
350 void * userdata; // The user data pointer passed to the callback.
351};
352
353// Parameters for FNREG registration:
354#define ROAR_DL_FNREG_SUBTYPE  0
355#define ROAR_DL_FNREG_VERSION  0
356#define ROAR_DL_FNREG_SIZE     sizeof(struct roar_dl_fnreg)
357
358
[5736]359// Common protocol interface (CPI):
[5576]360struct roar_dl_proto {
361 const int proto;
362 const char * description;
363 const int flags;
[5606]364 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);
365 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);
366 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);
367 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);
368 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);
369 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]370};
371
372#define ROAR_DL_PROTO_FLAGS_NONE         0
373
374#define ROAR_DL_PROTO_STATUS_RX_READY    0x0001
375#define ROAR_DL_PROTO_STATUS_TX_READY    0x0002
376#define ROAR_DL_PROTO_STATUS_WAIT_NOTIFY 0x0004
377
378// Parameters for FNREG registration:
379#define ROAR_DL_PROTO_SUBTYPE  1 /* 0 = roard */
380#define ROAR_DL_PROTO_VERSION  0
381#define ROAR_DL_PROTO_SIZE     sizeof(struct roar_dl_proto)
382
[5735]383
384// Common Service Interface (CSI):
385struct roar_dl_service {
386 // Name and ABI version of the application:
387 // if appname is NULL this is a /universal/ service.
388 // Such services MUST use APIs defined by the RoarAudio Project.
389 // If a random Vendor needs a API universal to own applications
390 // it should define a virtual application name for this.
391 const char * appname;
392 const char * appabi;
393 // Name and ABI/API version of service:
394 const char * servicename;
395 const char * serviceabi;
396 // Description:
397 const char * description;
398 // Flags (see below for defined flags):
399 const int    flags;
400 // Userdata:
401 // This is some kind of constant data.
[5809]402 // It can bed used by the functions below for internal stuff.
[5768]403 const void * userdata;
[5735]404 // Functions:
405 // get_api returns a pointer to a struct with the API.
406 // The api is specific to [appname, appabi, servicename, serviceabi].
[5769]407 const void * (*get_api)(const struct roar_dl_service * service, struct roar_dl_librarypara * para);
[5735]408};
409
410#define ROAR_DL_SERVICE_FLAGS_NONE         0x0000
411
412#define ROAR_DL_SERVICE_SUBTYPE  0
413#define ROAR_DL_SERVICE_VERSION  0
414#define ROAR_DL_SERVICE_SIZE     sizeof(struct roar_dl_service)
415
[5814]416#define ROAR_DL_PLUGIN_REG_SERVICES(obj) \
417static int _roaraudio_library_ROAR_DL_FN_SERVICE(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { \
418 size_t i; \
419 (void)para, (void)lib; \
420 for (i = 0; i < (sizeof((obj))/sizeof(*(obj))); i++) { \
421  ROAR_DL_PLUGIN_REG_FN(ROAR_DL_SERVICE_SUBTYPE, (obj)[i], ROAR_DL_SERVICE_VERSION); \
422 } \
423 return 0; \
424}
425#define ROAR_DL_PLUGIN_REG_SERVICES_GET_API(name,obj) \
426static const void * name(const struct roar_dl_service * service, struct roar_dl_librarypara * para) { \
427 (void)service, (void)para; \
428 return &(obj); \
429}
430
[5816]431struct roar_dl_service_api {
432 const void * api;
433 struct roar_dl_lhandle * lhandle;
[5818]434 const struct roar_dl_service * service;
[5816]435};
436
437#define libroar_dl_service_apitype(type) \
438union { \
439 struct roar_dl_service_api interface; \
440 const struct type * api; \
441}
442
[5819]443int libroar_dl_service_get_api_real(struct roar_dl_librarypara * para, const char * appname, const char * appabi, const char * servicename, const char * serviceabi, int universal, struct roar_dl_service_api * api, int retry);
444#define libroar_dl_service_get_api(para,appname,appabi,servicename,serviceabi,universal,api) libroar_dl_service_get_api_real((para),(appname),(appabi),(servicename),(serviceabi),(universal),(struct roar_dl_service_api *)(api), 1)
445#define roar_dl_service_get_api(para,servicename,serviceabi,api) libroar_dl_service_get_api((para), (para) == NULL ? NULL : ((struct roar_dl_librarypara *)(para))->appname, (para) == NULL ? NULL : ((struct roar_dl_librarypara *)(para))->abiversion, (servicename), (serviceabi), 1, (api))
[5816]446
447int libroar_dl_service_free_api_real(struct roar_dl_service_api * api);
448#define libroar_dl_service_free_api(api) libroar_dl_service_free_api_real((struct roar_dl_service_api *)&(api))
449
450#define libroar_dl_service_run_func(obj,name,type,...) ((type[3]){(type)roar_dl_context_restore((obj).interface.lhandle), ((obj).api->name(__VA_ARGS__)), (type)roar_dl_context_store((obj).interface.lhandle)})[1]
451#define libroar_dl_service_run_func_void(obj,name,...) do { roar_dl_context_restore((obj).interface.lhandle); (obj).api->name(__VA_ARGS__); roar_dl_context_store((obj).interface.lhandle); } while (0)
452#define libroar_dl_service_check_func(obj,name) ((obj).api->name != NULL)
[5814]453
[5511]454// Reg FN:
455
456// Options:
457#define ROAR_DL_FNREG_OPT_NONE 0   /* no options */
458
459// Register an FN.
460int                      roar_dl_register_fn(struct roar_dl_lhandle * lhandle, int fn, int subtype, const void * object, size_t objectlen, int version, int options);
461
[5770]462// Unregister an FN.
463int                      roar_dl_unregister_fn2(struct roar_dl_lhandle * lhandle, int fn, int subtype, const void * object, size_t objectlen, int version, int options);
464
[5511]465// Unregister FN for the given plugin.
466// This should not be called directly and is called internally when needed.
467int                      roar_dl_unregister_fn(struct roar_dl_lhandle * lhandle);
468
[3297]469#endif
470
471//ll
Note: See TracBrowser for help on using the repository browser.