Changeset 5917:316fad0b1a8e in roaraudio


Ignore:
Timestamp:
09/09/13 13:30:42 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

some more cleanup: moved RoarDMX support in a diffrent file and clean up some random functions

Location:
roard
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • roard/Makefile

    r5908 r5917  
    44SUBSYS=midi.o light.o raw.o rdtcs.o waveform.o beep.o 
    55DRV=driver_esd.o driver_ao.o driver_roar.o driver_oss.o driver_shout.o driver_sndio.o driver_dmx.o driver_pwmled.o driver_i2cdmx.o driver_sysclock.o driver_wmm.o driver_dstr.o driver_alsa.o driver_rsound.o driver_portaudio.o driver_pulsesimple.o driver_jack.o driver_artsc.o 
    6 CF_CODEC=codecfilter_cmd.o codecfilter_vorbis.o codecfilter_celt.o codecfilter_speex.o codecfilter_alaw.o codecfilter_mulaw.o codecfilter_sndfile.o codecfilter_fishsound.o codecfilter_flac.o 
     6CF_CODEC=codecfilter_cmd.o codecfilter_vorbis.o codecfilter_celt.o codecfilter_speex.o codecfilter_alaw.o codecfilter_mulaw.o codecfilter_sndfile.o codecfilter_fishsound.o codecfilter_flac.o codecfilter_roardmx.o 
    77CF_CONTAINER=codecfilter_wave.o codecfilter_raum.o codecfilter_au.o 
    88EMUL=emul_simple.o emul_rsound.o 
  • roard/include/light.h

    r5916 r5917  
    5757int light_dmxchannel_set(size_t index, uint8_t val); 
    5858 
     59// codec filters: 
     60int cf_light_roardmx_read(int id, struct roar_stream_server * ss); 
     61int cf_light_roardmx_write(int id, struct roar_stream_server * ss); 
     62 
    5963#endif 
    6064 
  • roard/light.c

    r5916 r5917  
    124124 struct roar_stream        *   s; 
    125125 struct roar_stream_server *  ss; 
    126  struct roar_roardmx_message  mes; 
    127126 char buf[512]; 
    128  int i, c; 
    129  uint16_t      channel; 
    130  uint8_t value; 
     127 int i; 
    131128 
    132129 if ( g_streams[id] == NULL ) 
     
    155152  case ROAR_CODEC_ROARDMX: 
    156153    ROAR_DBG("light_check_stream(id=%i): Codec: RoarDMX", id); 
    157     if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 ) { 
    158      streams_delete(id); // because we don't know at the moment... 
     154    if ( cf_light_roardmx_read(id, ss) == -1 ) { 
     155     streams_delete(id); // simply drop the client on error. 
    159156     return -1; 
    160     } 
    161  
    162     // we ignore errors here at the moment as 0 not < -1 
    163     c = roar_roardmx_message_numchannels(&mes); 
    164     ROAR_DBG("light_check_stream(id=%i): Number of subframes: %u", id, c); 
    165  
    166     for (i = 0; i < c; i++) { 
    167      if ( roar_roardmx_message_get_chanval(&mes, &channel, &value, i) == -1 ) 
    168       return -1; 
    169  
    170      if ( g_light_state.channels < channel ) { 
    171       ROAR_WARN("light_check_stream(id=%i): Writing on non extisting DMX channel %u", id, channel); 
    172       continue; 
    173      } else { 
    174       g_light_state.state[channel]   = value; 
    175       g_light_state.changes[channel] = 0xFF; // the channel changed 
    176      } 
    177157    } 
    178158   break; 
     
    185165} 
    186166 
     167static inline int light_send_stream_dmx512  (int id, struct roar_stream * s, struct roar_stream_server * ss) { 
     168 int chans = g_light_state.channels; 
     169 uint8_t buf[512]; 
     170 register uint8_t * bufptr; 
     171 
     172 if ( chans > 512 ) 
     173  chans = 512; 
     174 
     175 if ( chans == 512 ) { 
     176  bufptr = g_light_state.state; 
     177 } else { 
     178  memset(buf, 0, 512); 
     179  memcpy(buf, g_light_state.state, chans); 
     180  bufptr = buf; 
     181 } 
     182 
     183 if ( stream_vio_s_write(ss, bufptr, 512) != 512 ) { 
     184  streams_delete(id); 
     185  return -1; 
     186 } 
     187 
     188 s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, 1); 
     189 
     190 return 0; 
     191} 
     192 
    187193int light_send_stream   (int id) { 
    188  int chans; 
    189194 struct roar_stream        *   s; 
    190195 struct roar_stream_server *  ss; 
    191  uint8_t buf[512]; 
    192  register uint8_t * bufptr; 
    193  struct roar_roardmx_message  mes; 
    194  int i; 
    195  int have_message = 0; 
    196196 
    197197 if ( g_streams[id] == NULL ) 
     
    204204 switch (s->info.codec) { 
    205205  case ROAR_CODEC_DMX512: 
    206     chans = g_light_state.channels; 
    207  
    208     if ( chans > 512 ) 
    209      chans = 512; 
    210  
    211     if ( chans == 512 ) { 
    212      bufptr = g_light_state.state; 
    213     } else { 
    214      memset(buf, 0, 512); 
    215      memcpy(buf, g_light_state.state, chans); 
    216      bufptr = buf; 
    217     } 
    218  
    219     if ( stream_vio_s_write(ss, bufptr, 512) != 512 ) { 
    220      streams_delete(id); 
    221      return -1; 
    222     } 
    223  
    224     s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, 1); 
    225  
    226     return 0; 
     206    return light_send_stream_dmx512(id, s, ss); 
    227207   break; 
    228208  case ROAR_CODEC_ROARDMX: 
    229     for (i = 0; i < g_light_state.channels; i++) { 
    230      if ( g_light_state.changes[i] ) { 
    231       if ( !have_message ) 
    232        if ( roar_roardmx_message_new_sset(&mes) == -1 ) 
    233         return -1; 
    234  
    235       have_message = 2; 
    236  
    237       if ( roar_roardmx_message_add_chanval(&mes, i, g_light_state.state[i]) == -1 ) { 
    238        if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 ) 
    239         return -1; 
    240  
    241        if ( roar_roardmx_message_new_sset(&mes) == -1 ) 
    242         return -1; 
    243  
    244        have_message = 1; 
    245       } 
    246      } 
    247     } 
    248  
    249     if ( have_message == 2 ) { 
    250      if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 ) 
    251       return -1; 
    252     } 
    253     return 0; 
     209    return cf_light_roardmx_write(id, ss); 
    254210   break; 
    255211  default: 
Note: See TracChangeset for help on using the changeset viewer.