[Freeswitch-svn] [commit] r7557 - freeswitch/trunk/src
Freeswitch SVN
mikej at freeswitch.org
Fri Feb 8 13:26:12 EST 2008
Author: mikej
Date: Fri Feb 8 13:26:11 2008
New Revision: 7557
Modified:
freeswitch/trunk/src/switch_ivr_originate.c
Log:
lower stack allocation
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Fri Feb 8 13:26:11 2008
@@ -248,7 +248,7 @@
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_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 @@
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 @@
}
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_core_codec_destroy(&write_codec);
}
+ switch_safe_free(abuf);
return status;
}
@@ -467,7 +469,8 @@
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 @@
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 @@
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 @@
}
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 @@
if (var_event) {
switch_event_destroy(&var_event);
}
+ switch_safe_free(fdata);
return status;
}
More information about the Freeswitch-svn
mailing list