From 9d71c0eeabb83cefec7059ed7c26b75eecc99d45 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 3 Dec 2008 23:38:12 +0000 Subject: [PATCH] reduce cpu requirement for generated comfort noise git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10584 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_resample.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/switch_resample.c b/src/switch_resample.c index 49efe64139..9c33004f90 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -203,15 +203,17 @@ SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len) SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor) { - int16_t rnd, x; + int16_t rnd = 0, rnd2, x; uint32_t i; int sum_rnd = 0; assert(divisor); + rnd2 = (int16_t) (intptr_t) &data + switch_timestamp(NULL); + for (i = 0; i < samples; i++, sum_rnd = 0) { - for (x = 0; x < 7; x++) { - rnd = (int16_t) (rand() * sizeof(int16_t)); + for (x = 0; x < 10; x++) { + rnd += ((x + i) * rnd2); sum_rnd += rnd; } switch_normalize_to_16bit(sum_rnd);