Changeset 5920:749a4a6a1413 in roaraudio


Ignore:
Timestamp:
09/11/13 11:25:17 (6 years ago)
Author:
phi
Branch:
default
Message:

added very basic support to handle RoarDMX events

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/include/light.h

    r5917 r5920  
    3232 
    3333#define LIGHT_CHANNELS_DEFAULT 512 /* one DMX Universe */ 
     34#define MAX_EVENTS_PER_CYCLE   16  /* this*cfreq is event thruput (16*100Hz = 1.6kEvents/s) */ 
    3435 
    3536extern struct light_state { 
    3637 unsigned int    channels; 
     38 uint8_t events[MAX_EVENTS_PER_CYCLE]; 
     39 size_t eventsqueuelen; 
    3740 uint8_t * state; 
    3841 uint8_t * changes; 
     
    5760int light_dmxchannel_set(size_t index, uint8_t val); 
    5861 
     62int light_dmxevent_add(const uint8_t * events, size_t len); 
     63int light_dmxevent_read(const uint8_t ** events, size_t * len); 
     64#define light_dmxevent_addone(event) light_dmxevent_add(&(uint8_t){(event)}, 1) 
     65 
    5966// codec filters: 
    6067int cf_light_roardmx_read(int id, struct roar_stream_server * ss); 
  • roard/light.c

    r5918 r5920  
    104104 memset(g_light_state.state,   0, g_light_state.channels); 
    105105 memset(g_light_state.changes, 0, g_light_state.channels); 
     106 memset(g_light_state.events,  0, sizeof(g_light_state.events)); 
     107 
     108 g_light_state.eventsqueuelen = 0; 
    106109 
    107110 return 0; 
     
    113116 
    114117 memset(g_light_state.changes, 0, g_light_state.channels); 
     118 memset(g_light_state.events,  0, sizeof(g_light_state.events)); 
     119 
     120 g_light_state.eventsqueuelen = 0; 
    115121 
    116122 return 0; 
     
    236242} 
    237243 
     244int light_dmxevent_add(const uint8_t * events, size_t len) { 
     245 size_t i; 
     246 
     247 if ( events == NULL ) { 
     248  roar_err_set(ROAR_ERROR_FAULT); 
     249  return -1; 
     250 } 
     251 
     252 if ( len > (sizeof(g_light_state.events) - g_light_state.eventsqueuelen) ) { 
     253  roar_err_set(ROAR_ERROR_NOSPC); 
     254  return -1; 
     255 } 
     256 
     257 for (i = 0; i < len; i++) { 
     258  g_light_state.events[g_light_state.eventsqueuelen++] = events[i]; 
     259  roar_notify_core_emit_simple(ROAR_DATA_DMX512_EVENT, -1, g_light_mixer.stream, ROAR_OT_STREAM, events[i], -1, NULL, -1); 
     260 } 
     261 
     262 return 0; 
     263} 
     264 
     265int light_dmxevent_read(const uint8_t ** events, size_t * len) { 
     266 if ( events == NULL || len == NULL ) { 
     267  roar_err_set(ROAR_ERROR_FAULT); 
     268  return -1; 
     269 } 
     270 
     271 *events = g_light_state.events; 
     272 *len    = g_light_state.eventsqueuelen; 
     273 
     274 return 0; 
     275} 
     276 
    238277#endif 
    239278 
Note: See TracChangeset for help on using the changeset viewer.