From 573058c6d3acc414912b3cb2d3e3a751e8d4da89 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 21 Mar 2007 18:50:51 +0000 Subject: [PATCH] shhhh git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4716 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_resample.h | 8 +++++++ .../mod_conference/mod_conference.c | 2 +- src/switch_resample.c | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index c828230719..d2ba8a42bb 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -154,6 +154,14 @@ SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len); */ SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len); +/*! + \brief Generate static noise + \param data the audio data buffer + \param samples the number of 2 byte samples + \param divisor the volume factor + */ +SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor); + /*! \brief Change the volume of a signed linear audio frame \param data the audio data diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 189b2394a5..5d04ae9f0e 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1696,7 +1696,7 @@ static void conference_loop_output(conference_member_t *member) } else { if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) { - memset(write_frame.data, 255, bytes); + switch_generate_sln_silence(write_frame.data, samples, 1400); write_frame.datalen = bytes; write_frame.samples = samples; write_frame.timestamp = timer.samplecount; diff --git a/src/switch_resample.c b/src/switch_resample.c index d1bf50492b..af6321fa9f 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -183,6 +183,27 @@ 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,i; + uint32_t sum_rnd = 0; + + assert(divisor); + + for(i = 0; i < samples; i++, sum_rnd = 0) { + for(x = 0; x < 7; x++) { + rnd = (int16_t) (rand() * sizeof(int16_t)); + sum_rnd += rnd; + } + switch_normalize_to_16bit(sum_rnd); + *data = (int16_t) sum_rnd; + *data /= (int)divisor; + + data++; + } +} + + SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol) { double newrate = 0;