Changeset 2816:b9e357b0dc43 in roaraudio
- Timestamp:
- 09/29/09 18:04:39 (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/codecfilter.c
r2701 r2816 36 36 {-1, "null", "null codec filter", NULL, NULL, ROAR_CODECFILTER_NONE, ROAR_SUBSYS_NONE, 37 37 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, 38 {-1, "PCM", "Native PCM Support", NULL, NULL, 39 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_WAVEFORM, 40 NULL, NULL, NULL, NULL, NULL, NULL, cf_alaw_delay, NULL}, 41 {ROAR_CODEC_MIDI, "MIDI", "Native MIDI Support", NULL, NULL, 42 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_MIDI, 43 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, 44 {ROAR_CODEC_DMX512, "DMX512", "Native DMX512 Support", NULL, NULL, 45 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_LIGHT, 46 NULL, NULL, NULL, NULL, NULL, NULL, cf_alaw_delay, NULL}, 38 47 39 48 /* … … 45 54 #ifndef ROAR_WITHOUT_CF_WAVE 46 55 {ROAR_CODEC_RIFF_WAVE, "RIFF/WAVE", "RIFF/WAVE", NULL, NULL, 47 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE , ROAR_SUBSYS_WAVEFORM,56 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, ROAR_SUBSYS_WAVEFORM, 48 57 cf_wave_open, cf_wave_close, NULL, cf_wave_write, cf_wave_read, NULL, NULL, cf_wave_ctl}, 49 58 #endif … … 56 65 #endif 57 66 67 #ifdef ROAR_HAVE_LIBOGG 68 {ROAR_CODEC_OGG, "Ogg", "Ogg Container Format", NULL, NULL, ROAR_CODECFILTER_NONE, 69 ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI, 70 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, 71 #endif 72 58 73 #ifdef ROAR_SUPPORT_ALAW 59 74 {ROAR_CODEC_ALAW, "alaw", "A-Law", NULL, NULL, 60 75 #ifdef ROAR_SUPPORT_ALAW_RW 61 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE ,62 #else 63 ROAR_CODECFILTER_READ ,76 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, 77 #else 78 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_PRETHRU_NN, 64 79 #endif 65 80 ROAR_SUBSYS_WAVEFORM, … … 76 91 {ROAR_CODEC_MULAW, "mulaw", "mu-Law", NULL, NULL, 77 92 #ifdef ROAR_SUPPORT_MULAW_RW 78 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE ,79 #else 80 ROAR_CODECFILTER_READ ,93 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, 94 #else 95 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_PRETHRU_NN, 81 96 #endif 82 97 ROAR_SUBSYS_WAVEFORM, … … 101 116 {ROAR_CODEC_OGG_VORBIS, "oggvorbis", "Ogg Vorbis decoder", NULL, NULL, 102 117 #ifdef ROAR_HAVE_LIBVORBISENC 103 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE ,118 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, 104 119 #else 105 120 ROAR_CODECFILTER_READ, … … 136 151 137 152 #ifdef ROAR_HAVE_LIBCELT 138 {ROAR_CODEC_ROAR_CELT, "RoarCELT", "RoarAudio CELT", NULL, NULL, ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE, 153 {ROAR_CODEC_ROAR_CELT, "RoarCELT", "RoarAudio CELT", NULL, NULL, 154 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, 139 155 ROAR_SUBSYS_WAVEFORM, 140 156 cf_celt_open, cf_celt_close, NULL, cf_celt_write, cf_celt_read, NULL, cf_celt_delay, NULL}, … … 142 158 143 159 #ifdef ROAR_HAVE_LIBSPEEX 144 {ROAR_CODEC_ROAR_SPEEX, "RoarSpeex", "RoarAudio Speex", NULL, NULL, ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE, 160 {ROAR_CODEC_ROAR_SPEEX, "RoarSpeex", "RoarAudio Speex", NULL, NULL, 161 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, 145 162 ROAR_SUBSYS_WAVEFORM, 146 163 cf_speex_open, cf_speex_close, NULL, cf_speex_write, cf_speex_read, NULL, NULL, NULL}, … … 161 178 #endif 162 179 #endif 180 181 {ROAR_CODEC_ROARDMX, "RoarDMX", "Native RoarDMX Support", NULL, NULL, 182 ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_LIGHT, 183 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, 163 184 164 185 {-1, NULL, NULL, NULL, NULL, ROAR_CODECFILTER_NONE, ROAR_SUBSYS_NONE, … … 203 224 if ( flags & ROAR_CODECFILTER_WRITE ) 204 225 mode[1] = 'w'; 226 if ( flags & ROAR_CODECFILTER_PRETHRU ) 227 mode[2] = 'P'; 228 if ( flags & ROAR_CODECFILTER_PRETHRU_NN ) 229 mode[2] = 'p'; 205 230 } 206 231 -
roard/codecfilter_celt.c
r2204 r2816 225 225 int diff; 226 226 int fs2 = self->frame_size * 2 * ROAR_STREAM(self->stream)->info.channels; 227 int sid; 227 228 uint16_t pkglen_net, pkglen; 228 229 unsigned char cbits[BS+2]; 230 void * prethru; 229 231 230 232 if ( !self->opened_encoder ) { 233 sid = ROAR_STREAM(self->stream)->id; 234 235 if ( stream_prethru_destroy(sid) == -1 ) { 236 return -1; 237 } 238 239 if ( stream_prethru_add_data(sid, &prethru, ROAR_CELT_MAGIC_LEN) == -1 ) { 240 return -1; 241 } 242 243 memcpy(prethru, ROAR_CELT_MAGIC, ROAR_CELT_MAGIC_LEN); 244 231 245 if ( stream_vio_s_write(self->stream, ROAR_CELT_MAGIC, ROAR_CELT_MAGIC_LEN) != ROAR_CELT_MAGIC_LEN ) 232 246 return -1; -
roard/codecfilter_speex.c
r2310 r2816 261 261 int ret = 0; 262 262 int need_extra; 263 int sid; 264 void * prethru; 263 265 264 266 /* … … 271 273 272 274 if ( ! self->encoder ) { 275 sid = ROAR_STREAM(self->stream)->id; 276 277 if ( stream_prethru_destroy(sid) == -1 ) { 278 return -1; 279 } 280 281 if ( stream_prethru_add_data(sid, &prethru, ROAR_SPEEX_MAGIC_LEN) == -1 ) { 282 return -1; 283 } 284 285 memcpy(prethru, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN); 286 273 287 if ( stream_vio_s_write(self->stream, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN) != ROAR_SPEEX_MAGIC_LEN ) 274 288 return -1; … … 282 296 } 283 297 298 284 299 mode = ROAR_HOST2NET16(mode); 300 301 if ( stream_prethru_add_data(sid, &prethru, 2) == -1 ) { 302 return -1; 303 } 304 305 *(uint16_t*)prethru = mode; 285 306 286 307 if ( stream_vio_s_write(self->stream, &mode, 2) != 2 ) -
roard/codecfilter_vorbis.c
r2107 r2816 144 144 int chans; 145 145 int end; 146 int sid; 147 void * prethrubuf; 146 148 #if ROAR_VORBIS_BITS == 8 147 149 int8_t * data = (int8_t *) buf; … … 161 163 } 162 164 165 sid = ROAR_STREAM(self->stream)->id; 166 163 167 vorbis_analysis_headerout(&(self->encoder.vd), &(self->encoder.vc), &header, &header_comm, &header_code); 164 168 … … 166 170 ogg_stream_packetin(&(self->encoder.os), &header_comm); 167 171 ogg_stream_packetin(&(self->encoder.os), &header_code); 172 173 stream_prethru_destroy(sid); 168 174 169 175 while (ogg_stream_flush(&(self->encoder.os), &(self->encoder.og))) { … … 174 180 free(self); // TODO: do we need addional cleanup? 175 181 return -1; 182 } 183 // we ignore errors at the moment... 184 if ( stream_prethru_add_data(sid, &prethrubuf, self->encoder.og.header_len + self->encoder.og.body_len) != -1 ) { 185 memcpy(prethrubuf, self->encoder.og.header, self->encoder.og.header_len); 186 memcpy(prethrubuf + self->encoder.og.header_len, self->encoder.og.body, self->encoder.og.body_len ); 176 187 } 177 188 } -
roard/codecfilter_wave.c
r2607 r2816 154 154 struct codecfilter_wave_inst * self = (struct codecfilter_wave_inst *) inst; 155 155 struct roar_stream * s = ROAR_STREAM(self->stream); 156 char header[44];156 void * header; 157 157 int32_t tmp32; 158 158 int16_t tmp16; 159 159 int16_t bits; 160 160 int16_t codec; 161 int sid; 161 162 162 163 ROAR_DBG("cf_wave_write(inst=%p, buf=%p, len=%i) = ?", inst, buf, len); … … 169 170 if ( s->fh == -1 ) { 170 171 errno = EAGAIN; 172 return -1; 173 } 174 175 sid = ROAR_STREAM(self->stream)->id; 176 177 if ( stream_prethru_destroy(sid) == -1 ) { 178 return -1; 179 } 180 181 if ( stream_prethru_add_data(sid, &header, 44) == -1 ) { 171 182 return -1; 172 183 } -
roard/include/codecfilter.h
r2686 r2816 32 32 struct roar_stream_server; 33 33 34 #define ROAR_CODECFILTER_NONE 0 35 #define ROAR_CODECFILTER_READ 1 36 #define ROAR_CODECFILTER_WRITE 2 34 #define ROAR_CODECFILTER_NONE 0x00 35 #define ROAR_CODECFILTER_READ 0x01 36 #define ROAR_CODECFILTER_WRITE 0x02 37 #define ROAR_CODECFILTER_PRETHRU 0x04 /* we have support for prethru */ 38 #define ROAR_CODECFILTER_PRETHRU_NN 0x08 /* prethru Not Needed */ 37 39 38 40 -
roard/include/streams.h
r2625 r2816 80 80 struct roar_buffer * outputbuffer; 81 81 int state; 82 struct roar_buffer * prethru; 82 83 } * g_streams[ROAR_STREAMS_MAX]; 83 84 … … 135 136 int stream_outputbuffer_destroy(int id); 136 137 138 int stream_prethru_add(int id, struct roar_buffer * buf); 139 int stream_prethru_add_data(int id, void ** buf, size_t len); 140 int stream_prethru_destroy(int id); 141 int stream_prethru_send(int dst, int src); 142 137 143 int streams_check (int id); 138 144 int streams_send_mon (int id); -
roard/streams.c
r2766 r2816 104 104 s->ready = 0; 105 105 s->outputbuffer = NULL; 106 s->prethru = NULL; 106 107 107 108 s->mixer.scale = 65535; … … 228 229 229 230 stream_outputbuffer_destroy(id); 231 stream_prethru_destroy(id); 230 232 231 233 if ( s->buffer != NULL ) … … 421 423 return -1; 422 424 425 dir = ROAR_STREAM(ss)->dir; 426 423 427 ROAR_DBG("streams_set_fh(id=%i): g_streams[id]->id=%i", id, s->id); 424 428 … … 435 439 } 436 440 437 if ( codecfilter_open(&(ss->codecfilter_inst), &(ss->codecfilter), NULL, 438 s->info.codec, ss) == -1 ) { 439 return streams_delete(id); // TODO: FIXME: is this correct? shoudn't we return -1 in any case here? 440 } 441 ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh); 442 443 if ( dir != ROAR_DIR_THRU ) { 444 if ( codecfilter_open(&(ss->codecfilter_inst), &(ss->codecfilter), NULL, 445 s->info.codec, ss) == -1 ) { 446 return streams_delete(id); // TODO: FIXME: is this correct? shoudn't we return -1 in any case here? 447 } 448 } 449 450 ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh); 441 451 442 452 if ( fh == -2 ) { … … 454 464 } 455 465 466 ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh); 467 456 468 if ( fh == -1 || fh == -2 ) { // yes, this is valid, indecats full vio! 457 469 ss->ready = 1; … … 460 472 } 461 473 474 ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh); 475 462 476 // roar_socket_recvbuf(fh, ROAR_OUTPUT_CALC_OUTBUFSIZE( &(ROAR_STREAM(g_streams[id])->info) )); // set recv buffer to minimum 463 464 dir = ROAR_STREAM(ss)->dir;465 477 466 478 switch (dir) { … … 493 505 ss->ready = 1; 494 506 ss->state = ROAR_STREAMSTATE_NEW; 507 508 ROAR_DBG("streams_set_fh(id=%i, fh=%i) = 0", id, fh); 495 509 return 0; 496 510 } else { … … 502 516 ss->ready = 1; 503 517 ss->state = ROAR_STREAMSTATE_NEW; 518 519 ROAR_DBG("streams_set_fh(id=%i, fh=%i) = 0", id, fh); 504 520 return 0; 505 521 } … … 1171 1187 } 1172 1188 1189 return 0; 1190 } 1191 1192 int stream_prethru_add(int id, struct roar_buffer * buf) { 1193 register struct roar_stream_server * ss; 1194 1195 _CHECK_SID(id); 1196 1197 if ( (ss = g_streams[id]) == NULL ) 1198 return -1; 1199 1200 if ( ss->prethru == NULL ) { 1201 ss->prethru = buf; 1202 return 0; 1203 } 1204 1205 if ( roar_buffer_add(ss->prethru, buf) == -1 ) { 1206 return -1; 1207 } 1208 1209 return 0; 1210 } 1211 1212 int stream_prethru_add_data(int id, void ** buf, size_t len) { 1213 struct roar_buffer * buffer; 1214 1215 _CHECK_SID(id); 1216 1217 if ( roar_buffer_new(&buffer, len) == -1 ) 1218 return -1; 1219 1220 if ( roar_buffer_get_data(buffer, buf) == -1 ) { 1221 roar_buffer_free(buffer); 1222 return -1; 1223 } 1224 1225 if ( stream_prethru_add(id, buffer) == -1 ) { 1226 roar_buffer_free(buffer); 1227 return -1; 1228 } 1229 1230 return 0; 1231 } 1232 1233 int stream_prethru_destroy(int id) { 1234 int ret; 1235 register struct roar_stream_server * ss; 1236 1237 _CHECK_SID(id); 1238 1239 if ( (ss = g_streams[id]) == NULL ) 1240 return -1; 1241 1242 if ( ss->prethru != NULL ) { 1243 ret = roar_buffer_free(ss->prethru); 1244 ss->prethru = NULL; 1245 return ret; 1246 } 1247 1248 return 0; 1249 } 1250 1251 int stream_prethru_send(int dst, int src) { 1252 struct roar_stream_server * dst_ss, * src_ss; 1253 struct roar_buffer * bufbuf; 1254 void * bufdata; 1255 size_t buflen; 1256 1257 ROAR_DBG("stream_prethru_send(dst=%i, src=%i) = ?", dst, src); 1258 1259 _CHECK_SID(dst); 1260 _CHECK_SID(src); 1261 1262 if ( (dst_ss = g_streams[dst]) == NULL ) 1263 return -1; 1264 1265 if ( (src_ss = g_streams[src]) == NULL ) 1266 return -1; 1267 1268 bufbuf = src_ss->prethru; 1269 1270 ROAR_DBG("stream_prethru_send(dst=%i, src=%i): prethru buffer at %p", dst, src, bufbuf); 1271 1272 while (bufbuf != NULL) { 1273 ROAR_DBG("stream_prethru_send(dst=%i, src=%i): looping with buffer at %p", dst, src, bufbuf); 1274 1275 if ( roar_buffer_get_data(bufbuf, &bufdata) == -1 ) 1276 return -1; 1277 1278 if ( roar_buffer_get_len(bufbuf, &buflen) == -1 ) 1279 return -1; 1280 1281 if ( stream_vio_s_write(dst_ss, bufdata, buflen) != buflen ) 1282 return -1; 1283 1284 if ( roar_buffer_get_next(bufbuf, &bufbuf) == -1 ) 1285 return -1; 1286 } 1287 1288 ROAR_DBG("stream_prethru_send(dst=%i, src=%i) = 0", dst, src); 1173 1289 return 0; 1174 1290 } … … 1614 1730 return -1; 1615 1731 1616 if ( streams_thru_num ) 1617 for (i = 0; i < ROAR_STREAMS_MAX; i++) 1618 if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == ROAR_STREAM(stream)->id ) 1619 if ( ROAR_STREAM(g_streams[i])->dir == ROAR_DIR_THRU ) 1620 if ( g_streams[i]->ready ) 1732 if ( streams_thru_num ) { 1733 for (i = 0; i < ROAR_STREAMS_MAX; i++) { 1734 if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == ROAR_STREAM(stream)->id ) { 1735 if ( ROAR_STREAM(g_streams[i])->dir == ROAR_DIR_THRU ) { 1736 if ( g_streams[i]->ready ) { 1621 1737 if ( stream_vio_write(i, orig_buf, len) != len ) 1622 1738 streams_delete(i); 1739 1740 if ( g_streams[i] != NULL ) 1741 g_streams[i]->state = ROAR_STREAMSTATE_OLD; 1742 } 1743 } 1744 } 1745 } 1746 } 1623 1747 1624 1748 return len; … … 1640 1764 // ROAR_WARN("stream_vio_s_write(*): writing..."); 1641 1765 1642 if ( streams_thru_num ) 1643 for (i = 0; i < ROAR_STREAMS_MAX; i++) 1644 if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == ROAR_STREAM(stream)->id ) 1645 if ( ROAR_STREAM(g_streams[i])->dir == ROAR_DIR_THRU ) 1646 if ( g_streams[i]->ready ) 1647 if ( stream_vio_write(i, buf, count) != count ) 1766 if ( streams_thru_num ) { 1767 for (i = 0; i < ROAR_STREAMS_MAX; i++) { 1768 if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == ROAR_STREAM(stream)->id ) { 1769 if ( ROAR_STREAM(g_streams[i])->dir == ROAR_DIR_THRU ) { 1770 if ( g_streams[i]->ready ) { 1771 if ( g_streams[i]->state == ROAR_STREAMSTATE_NEW ) { 1772 if ( streams_get_flag(i, ROAR_FLAG_PRETHRU) == 1 ) { 1773 if ( stream_prethru_send(i, ROAR_STREAM(stream)->id) == -1 ) { 1774 streams_delete(i); 1775 } 1776 } 1777 } 1778 1779 if ( stream_vio_write(i, buf, count) != count ) { 1648 1780 streams_delete(i); 1781 } 1782 1783 if ( g_streams[i] != NULL ) 1784 g_streams[i]->state = ROAR_STREAMSTATE_OLD; 1785 } 1786 } 1787 } 1788 } 1789 } 1649 1790 1650 1791 return roar_vio_write(&(stream->vio), buf, count);
Note: See TracChangeset
for help on using the changeset viewer.