add dynamic buffers

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2583 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-09-08 18:57:24 +00:00
parent 4960fbc73f
commit f689b62fb6
9 changed files with 143 additions and 14 deletions
@@ -40,6 +40,10 @@ static char *global_cf_name = "conference.conf";
#define CONF_EVENT_MAINT "conference::maintenence"
#define CONF_DEFAULT_LEADIN 20
#define CONF_DBLOCK_SIZE CONF_BUFFER_SIZE
#define CONF_DBUFFER_SIZE CONF_BUFFER_SIZE
#define CONF_DBUFFER_MAX 0
typedef enum {
FILE_STOP_CURRENT,
FILE_STOP_ALL
@@ -2355,7 +2359,7 @@ static void conference_function(switch_core_session_t *session, char *data)
switch_core_session_get_pool(session));
/* Setup an audio buffer for the resampled audio */
if (switch_buffer_create(pool, &member.resample_buffer, CONF_BUFFER_SIZE) != SWITCH_STATUS_SUCCESS) {
if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
goto done;
}
@@ -2381,13 +2385,13 @@ static void conference_function(switch_core_session_t *session, char *data)
}
/* Setup an audio buffer for the incoming audio */
if (switch_buffer_create(pool, &member.audio_buffer, CONF_BUFFER_SIZE) != SWITCH_STATUS_SUCCESS) {
if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
goto codec_done1;
}
/* Setup an audio buffer for the outgoing audio */
if (switch_buffer_create(pool, &member.mux_buffer, CONF_BUFFER_SIZE) != SWITCH_STATUS_SUCCESS) {
if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
goto codec_done1;
}
@@ -2435,6 +2439,10 @@ static void conference_function(switch_core_session_t *session, char *data)
switch_core_codec_destroy(&member.write_codec);
done:
switch_buffer_destroy(&member.resample_buffer);
switch_buffer_destroy(&member.audio_buffer);
switch_buffer_destroy(&member.mux_buffer);
/* Release the config registry handle */
if (cxml) {
switch_xml_free(cxml);
+5 -2
View File
@@ -42,7 +42,8 @@
#include <swift.h>
#include <switch.h>
#define MY_BUF_LEN 1024 * 256
#define MY_BUF_LEN 1024 * 32
#define MY_BLOCK_SIZE MY_BUF_LEN
static const char modname[] = "mod_cepstral";
@@ -119,7 +120,7 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
return SWITCH_STATUS_MEMERR;
}
if (switch_buffer_create(sh->memory_pool, &cepstral->audio_buffer, MY_BUF_LEN) != SWITCH_STATUS_SUCCESS) {
if (switch_buffer_create_dynamic(&cepstral->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Buffer Failed!\n");
return SWITCH_STATUS_MEMERR;
}
@@ -195,6 +196,8 @@ static switch_status_t cepstral_speech_close(switch_speech_handle_t *sh, switch_
cepstral->port = NULL;
//cepstral->engine = NULL;
switch_buffer_destroy(&cepstral->audio_buffer);
return SWITCH_STATUS_SUCCESS;
}
+3 -1
View File
@@ -370,6 +370,8 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
teletone_destroy_session(&tech_pvt->tone_session);
switch_buffer_destroy(&tech_pvt->dtmf_buffer);
return SWITCH_STATUS_SUCCESS;
}
@@ -623,7 +625,7 @@ static switch_status_t wanpipe_send_dtmf(switch_core_session_t *session, char *d
if (!tech_pvt->dtmf_buffer) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocate DTMF Buffer....");
if (switch_buffer_create(switch_core_session_get_pool(session), &tech_pvt->dtmf_buffer, 3192) != SWITCH_STATUS_SUCCESS) {
if (switch_buffer_create_dynamic(&tech_pvt->dtmf_buffer, 1024, 3192, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Failed to allocate DTMF Buffer!\n");
return SWITCH_STATUS_FALSE;
} else {
@@ -32,7 +32,8 @@
#ifndef HAVE_CURL
#define HAVE_CURL
#endif
#define JS_BUFFER_SIZE 131072
#define JS_BUFFER_SIZE 1024 * 32
#define JS_BLOCK_SIZE JS_BUFFER_SIZE
#ifdef __ICC
#pragma warning (disable:310 193 1418)
#endif
@@ -2007,7 +2008,7 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
}
}
switch_buffer_create(pool, &tto->audio_buffer, JS_BUFFER_SIZE);
switch_buffer_create_dynamic(&tto->audio_buffer, JS_BLOCK_SIZE, JS_BUFFER_SIZE, 0);
tto->pool = pool;
tto->obj = obj;
tto->cx = cx;
@@ -2027,6 +2028,8 @@ static void teletone_destroy(JSContext *cx, JSObject *obj)
switch_core_timer_destroy(tto->timer);
}
teletone_destroy_session(&tto->ts);
switch_buffer_destroy(&tto->audio_buffer);
switch_buffer_destroy(&tto->loop_buffer);
switch_core_codec_destroy(&tto->codec);
pool = tto->pool;
tto->pool = NULL;
@@ -2088,7 +2091,7 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
}
loops--;
if (!tto->loop_buffer) {
switch_buffer_create(tto->pool, &tto->loop_buffer, JS_BUFFER_SIZE);
switch_buffer_create_dynamic(&tto->loop_buffer, JS_BLOCK_SIZE, JS_BUFFER_SIZE, 0);
}
}