Changeset 5814:81052ac84144 in roaraudio


Ignore:
Timestamp:
01/05/13 03:05:38 (8 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Improved CSI: Make it easier to register and access services.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5806 r5814  
    55        * Re-ported to OpenBSD. 
    66        * Made build system tests return correct error codes. 
     7        * Improved CSI: Make it easier to register and access services. 
    78 
    89v. 1.0beta8 - Mon Dec 10 2012 12:42 CET 
  • include/libroar/roardl.h

    r5809 r5814  
    137137// register objects using FN: 
    138138#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) 
     139#define ROAR_DL_PLUGIN_REG_FNFUNC(fn) ROAR_DL_PLUGIN_REG((fn), _roaraudio_library_ ## fn) 
    139140 
    140141// Do a FN reg callback registration: 
     
    404405#define ROAR_DL_SERVICE_SIZE     sizeof(struct roar_dl_service) 
    405406 
     407#define ROAR_DL_PLUGIN_REG_SERVICES(obj) \ 
     408static int _roaraudio_library_ROAR_DL_FN_SERVICE(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { \ 
     409 size_t i; \ 
     410 (void)para, (void)lib; \ 
     411 for (i = 0; i < (sizeof((obj))/sizeof(*(obj))); i++) { \ 
     412  ROAR_DL_PLUGIN_REG_FN(ROAR_DL_SERVICE_SUBTYPE, (obj)[i], ROAR_DL_SERVICE_VERSION); \ 
     413 } \ 
     414 return 0; \ 
     415} 
     416#define ROAR_DL_PLUGIN_REG_SERVICES_GET_API(name,obj) \ 
     417static const void * name(const struct roar_dl_service * service, struct roar_dl_librarypara * para) { \ 
     418 (void)service, (void)para; \ 
     419 return &(obj); \ 
     420} 
     421 
     422const void * libroar_dl_service_get_api(struct roar_dl_librarypara * para, const char * appname, const char * appabi, const char * servicename, const char * serviceabi, int universal); 
     423#define roar_dl_service_get_api(para,servicename,serviceabi,type) ((const struct type*)libroar_dl_service_get_api((para), (para)->appname, (para)->abiversion, (servicename), (serviceabi), 1)) 
     424 
    406425// Reg FN: 
    407426 
  • libroar/roardl.c

    r5770 r5814  
    10281028} 
    10291029 
     1030const void * libroar_dl_service_get_api(struct roar_dl_librarypara * para, const char * appname, const char * appabi, const char * servicename, const char * serviceabi, int universal) { 
     1031 const struct roar_dl_service * s; 
     1032 struct __fnregs * c = NULL; 
     1033 size_t i; 
     1034 
     1035 for (i = 0; i < __MAX_FNREGS; i++) { 
     1036  c = &(__fnrefs[ROAR_DL_FN_SERVICE][i]); 
     1037  s = c->object; 
     1038 
     1039  if ( c->lhandle == NULL ) 
     1040   continue; 
     1041 
     1042  if ( c->subtype != ROAR_DL_SERVICE_SUBTYPE ) 
     1043   continue; 
     1044  if ( c->objectlen != ROAR_DL_SERVICE_SIZE ) 
     1045   continue; 
     1046  if ( c->version != ROAR_DL_SERVICE_VERSION ) 
     1047   continue; 
     1048 
     1049  if ( !universal && s->appname == NULL ) 
     1050   continue; 
     1051  if ( s->appname != NULL && !!strcmp(s->appname, appname) ) 
     1052   continue; 
     1053  if ( (s->appabi == NULL && appabi != NULL) || (s->appabi != NULL && appabi == NULL) || 
     1054       (s->appabi != NULL && appabi != NULL && !!strcmp(s->appabi, appabi) ) ) 
     1055   continue; 
     1056  if ( s->servicename == NULL || !!strcmp(s->servicename, servicename) ) 
     1057   continue; 
     1058  if ( s->serviceabi == NULL || !!strcmp(s->serviceabi, serviceabi) ) 
     1059   continue; 
     1060 
     1061  if ( s->get_api == NULL ) 
     1062   continue; 
     1063 
     1064  return s->get_api(s, para); 
     1065 } 
     1066 
     1067 roar_err_set(ROAR_ERROR_NOENT); 
     1068 return NULL; 
     1069} 
     1070 
    10301071//ll 
Note: See TracChangeset for help on using the changeset viewer.