allow -1 as silence generation divisor to specify only zeroes silence

This commit is contained in:
System Administrator 2011-05-25 23:16:24 -04:00
parent 267d9cbc3a
commit 294a57fbcb
4 changed files with 19 additions and 4 deletions

View File

@ -62,6 +62,12 @@ SWITCH_BEGIN_EXTERN_C struct switch_unicast_conninfo {
};
typedef struct switch_unicast_conninfo switch_unicast_conninfo_t;
#define SWITCH_IVR_VERIFY_SILENCE_DIVISOR(divisor) \
do { \
if ((divisor) <= 0 && (divisor) != -1) { \
divisor = 400; \
} \
} while(0);
/**
* @defgroup switch_ivr IVR Library

View File

@ -154,7 +154,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
return SWITCH_STATUS_SUCCESS;
}
if (ms > 100 && (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE);
if (var) {
sval = atoi(var);
SWITCH_IVR_VERIFY_SILENCE_DIVISOR(sval);
}
if (ms > 100 && sval) {
switch_core_session_get_read_impl(session, &imp);
if (switch_core_codec_init(&codec,

View File

@ -910,9 +910,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
ringback.silence = atoi(p);
}
}
if (ringback.silence <= 0) {
ringback.silence = 400;
}
SWITCH_IVR_VERIFY_SILENCE_DIVISOR(ringback.silence);
} else {
switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
switch_buffer_set_loops(ringback.audio_buffer, -1);

View File

@ -190,6 +190,11 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples
assert(divisor);
if (divisor == (uint32_t)-1) {
memset(data, 0, sizeof(*data));
return;
}
for (i = 0; i < samples; i++, sum_rnd = 0) {
for (x = 0; x < 6; x++) {
rnd2 = rnd2 * 31821U + 13849U;