Changeset 5983:377909b17ccb in roaraudio


Ignore:
Timestamp:
02/23/14 22:16:20 (5 years ago)
Author:
phi
Branch:
default
Message:

added support to *add* RoarDMX events in SLFI filters

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroarlight/slfi.h

    r5982 r5983  
    9595int roar_slfi_ctl(struct roar_slfi_inst * inst, enum roar_slfi_command command, void * argp); 
    9696 
     97int roar_slfi_event_add(struct roar_slfi_inst * inst, uint8_t event); // does not perform any context switching. 
     98int roar_slfi_cb_set_event_add(struct roar_slfi_inst * inst, int (*cb)(struct roar_slfi_inst * inst, void * userdata, uint8_t event), void * userdata); 
     99 
    97100#endif 
    98101 
  • libroarlight/slfi.c

    r5982 r5983  
    240240} 
    241241 
     242int roar_slfi_event_add(struct roar_slfi_inst * inst, uint8_t event) { 
     243 if ( inst == NULL ) { 
     244  roar_err_set(ROAR_ERROR_FAULT); 
     245  return -1; 
     246 } 
     247 
     248 if ( inst->cb_event_add == NULL ) { 
     249  roar_err_set(ROAR_ERROR_NOSYS); 
     250  return -1; 
     251 } 
     252 
     253 return inst->cb_event_add(inst, inst->cb_event_add_userdata, event); 
     254} 
     255 
     256int roar_slfi_cb_set_event_add(struct roar_slfi_inst * inst, int (*cb)(struct roar_slfi_inst * inst, void * userdata, uint8_t event), void * userdata) { 
     257 if ( inst == NULL ) { 
     258  roar_err_set(ROAR_ERROR_FAULT); 
     259  return -1; 
     260 } 
     261 
     262 inst->cb_event_add = cb; 
     263 inst->cb_event_add_userdata = userdata; 
     264 return 0; 
     265} 
     266 
    242267//ll 
  • roard/light.c

    r5982 r5983  
    2828#ifndef ROAR_WITHOUT_DCOMP_LIGHT 
    2929 
     30static uint8_t nextcycle_events[MAX_EVENTS_PER_CYCLE]; 
     31static size_t nextcycle_eventsqueuelen; 
     32static int __cb_event_add(struct roar_slfi_inst * inst, void * userdata, uint8_t event); 
     33 
    3034// declared 'extern' 
    3135struct light_state g_light_state; 
     
    148152 
    149153 g_light_state.eventsqueuelen = 0; 
     154 
     155 if ( nextcycle_eventsqueuelen ) { 
     156  light_dmxevent_add(nextcycle_events, nextcycle_eventsqueuelen); 
     157  nextcycle_eventsqueuelen = 0; 
     158 } 
    150159 
    151160 return 0; 
     
    298307 
    299308 if ( primary ) { 
     309  roar_slfi_cb_set_event_add(filter, __cb_event_add, NULL); 
    300310  g_light_state.filter = filter; 
    301311  return 0; 
     
    395405} 
    396406 
     407static int __cb_event_add(struct roar_slfi_inst * inst, void * userdata, uint8_t event) { 
     408 size_t i; 
     409 
     410 if ( nextcycle_eventsqueuelen == MAX_EVENTS_PER_CYCLE ) { 
     411  roar_err_set(ROAR_ERROR_NOSPC); 
     412  return -1; 
     413 } 
     414 
     415 nextcycle_events[nextcycle_eventsqueuelen++] = event; 
     416 
     417 return 0; 
     418} 
     419 
    397420#endif 
    398421 
Note: See TracChangeset for help on using the changeset viewer.