Changeset 5982:c38f275b38ae in roaraudio


Ignore:
Timestamp:
02/23/14 15:46:19 (5 years ago)
Author:
phi
Branch:
default
Message:

Added support to load light control filters into roard.

Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5977 r5982  
    22        * Added user defined RoarDMX events. 
    33        * Added support for rangeset to libroarlight, roard and roarlight. 
     4        * Added support to load light control filters into roard. 
    45 
    56v. 1.0beta11 - Tue Jan 21 2014 21:04 CET 
  • include/libroar/roardl.h

    r5961 r5982  
    6060#define ROAR_DL_FN_DRIVER               3 /* Driver, roard? */ 
    6161#define ROAR_DL_FN_SOURCE               4 /* Sources, roard? */ 
    62 #define ROAR_DL_FN_FILTER               5 /* Filter, libroardsp */ 
     62#define ROAR_DL_FN_FILTER               5 /* Filter, libroardsp, libroarlight */ 
    6363#define ROAR_DL_FN_FF                   6 /* file format??? */ 
    6464#define ROAR_DL_FN_AUTH                 7 /* Auth */ 
     
    357357 
    358358 
     359// Filter Infrastructure (FN_FILTER): 
     360// Parameters for FNREG registration:  
     361#define ROAR_DL_FILTER_SUBTYPE_DSP   0 /* libroardsp */ 
     362#define ROAR_DL_FILTER_SUBTYPE_SLFI  1 /* libroarlight */ 
     363// ROAR_DL_FILTER_{VERSION,SIZE}_* are defined in corresponding headers. 
     364 
     365 
    359366// Common protocol interface (CPI): 
    360367struct roar_dl_proto { 
     
    467474int                      roar_dl_unregister_fn(struct roar_dl_lhandle * lhandle); 
    468475 
     476// asking for a object: 
     477int                      roar_dl_query_fn(struct roar_dl_lhandle ** lhandle, int fn, int subtype, const void ** object, size_t * objectlen, int version, int * options, ssize_t index); 
     478 
    469479#endif 
    470480 
  • include/libroarlight/libroarlight.h

    r5961 r5982  
    4444#include "pwm.h" 
    4545#include "laser.h" 
     46#include "slfi.h" 
    4647 
    4748#endif 
  • libroar/roardl.c

    r5961 r5982  
    11171117} 
    11181118 
     1119 
     1120int roar_dl_query_fn(struct roar_dl_lhandle ** lhandle, int fn, int subtype, const void ** object, size_t * objectlen, int version, int * options, ssize_t index) { 
     1121 struct __fnregs * c = NULL; 
     1122 ssize_t found = 0; 
     1123 size_t j; 
     1124 
     1125 if ( lhandle == NULL || object == NULL || objectlen == NULL || options == NULL ) { 
     1126  roar_err_set(ROAR_ERROR_FAULT); 
     1127  return -1; 
     1128 } 
     1129 
     1130 if ( fn <= 0 || fn >= ROAR_DL_FN_MAX || index < 0 || index >= __MAX_FNREGS ) { 
     1131  roar_err_set(ROAR_ERROR_INVAL); 
     1132  return -1; 
     1133 } 
     1134 
     1135 for (j = 0; j < __MAX_FNREGS; j++) { 
     1136  c = &(__fnrefs[fn][j]); 
     1137 
     1138  if ( c->lhandle == NULL ) 
     1139   continue; 
     1140  if ( c->subtype != subtype ) 
     1141   continue; 
     1142  if ( c->version != version ) 
     1143   continue; 
     1144 
     1145  if ( index == found++ ) { 
     1146   *lhandle   = c->lhandle; 
     1147   *object    = c->object; 
     1148   *objectlen = c->objectlen; 
     1149   *options   = c->options; 
     1150   return 0; 
     1151  } 
     1152 } 
     1153 
     1154 roar_err_set(ROAR_ERROR_NOENT); 
     1155 return -1; 
     1156} 
     1157 
    11191158static inline int __load_plugin_any_get_api(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) { 
    11201159 struct roar_dl_lhandle * lhandle = NULL; 
  • libroarlight/Makefile

    r5849 r5982  
    77 
    88TARGETS=$(SLIB) $(ALIB) $(IMPLIB) 
    9 OBJS=libroarlight.o colors.o roardmx.o pwm.o 
     9OBJS=libroarlight.o colors.o roardmx.o pwm.o slfi.o 
    1010 
    1111#DEFINES        = -DDEBUG 
  • plugins/universal/Makefile

    r5902 r5982  
    66TARGETS_IO=piface$(SHARED_SUFFIX) 
    77TARGETS_SERVICE=service-about$(SHARED_SUFFIX) 
    8 TARGETS=$(TARGETS_MISC) $(TARGETS_PROTO) $(TARGETS_SERVICE) $(TARGETS_IO) 
     8TARGETS_SLFI=filter-slfi-helloworld$(SHARED_SUFFIX) 
     9TARGETS=$(TARGETS_MISC) $(TARGETS_PROTO) $(TARGETS_SERVICE) $(TARGETS_IO) $(TARGETS_SLFI) 
    910 
    1011#DEFINES        = -DDEBUG 
  • roard/include/light.h

    r5980 r5982  
    4242 uint8_t * output; 
    4343 uint8_t * outputchanges; 
     44 struct roar_slfi_inst * filter; 
    4445} g_light_state; 
    4546 
     
    5758int light_check_stream  (int id); 
    5859int light_send_stream   (int id); 
     60 
     61int light_filter_load(int primary, const char * name, int autoload, const struct roar_keyval * para, ssize_t paralen); 
    5962 
    6063// for plugins: 
  • roard/light.c

    r5981 r5982  
    7070 
    7171 g_light_state.channels = channels; 
     72 g_light_state.filter   = NULL; 
    7273 
    7374 if ( (g_light_mixer.stream = add_mixer(ROAR_SUBSYS_LIGHT, _MIXER_NAME("Light Control"), &ss)) == -1 ) { 
     
    9293 
    9394int light_free  (void) { 
     95 if ( g_light_state.filter != NULL ) { 
     96  roar_slfi_unref(g_light_state.filter); 
     97 } 
     98 
    9499 if ( g_light_state.state != NULL ) { 
    95100  roar_mm_free(g_light_state.state); 
     
    162167 
    163168 // TODO: next run filters 
     169 if ( g_light_state.filter != NULL ) { 
     170  if ( roar_slfi_update(g_light_state.filter, 
     171                        g_light_state.output, g_light_state.channels, 
     172                        ((int32_t)1000000LU)/(int32_t)ROAR_OUTPUT_CFREQ, 
     173                        g_light_state.events, g_light_state.eventsqueuelen) == -1 ) { 
     174   ROAR_WARN("light_update(void): Can not run SLFI filter: %s", roar_errorstring); 
     175  } 
     176 } 
    164177 
    165178 // calculate diffrence: 
     
    267280} 
    268281 
     282int light_filter_load(int primary, const char * name, int autoload, const struct roar_keyval * para, ssize_t paralen) { 
     283 struct roar_slfi_inst * filter; 
     284 int ret; 
     285 int err; 
     286 
     287 if ( primary && g_light_state.filter != NULL ) { 
     288  roar_err_set(ROAR_ERROR_ALREADY); 
     289  return -1; 
     290 } else if ( !primary && g_light_state.filter == NULL ) { 
     291  roar_err_set(ROAR_ERROR_BADSTATE); 
     292  return -1; 
     293 } 
     294 
     295 filter = roar_slfi_new(name, autoload, para, paralen); 
     296 if ( filter == NULL ) 
     297  return -1; 
     298 
     299 if ( primary ) { 
     300  g_light_state.filter = filter; 
     301  return 0; 
     302 } 
     303 
     304 ret = roar_slfi_ctl(g_light_state.filter, ROAR_SLFI_CMD_PUSH, filter); 
     305 err = roar_error; 
     306 
     307 roar_slfi_unref(filter); 
     308 
     309 roar_err_set(err); 
     310 return ret; 
     311} 
     312 
    269313int light_dmxchannel_get(size_t index) { 
    270314 if ( (size_t)g_light_state.channels <= index ) { 
  • roard/roard.c

    r5961 r5982  
    13011301 
    13021302 
     1303#if defined(ROAR_HAVE_MAIN_ARGS) && !defined(ROAR_WITHOUT_DCOMP_LIGHT) 
     1304struct light_filter { 
     1305 const char * name; 
     1306 char * para; 
     1307}; 
     1308 
     1309static int light_filter_add(int primary, struct light_filter * filter) { 
     1310 struct roar_keyval * kv; 
     1311 ssize_t kvlen; 
     1312 int ret; 
     1313 int err; 
     1314 
     1315 if ( filter->para == NULL ) { 
     1316  kvlen = -1; 
     1317  kv = NULL; 
     1318 } else { 
     1319  kvlen = roar_keyval_split(&kv, filter->para, NULL, NULL, 1); 
     1320  if ( kvlen == -1 ) { 
     1321   ROAR_ERR("light_filter_add(primar=%i, filter={name='%s', para=%p}): Can not split string: %s", primary, filter->name, filter->para, roar_errorstring); 
     1322   return -1; 
     1323  } 
     1324 } 
     1325 
     1326 ret = light_filter_load(primary, filter->name, 1, kv, kvlen); 
     1327 err = roar_error; 
     1328 if ( kv != NULL ) 
     1329  roar_mm_free(kv); 
     1330 
     1331 if ( ret == -1 ) { 
     1332  roar_err_set(err); 
     1333  ROAR_ERR("light_filter_add(primary=%i, filter={name='%s', para=%p}): Can not load filter: %s", primary, filter->name, filter->para, roar_errorstring); 
     1334  return -1; 
     1335 } 
     1336 
     1337 return 0; 
     1338} 
     1339#endif 
     1340 
    13031341// MAIN: 
    13041342 
     
    13991437 struct roar_vio_calls pidfile_vio; 
    14001438#endif 
     1439#if defined(ROAR_HAVE_MAIN_ARGS) && !defined(ROAR_WITHOUT_DCOMP_LIGHT) 
     1440 struct light_filter light_filter[32] = {{"chain", NULL}}; 
     1441 int    light_filter_count = 1; 
     1442 char * light_filter_para  = NULL; 
     1443#endif 
    14011444 
    14021445 ROAR_DBG("main(*): starting roard..."); 
     
    16771720  } else if ( strcmp(k, "--list-plugins") == 0 ) { 
    16781721   metaaction = MA_LIST_PLUGIN; 
     1722 
     1723  } else if ( strcmp(k, "--light-filter-load") == 0 ) { 
     1724   ROAR_CKHAVEARGS(1); 
     1725   if ( light_filter_count == (sizeof(light_filter)/sizeof(*light_filter)) ) { 
     1726    ROAR_ERR("Can not load any more light filters: %s", argv[++i]); 
     1727   } else { 
     1728    light_filter[light_filter_count].name = argv[++i]; 
     1729    light_filter[light_filter_count].para = light_filter_para; 
     1730    light_filter_count++; 
     1731   } 
     1732   light_filter_para = NULL; 
     1733  } else if ( strcmp(k, "--light-filter-load-primary") == 0 ) { 
     1734   ROAR_CKHAVEARGS(1); 
     1735   light_filter[0].name = argv[++i]; 
     1736   light_filter[0].para = light_filter_para; 
     1737  } else if ( strcmp(k, "--light-filter-args") == 0 ) { 
     1738   ROAR_CKHAVEARGS(1); 
     1739   light_filter_para = argv[++i]; 
    16791740 
    16801741  } else if ( strcmp(k, "--guest-acclev") == 0 ) { 
     
    23352396  ROAR_ERR("Can not initialize light control subsystem"); 
    23362397 } 
     2398 light_filter_add(1, &(light_filter[0])); 
     2399 for (i = 1; i < light_filter_count; i++) 
     2400  light_filter_add(0, &(light_filter[i])); 
    23372401#endif 
    23382402 
Note: See TracChangeset for help on using the changeset viewer.