lower stack allocation
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7557 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
58670275cf
commit
e9c6eaabc1
|
@ -248,7 +248,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
|||
switch_core_session_message_t *message = NULL;
|
||||
switch_frame_t *read_frame = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
uint8_t abuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
uint8_t *abuf = NULL;
|
||||
int timelimit = 60;
|
||||
const char *var = switch_channel_get_variable(caller_channel, "call_timeout");
|
||||
switch_time_t start = 0;
|
||||
|
@ -290,8 +290,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
|
||||
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
|
||||
write_frame.data = abuf;
|
||||
write_frame.buflen = sizeof(abuf);
|
||||
write_frame.data = abuf = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
|
||||
|
||||
write_frame.codec = &write_codec;
|
||||
write_frame.datalen = read_codec->implementation->bytes_per_frame;
|
||||
|
@ -376,9 +376,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
|||
|
||||
if (read_frame && !pass) {
|
||||
if (ringback.fh) {
|
||||
uint8_t fbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
switch_size_t mlen, olen;
|
||||
unsigned int pos = 0;
|
||||
uint8_t *fbuf = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
|
||||
if (ringback.asis) {
|
||||
mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
|
||||
|
@ -400,6 +400,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
|||
}
|
||||
write_frame.data = fbuf;
|
||||
write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
|
||||
switch_safe_free(fbuf);
|
||||
} else if (ringback.audio_buffer) {
|
||||
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
|
||||
write_frame.data,
|
||||
|
@ -433,6 +434,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
|||
}
|
||||
switch_core_codec_destroy(&write_codec);
|
||||
}
|
||||
switch_safe_free(abuf);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -467,7 +469,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
int32_t sleep_ms = 1000, try = 0, retries = 1, idx = IDX_NADA;
|
||||
switch_codec_t write_codec = { 0 };
|
||||
switch_frame_t write_frame = { 0 };
|
||||
uint8_t fdata[SWITCH_RECOMMENDED_BUFFER_SIZE], pass = 0;
|
||||
uint8_t *fdata;
|
||||
uint8_t pass = 0;
|
||||
char key[80] = SWITCH_BLANK_STRING, file[512] = SWITCH_BLANK_STRING, *odata, *var;
|
||||
switch_call_cause_t reason = SWITCH_CAUSE_UNALLOCATED;
|
||||
uint8_t to = 0;
|
||||
|
@ -481,7 +484,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
uint8_t ring_ready = 0;
|
||||
char *loop_data = NULL;
|
||||
|
||||
write_frame.data = fdata;
|
||||
write_frame.data = fdata = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
|
||||
*bleg = NULL;
|
||||
odata = strdup(bridgeto);
|
||||
|
@ -1033,9 +1036,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
|
||||
if (ring_ready && read_frame && !pass) {
|
||||
if (ringback.fh) {
|
||||
uint8_t abuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
switch_size_t mlen, olen;
|
||||
unsigned int pos = 0;
|
||||
uint8_t *abuf = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
|
||||
if (ringback.asis) {
|
||||
mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
|
||||
|
@ -1057,6 +1060,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
}
|
||||
write_frame.data = abuf;
|
||||
write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
|
||||
switch_safe_free(abuf);
|
||||
} else if (ringback.audio_buffer) {
|
||||
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
|
||||
write_frame.data,
|
||||
|
@ -1244,6 +1248,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
if (var_event) {
|
||||
switch_event_destroy(&var_event);
|
||||
}
|
||||
switch_safe_free(fdata);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue