Changeset 5917:316fad0b1a8e in roaraudio for roard
- Timestamp:
- 09/09/13 13:30:42 (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/Makefile
r5908 r5917 4 4 SUBSYS=midi.o light.o raw.o rdtcs.o waveform.o beep.o 5 5 DRV=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 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 codecfilter_roardmx.o 7 7 CF_CONTAINER=codecfilter_wave.o codecfilter_raum.o codecfilter_au.o 8 8 EMUL=emul_simple.o emul_rsound.o -
roard/include/light.h
r5916 r5917 57 57 int light_dmxchannel_set(size_t index, uint8_t val); 58 58 59 // codec filters: 60 int cf_light_roardmx_read(int id, struct roar_stream_server * ss); 61 int cf_light_roardmx_write(int id, struct roar_stream_server * ss); 62 59 63 #endif 60 64 -
roard/light.c
r5916 r5917 124 124 struct roar_stream * s; 125 125 struct roar_stream_server * ss; 126 struct roar_roardmx_message mes;127 126 char buf[512]; 128 int i, c; 129 uint16_t channel; 130 uint8_t value; 127 int i; 131 128 132 129 if ( g_streams[id] == NULL ) … … 155 152 case ROAR_CODEC_ROARDMX: 156 153 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. 159 156 return -1; 160 }161 162 // we ignore errors here at the moment as 0 not < -1163 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 changed176 }177 157 } 178 158 break; … … 185 165 } 186 166 167 static 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 187 193 int light_send_stream (int id) { 188 int chans;189 194 struct roar_stream * s; 190 195 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;196 196 197 197 if ( g_streams[id] == NULL ) … … 204 204 switch (s->info.codec) { 205 205 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); 227 207 break; 228 208 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); 254 210 break; 255 211 default:
Note: See TracChangeset
for help on using the changeset viewer.