source: roaraudio/roarclients/roarphone.c @ 3013:fc3c4811bacd

Last change on this file since 3013:fc3c4811bacd was 3013:fc3c4811bacd, checked in by phi, 15 years ago

use vio

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