Changeset 5982:c38f275b38ae in roaraudio for roard


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

Added support to load light control filters into roard.

Location:
roard
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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.