source: roaraudio/roarclients/roarphone.c @ 4883:c56aedd9d0cb

Last change on this file since 4883:c56aedd9d0cb was 4883:c56aedd9d0cb, checked in by phi, 13 years ago

Added functions to access symbolic names for audio info parameters (Closes: #51)

File size: 17.3 KB
RevLine 
[2292]1//roarphone.c:
[2124]2
3/*
[4708]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2011
[2124]5 *
6 *  This file is part of roarclients a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
[3517]21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
[2124]23 *
24 */
25
26#include <roaraudio.h>
[2185]27#include <libroardsp/libroardsp.h>
[2282]28#include <libroareio/libroareio.h>
[2124]29
[2215]30#if defined(ROAR_HAVE_LIBSPEEX) && !defined(ROAR_HAVE_LIBSPEEXDSP)
31#define _SPEEX_API_OLD
32#elif defined(ROAR_HAVE_LIBSPEEX) && defined(ROAR_HAVE_LIBSPEEXDSP)
33#define _SPEEX_API_NEW
34#endif
35
36#ifdef _SPEEX_API_OLD
[2141]37#include <speex/speex_echo.h>
38#endif
39
40#define TIMEDIV  100
[2124]41
[2125]42#define DRIVER  "oss"
43
[2140]44// anti echo:
45#define AE_NONE      0
46#define AE_SIMPLE    1
47#define AE_SPEEX     2
[2141]48#define AE_ROARD     3
[2140]49
[2322]50#define DTX_F        25
51
[2329]52#define CON_NONE     0x00
53#define CON_CON      0x01
54#define CON_STREAM   0x02
55
[2140]56struct {
57 int antiecho;
[2166]58 int samples;
[2167]59 int transcode;
[2321]60 int64_t dtx_threshold;
[2986]61 size_t jumbo_mtu;
[2993]62 int    ioflush_interval;
[2991]63 struct {
64  struct {
65   int downmix;
66   float lowp_freq;
[3006]67   int speex_prep;
[3007]68   int speex_prep_denoise;
69   int speex_prep_agc;
70   int speex_prep_vad;
[2991]71  } in;
72 } filter;
[2140]73} g_conf;
74
[2322]75int dtx_counter = 0;
76
[2329]77struct {
78 int state;
79 struct roar_connection con;
80 struct roar_stream     stream;
81 struct roar_vio_calls * svio;
82} g_cons;
83
[2185]84struct roar_bixcoder transcoder[1];
85
[2330]86struct {
[2977]87 struct roardsp_filterchain input;
88 struct roardsp_filterchain output;
89} g_filterchains;
90
91struct {
[2330]92 struct {
93  char key[ROAR_META_MAX_NAMELEN];
94  char value[LIBROAR_BUFFER_MSGDATA];
95 } tmp;
96 char * rn;
97 char * nick;
98 char * org;
99 char * email;
100 char * hp;
101 char * loc;
102 char * thumbnail;
103} g_meta;
104
[2124]105void usage (void) {
[2292]106 printf("roarphone [OPTIONS]...\n");
[2124]107
[2330]108 printf("\nServer Options:\n\n");
[2124]109
[2995]110 printf("  --server    SERVER   - Set server hostname\n"
[2994]111        "  --jumbo-mtu MTU      - Sets the MTU for Jumbo Packets\n"
112        "  --io-flush  INTERVAL - Flushs output every INTERVAL packets\n"
[2330]113       );
114
115 printf("\nAudio Options:\n\n");
116 printf("  --rate     RATE      - Set sample rate\n"
[2141]117        "  --bits     BITS      - Set bits per sample\n"
118        "  --chans    CHANNELS  - Set number of channels\n"
[2330]119       );
120
[2991]121 printf("\nAudio Filter Options:\n\n");
122 printf("  --afi-downmix        - Enable input downmixing\n"
123        "  --afi-lowpass FREQ   - Enable input lowpass at FREQ (in Hz)\n"
[3006]124        "  --afi-speex-prep     - Enable speex preprocessor\n"
[3007]125        "  --afi-speex-denoise  - Enable speex denoiser\n"
126        "  --afi-speex-agc      - Enable speex AGC\n"
127        "  --afi-speex-vad      - Enable speex VAD\n"
[2991]128       );
129
[2330]130 printf("\nCodec Options:\n\n");
131 printf("  --codec    CODEC     - Set the codec\n"
132        "  --transcode          - Use local transcodeing\n"
133       );
134
135 printf("\nDriver Options:\n\n");
136 printf("  --driver   DRIVER    - Set the driver\n"
[2141]137        "  --device   DEVICE    - Set the device\n"
[2330]138       );
139
140 printf("\nGeneral Options:\n\n");
141 printf("  --antiecho AEMODE    - Set the anti echo mode\n"
[2321]142        "  --threshold DTXTHRES - Set the DTX threshold, disabled by default\n"
[2141]143        "  --help               - Show this help\n"
[2124]144       );
145
[2330]146 printf("\nMeta Data Options:\n\n");
147 printf("  --m-rn    REALNAME   - Sets the real name\n"
148        "  --m-nick  NICK       - Sets the nick name\n"
149        "  --m-email EMAIL      - Sets the email address\n"
150        "  --m-hp    HOMEPAGE   - Sets the homepage URL\n"
151        "  --m-thumbn THUMBNAIL - Sets a URL to a thumbnail\n"
152        "  --m-loc   LOCATION   - Sets the location (room number)\n"
153        "  --m-org ORGANIZATION - Sets the organization/company name\n"
154       );
[2124]155}
156
[2128]157int open_stream (struct roar_vio_calls * vio, char * server, struct roar_audio_info * info) {
[2329]158 int fh;
159
160 g_cons.svio = vio;
161
162 if ( !(g_cons.state & CON_CON) )
163  if ( roar_simple_connect(&(g_cons.con), server, "roarphone") == -1 )
164   return -1;
165
166 g_cons.state |= CON_CON;
167
[3013]168 if ( (fh = roar_vio_simple_new_stream_obj(vio, &(g_cons.con), &(g_cons.stream),
169                                           info->rate, info->channels, info->bits, info->codec,
170                                           ROAR_DIR_BIDIR
171                                          )) == -1 )
[2329]172  return -1;
173
174 g_cons.state |= CON_STREAM;
175
176 return 0;
[2128]177}
178
[2330]179#define _SET_META(ivar,itype) if ( (ivar) != NULL ) {  \
180                              meta.value = (ivar);     \
181                              meta.type  = (itype);    \
182                              roar_stream_meta_set(&(g_cons.con), &(g_cons.stream), ROAR_META_MODE_SET, &meta); \
183                              }
184int set_meta (void) {
185 struct roar_meta   meta;
186
187 meta.value  = g_meta.tmp.value;
188 meta.key[0] = 0;
189 meta.type   = ROAR_META_TYPE_NONE;
190
191 roar_stream_meta_set(&(g_cons.con), &(g_cons.stream), ROAR_META_MODE_CLEAR, &meta);
192
193 _SET_META(g_meta.thumbnail, ROAR_META_TYPE_THUMBNAIL);
194 _SET_META(g_meta.loc,       ROAR_META_TYPE_LOCATION);
195 _SET_META(g_meta.hp,        ROAR_META_TYPE_HOMEPAGE);
196 _SET_META(g_meta.org,       ROAR_META_TYPE_ORGANIZATION);
197
198 if ( g_meta.nick != NULL ) {
199  if ( g_meta.rn  != NULL ) {
200   snprintf(g_meta.tmp.value, LIBROAR_BUFFER_MSGDATA-1, "%s (%s)", g_meta.rn, g_meta.nick);
201   g_meta.tmp.value[LIBROAR_BUFFER_MSGDATA-1] = 0;
202   _SET_META(g_meta.tmp.value, ROAR_META_TYPE_AUTHOR);
203  } else {
204   _SET_META(g_meta.nick, ROAR_META_TYPE_AUTHOR);
205  }
206 } else {
207  if ( g_meta.rn  != NULL ) {
208   _SET_META(g_meta.rn, ROAR_META_TYPE_AUTHOR);
209  }
210 }
211
212 // TODO: make this more nice...
213 if ( g_meta.email != NULL ) {
214  if ( g_meta.nick != NULL ) {
215   if ( g_meta.rn != NULL ) {
216    snprintf(g_meta.tmp.value, LIBROAR_BUFFER_MSGDATA-1, "%s (%s) <%s>", g_meta.rn, g_meta.nick, g_meta.email);
217   } else {
218    snprintf(g_meta.tmp.value, LIBROAR_BUFFER_MSGDATA-1, "%s <%s>", g_meta.nick, g_meta.email);
219   }
220  } else {
221   if ( g_meta.rn != NULL ) {
222    snprintf(g_meta.tmp.value, LIBROAR_BUFFER_MSGDATA-1, "%s <%s>", g_meta.rn, g_meta.email);
223   } else {
224    snprintf(g_meta.tmp.value, LIBROAR_BUFFER_MSGDATA-1, "<%s>", g_meta.email);
225   }
226  }
227  g_meta.tmp.value[LIBROAR_BUFFER_MSGDATA-1] = 0;
228  _SET_META(g_meta.tmp.value, ROAR_META_TYPE_CONTACT);
229 }
230
231 return 0;
232}
233
[2215]234#ifdef _SPEEX_API_OLD
[2141]235int anti_echo_speex16(int16_t * buf, int16_t * aebuf, size_t len, struct roar_audio_info * info) {
236 static SpeexEchoState * state = NULL;
237 size_t samples = info->rate / TIMEDIV;
238 static int16_t * obuf = NULL;
239
240 if ( info->channels != 1 )
241  return -1;
242
243 if (len != samples)
244  return -1;
245
[2142]246 ROAR_DBG("anti_echo_speex16(*) = ?");
247
[2141]248 if ( state == NULL ) {
249  if ( (state = speex_echo_state_init(samples, 100*samples)) == NULL )
250   return -1;
251
252  // todo: set sample rate.
253 }
254
[2142]255 ROAR_DBG("anti_echo_speex16(*) = ?");
256
[2141]257 if ( obuf == NULL ) {
258  if ( (obuf = malloc(2*samples)) == NULL )
259   return -1;
260 }
261
[2142]262 ROAR_DBG("anti_echo_speex16(*) = ?");
263
[2141]264/*
265 speex_echo_cancellation(state, buf, aebuf, obuf);
266*/
267
268 speex_echo_cancel(state, buf, aebuf, obuf, NULL);
269
270 memcpy(buf, obuf, 2*samples);
271
[2142]272 ROAR_DBG("anti_echo_speex16(*) = 0");
273
[2141]274 return 0;
275}
276#endif
277
278int anti_echo16(int16_t * buf, int16_t * aebuf, size_t len, struct roar_audio_info * info) {
[2140]279 size_t i;
280
[3787]281 (void)info;
282
[2140]283 switch (g_conf.antiecho) {
284  case AE_NONE:
285    return 0;
286   break;
287  case AE_SIMPLE:
288    for (i = 0; i < len; i++)
289     buf[i] -= aebuf[i];
[2293]290    return 0;
[2140]291   break;
[2215]292#ifdef _SPEEX_API_OLD
[2141]293  case AE_SPEEX:
294    return anti_echo_speex16(buf, aebuf, len, info);
295   break;
296#endif
[2293]297  case AE_ROARD:
298    return 0;
299   break;
[2140]300  default:
301    return -1;
302   break;
303 }
304
305 return -1;
306}
307
[2321]308int zero_if_noise16 (int16_t * data, size_t samples) {
309 int64_t rms = roar_rms2_1_16(data, samples);
310
[2322]311 if ( rms < g_conf.dtx_threshold ) {
312  if ( dtx_counter ) {
313   dtx_counter--;
314  } else {
315   memset(data, 0, samples*2);
316  }
317 } else {
318  dtx_counter = DTX_F;
319 }
[2321]320
321 return 0;
322}
323
[2128]324int run_stream (struct roar_vio_calls * s0, struct roar_vio_calls * s1, struct roar_audio_info * info) {
[2129]325 size_t len;
[2140]326 void * outbuf, * micbuf;
327 ssize_t outlen, miclen;
[2993]328 unsigned long int pkg_count = 0;
[2129]329
[2312]330 ROAR_DBG("run_stream(*): g_conf.samples = %i, info->bits = %i", g_conf.samples, info->bits);
[2166]331 len = g_conf.samples * info->bits / 8;
[2312]332 ROAR_DBG("run_stream(*): len=%lu", (unsigned long) len);
[2129]333
[2140]334 if ( (outbuf = malloc(2*len)) == NULL )
[2129]335  return -1;
336
[2140]337 micbuf = outbuf + len;
338
[2129]339 while (1) {
[2140]340  if ( (miclen = roar_vio_read(s0, micbuf, len)) <= 0 )
[2129]341   break;
[2321]342
[2977]343  if ( roardsp_fchain_num(&(g_filterchains.input)) ) {
344   if ( roardsp_fchain_calc(&(g_filterchains.input), micbuf, len) == -1 )
345    break;
346  }
347
[2321]348  if ( g_conf.dtx_threshold > 0 )
349   if ( info->bits == 16 )
350    zero_if_noise16(micbuf, miclen/2);
351
[2185]352  if ( g_conf.transcode ) {
353   if ( roar_bixcoder_write_packet(transcoder, micbuf, miclen) == -1 )
354    break;
355  } else {
356   if ( roar_vio_write(s1, micbuf, miclen) != miclen )
357    break;
358  }
359
[2993]360  if ( g_conf.ioflush_interval != -1 ) {
361   if ( !(pkg_count % g_conf.ioflush_interval) )
362    roar_vio_sync(s1);
363  }
364
[2185]365  if ( g_conf.transcode ) {
[2312]366   ROAR_DBG("run_stream(*): outbuf=%p, len=%lu", outbuf, (unsigned long) len);
[2185]367   if ( roar_bixcoder_read_packet(transcoder, outbuf, len) == -1 )
368    break;
369
370   outlen = len;
371  } else {
372   if ( (outlen = roar_vio_read(s1, outbuf, len)) <= 0 )
373    break;
374  }
[2140]375
[2162]376  if ( g_conf.antiecho != AE_NONE && info->bits == 16 )
[2141]377   anti_echo16(outbuf, micbuf, ROAR_MIN(miclen, outlen)/2, info);
[2140]378
[2977]379  if ( roardsp_fchain_num(&(g_filterchains.output)) ) {
380   if ( roardsp_fchain_calc(&(g_filterchains.output), outbuf, outlen) == -1 )
381    break;
382  }
383
[2140]384  if ( roar_vio_write(s0, outbuf, outlen) != outlen )
[2129]385   break;
[2993]386
387  pkg_count++;
[2129]388 }
389
[2140]390 free(outbuf);
[2129]391
392 return 0;
[2128]393}
394
[2124]395int main (int argc, char * argv[]) {
[2125]396 struct roar_audio_info info = {.rate     = ROAR_RATE_DEFAULT,
397                                .bits     = ROAR_BITS_DEFAULT,
398                                .channels = ROAR_CHANNELS_DEFAULT,
399                                .codec    = ROAR_CODEC_DEFAULT
400                               };
[2167]401 struct roar_audio_info dinfo;
[2986]402 struct roar_vio_calls dvio, svio, svio_jumbo, svio_real;
403 struct roar_vio_calls * svio_p;
[2991]404 struct roardsp_filter * filter;
[2126]405 char * driver   = DRIVER;
406 char * device   = NULL;
[2124]407 char * server   = NULL;
408 char * k;
409 int    i;
[3007]410 union {
411  int32_t i32;
412  size_t  size;
413 } tmp;
[2124]414
[2140]415 memset(&g_conf, 0, sizeof(g_conf));
416
[2993]417 g_conf.antiecho         = AE_ROARD;
418 g_conf.dtx_threshold    = -1;
419 g_conf.ioflush_interval = -1;
[2140]420
[2329]421 memset(&g_cons, 0, sizeof(g_cons));
422 g_cons.state = CON_NONE;
423
[2330]424 memset(&g_meta, 0, sizeof(g_meta));
425
[2977]426 roardsp_fchain_init(&(g_filterchains.input));
427 roardsp_fchain_init(&(g_filterchains.output));
428
[2124]429 for (i = 1; i < argc; i++) {
430  k = argv[i];
431
432  if ( strcmp(k, "--server") == 0 ) {
433   server = argv[++i];
[2986]434  } else if ( strcmp(k, "--jumbo-mtu") == 0 ) {
435   g_conf.jumbo_mtu = atoi(argv[++i]);
[2993]436  } else if ( strcmp(k, "--io-flush") == 0 ) {
437   g_conf.ioflush_interval = atoi(argv[++i]);
[2124]438  } else if ( strcmp(k, "--rate") == 0 ) {
[4883]439   info.rate = roar_str2rate(argv[++i]);
[2124]440  } else if ( strcmp(k, "--bits") == 0 ) {
[4883]441   info.bits = roar_str2bits(argv[++i]);
[2124]442  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) {
[4883]443   info.channels = roar_str2channels(argv[++i]);
[2991]444
445  } else if ( strcmp(k, "--afi-downmix") == 0 ) {
446   g_conf.filter.in.downmix = 1;
447  } else if ( strcmp(k, "--afi-lowpass") == 0 ) {
448   g_conf.filter.in.lowp_freq = atof(argv[++i]);
[3006]449  } else if ( strcmp(k, "--afi-speex-prep") == 0 ) {
450   g_conf.filter.in.speex_prep = 1;
[3007]451  } else if ( strcmp(k, "--afi-speex-denoise") == 0 ) {
452   g_conf.filter.in.speex_prep = 1;
453   g_conf.filter.in.speex_prep_denoise = 1;
454  } else if ( strcmp(k, "--afi-speex-agc") == 0 ) {
455   g_conf.filter.in.speex_prep = 1;
456   g_conf.filter.in.speex_prep_agc = 1;
457  } else if ( strcmp(k, "--afi-speex-vad") == 0 ) {
458   g_conf.filter.in.speex_prep = 1;
459   g_conf.filter.in.speex_prep_vad = 1;
[2991]460
[2124]461  } else if ( strcmp(k, "--codec") == 0 ) {
[2125]462   info.codec = roar_str2codec(argv[++i]);
[2991]463
[2127]464  } else if ( strcmp(k, "--driver") == 0 ) {
465   driver = argv[++i];
466  } else if ( strcmp(k, "--device") == 0 ) {
467   device = argv[++i];
[2141]468  } else if ( strcmp(k, "--antiecho") == 0 ) {
469   k = argv[++i];
470   if ( !strcmp(k, "none") ) {
471    g_conf.antiecho = AE_NONE;
472   } else if ( !strcmp(k, "simple") ) {
473    g_conf.antiecho = AE_SIMPLE;
474   } else if ( !strcmp(k, "speex") ) {
475    g_conf.antiecho = AE_SPEEX;
476   } else if ( !strcmp(k, "roard") ) {
477    g_conf.antiecho = AE_ROARD;
478   } else {
479    fprintf(stderr, "Error: unknown mode: %s\n", k);
480    return 1;
481   }
[2321]482  } else if ( strcmp(k, "--threshold") == 0 ) {
483   g_conf.dtx_threshold = atol(argv[++i]);
484
485   // use threshold^2 or threshold < 0 for not using DTX
486   if ( g_conf.dtx_threshold > 0 )
487    g_conf.dtx_threshold *= g_conf.dtx_threshold;
[2167]488  } else if ( strcmp(k, "--transcode") == 0 ) {
489   g_conf.transcode = 1;
[2330]490
491  // META DATA:
492  } else if ( strcmp(k, "--m-rn") == 0 ) {
493   g_meta.rn = argv[++i];
494  } else if ( strcmp(k, "--m-nick") == 0 ) {
495   g_meta.nick = argv[++i];
496  } else if ( strcmp(k, "--m-email") == 0 ) {
497   g_meta.email = argv[++i];
498  } else if ( strcmp(k, "--m-hp") == 0 ) {
499   g_meta.hp = argv[++i];
500  } else if ( strcmp(k, "--m-thumbn") == 0 ) {
501   g_meta.thumbnail = argv[++i];
502  } else if ( strcmp(k, "--m-loc") == 0 ) {
503   g_meta.loc = argv[++i];
504  } else if ( strcmp(k, "--m-org") == 0 ) {
505   g_meta.org = argv[++i];
506
507
[2124]508  } else if ( strcmp(k, "--help") == 0 ) {
509   usage();
510   return 0;
511  } else {
512   fprintf(stderr, "Error: unknown argument: %s\n", k);
513   usage();
514   return 1;
515  }
516 }
517
[2568]518 // ignore errors, maybe it will work even if this fails
519 // (btw. it will never fail without crashing the rest of the app ;)
520 roar_libroar_set_server(server);
521
[2293]522 if ( g_conf.antiecho == AE_SPEEX ) {
523  ROAR_WARN("Speex Antiecho is obsolete and may be removed in future versions. Use --antiecho roard");
524 }
525
[2166]526 g_conf.samples = info.channels * info.rate / TIMEDIV;
527
[2167]528 memcpy(&dinfo, &info, sizeof(dinfo));
529
530 if ( g_conf.transcode ) {
531  dinfo.bits  = 16;
532  dinfo.codec = ROAR_CODEC_DEFAULT;
533
534  switch (info.codec) {
535   case ROAR_CODEC_ALAW:
536   case ROAR_CODEC_MULAW:
537     info.bits = 8;
538    break;
539   case ROAR_CODEC_ROAR_CELT:
540     info.bits = 16;
541    break;
542   case ROAR_CODEC_ROAR_SPEEX:
543     info.bits = 16;
544    break;
545  }
546 }
547
548 if ( roar_cdriver_open(&dvio, driver, device, &dinfo, ROAR_DIR_BIDIR) == -1 ) {
[2570]549  ROAR_ERR("Can not open sound card.");
[2126]550  return 1;
551 }
552
[2312]553 ROAR_DBG("main(*): CALL open_stream(&svio, server, &info)");
[2570]554 if ( open_stream(&svio_real, server, &info) == -1 ) {
555  ROAR_ERR("Can not open connection to server.");
[2128]556  roar_vio_close(&dvio);
557  return 2;
558 }
[2312]559 ROAR_DBG("main(*): RET");
[2128]560
[2570]561 if ( roar_vio_open_re(&svio, &svio_real) == -1 ) {
562  ROAR_ERR("Can not open connection to server (RE VIO).");
563  roar_vio_close(&dvio);
564  return 2;
565 }
566
[2986]567 if ( g_conf.jumbo_mtu ) {
568  if ( roar_vio_open_jumbo(&svio_jumbo, &svio, g_conf.jumbo_mtu) == -1 ) {
569   roar_vio_close(&dvio);
570   roar_vio_close(&svio);
571   return 2;
572  }
573  svio_p = &svio_jumbo;
574 } else {
575  svio_p = &svio;
576 }
577
[2330]578 set_meta();
579
[3008]580 if ( g_conf.transcode ) {
581  dinfo.codec = info.codec;
582
583  if ( roar_bixcoder_init(transcoder, &dinfo, svio_p) == -1 ) {
584   roar_vio_close(&svio);
585   roar_vio_close(&dvio);
586   return 10;
587  }
588
589  // ignore errors as it may also work if this fails
590  roar_bixcoder_write_header(transcoder);
591  roar_bixcoder_read_header(transcoder);
592
593  g_conf.samples = 8 * roar_bixcoder_packet_size(transcoder, -1) / dinfo.bits;
594 }
595
[2991]596#define _err(x) roar_vio_close(&dvio); roar_vio_close(&svio); return (x)
597
598 if ( g_conf.filter.in.downmix ) {
599  if ( roardsp_filter_new(&filter, &(g_cons.stream), ROARDSP_FILTER_DOWNMIX) == -1 ) {
600   _err(2);
601  }
602
603  if ( roardsp_fchain_add(&(g_filterchains.input), filter) == -1 ) {
604   _err(2);
605  }
606 }
607
608 if ( g_conf.filter.in.lowp_freq > 1 ) {
609  if ( roardsp_filter_new(&filter, &(g_cons.stream), ROARDSP_FILTER_LOWP) == -1 ) {
610   _err(2);
611  }
612
613  if ( roardsp_filter_ctl(filter, ROARDSP_FCTL_FREQ, &(g_conf.filter.in.lowp_freq)) == -1 ) {
614   _err(2);
615  }
616
617  if ( roardsp_fchain_add(&(g_filterchains.input), filter) == -1 ) {
618   _err(2);
619  }
620 }
621
[3006]622 if ( g_conf.filter.in.speex_prep ) {
623  if ( roardsp_filter_new(&filter, &(g_cons.stream), ROARDSP_FILTER_SPEEX_PREP) == -1 ) {
624   _err(2);
625  }
626
[3007]627  tmp.size = g_conf.samples;
628  if ( roardsp_filter_ctl(filter, ROARDSP_FCTL_PACKET_SIZE, &tmp) == -1 ) {
629   _err(2);
630  }
631
632  tmp.i32 = 0;
633
634  if ( g_conf.filter.in.speex_prep_denoise )
635   tmp.i32 |= ROARDSP_SPEEX_PREP_DENOISE_ON;
636
637  if ( g_conf.filter.in.speex_prep_agc )
638   tmp.i32 |= ROARDSP_SPEEX_PREP_AGC_ON;
639
640  if ( g_conf.filter.in.speex_prep_vad )
641   tmp.i32 |= ROARDSP_SPEEX_PREP_VAD_ON;
642
643  if ( roardsp_filter_ctl(filter, ROARDSP_FCTL_MODE, &tmp) == -1 ) {
644   _err(2);
645  }
646
[3006]647  if ( roardsp_fchain_add(&(g_filterchains.input), filter) == -1 ) {
648   _err(2);
649  }
650 }
651
[2991]652#undef _err
653
[2312]654 ROAR_DBG("main(*): CALL run_stream(&dvio, &svio, &info);");
[2986]655 run_stream(&dvio, svio_p, &info);
[2312]656 ROAR_DBG("main(*): RET");
[2128]657
[2185]658 roar_bixcoder_close(transcoder);
659
[2986]660 roar_vio_close(svio_p);
[2126]661 roar_vio_close(&dvio);
662
[2977]663 roardsp_fchain_uninit(&(g_filterchains.input));
664 roardsp_fchain_uninit(&(g_filterchains.output));
665
[2329]666 roar_disconnect(&(g_cons.con));
667
[2124]668 return 0;
669}
670
671//ll
Note: See TracBrowser for help on using the repository browser.