Changeset 5927:95a79080ea30 in roaraudio


Ignore:
Timestamp:
09/11/13 14:16:50 (6 years ago)
Author:
phi
Branch:
default
Message:

cleanup of code structure and added support to support events

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/codecfilter_roardmx.c

    r5917 r5927  
    2828#ifndef ROAR_WITHOUT_DCOMP_LIGHT 
    2929 
    30 int cf_light_roardmx_read(int id, struct roar_stream_server * ss) { 
    31  struct roar_roardmx_message  mes; 
    32  int i, c; 
     30static inline int __read_sset(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) { 
    3331 uint16_t channel; 
    3432 uint8_t value; 
    35  
    36  if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 ) { 
    37   return -1; 
    38  } 
     33 int i, c; 
    3934 
    4035 // we ignore errors here at the moment as 0 not < -1 
    41  c = roar_roardmx_message_numchannels(&mes); 
     36 c = roar_roardmx_message_numchannels(mes); 
    4237 ROAR_DBG("light_check_stream(id=%i): Number of subframes: %u", id, c); 
    4338 
    4439 for (i = 0; i < c; i++) { 
    45   if ( roar_roardmx_message_get_chanval(&mes, &channel, &value, i) == -1 ) 
     40  if ( roar_roardmx_message_get_chanval(mes, &channel, &value, i) == -1 ) 
    4641   return -1; 
    4742 
     
    5853} 
    5954 
    60 int cf_light_roardmx_write(int id, struct roar_stream_server * ss) { 
     55static inline int __read_events(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) { 
     56 const uint8_t * events; 
     57 size_t len; 
     58 
     59 (void)id, (void)ss; 
     60 
     61 if ( roar_roardmx_message_get_events(mes, &events, &len) == -1 ) 
     62  return -1; 
     63 
     64 return light_dmxevent_add(events, len); 
     65} 
     66 
     67int cf_light_roardmx_read(int id, struct roar_stream_server * ss) { 
     68 struct roar_roardmx_message  mes; 
     69 unsigned char type; 
     70 
     71 if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 ) 
     72  return -1; 
     73 
     74 if ( roar_roardmx_message_get_type(&mes, &type) == -1 ) 
     75  return -1; 
     76 
     77 switch (type) { 
     78  case ROAR_ROARDMX_TYPE_SSET: return __read_sset(id, ss, &mes); break; 
     79  case ROAR_ROARDMX_TYPE_EVENT: return __read_events(id, ss, &mes); break; 
     80 } 
     81 
     82 roar_err_set(ROAR_ERROR_NSTYPE); 
     83 return -1; 
     84} 
     85 
     86static inline int __write_events(int id, struct roar_stream_server * ss) { 
     87 struct roar_roardmx_message  mes; 
     88 const uint8_t * events; 
     89 size_t len; 
     90 
     91 if ( light_dmxevent_read(&events, &len) == -1 ) 
     92  return -1; 
     93 
     94 // check if we need to send events at all: 
     95 if ( len == 0 ) 
     96  return 0; 
     97 
     98 // ok, now let's build the message: 
     99 if ( roar_roardmx_message_new_event(&mes) == -1 ) 
     100  return -1; 
     101 
     102 if ( roar_roardmx_message_add_events(&mes, events, len) == -1 ) 
     103  return -1; 
     104 
     105 // and send it: 
     106 if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 ) 
     107  return -1; 
     108 
     109 return 0; 
     110} 
     111 
     112static inline int __write_channels(int id, struct roar_stream_server * ss) { 
    61113 struct roar_roardmx_message  mes; 
    62114 int have_message = 0; 
     
    90142} 
    91143 
     144int cf_light_roardmx_write(int id, struct roar_stream_server * ss) { 
     145 if ( __write_events(id, ss) == -1 ) 
     146  return -1; 
     147 
     148 if ( __write_channels(id, ss) == -1 ) 
     149  return -1; 
     150 
     151 return 0; 
     152} 
     153 
    92154#endif 
    93155 
Note: See TracChangeset for help on using the changeset viewer.