diff --git a/libs/esl/src/esl_buffer.c b/libs/esl/src/esl_buffer.c index ac4247791b..61a04c0db8 100644 --- a/libs/esl/src/esl_buffer.c +++ b/libs/esl/src/esl_buffer.c @@ -58,15 +58,21 @@ ESL_DECLARE(esl_status_t) esl_buffer_create(esl_buffer_t **buffer, esl_size_t bl if (new_buffer) { memset(new_buffer, 0, sizeof(*new_buffer)); - if (start_len) { - new_buffer->data = malloc(start_len); - if (!new_buffer->data) { - free(new_buffer); - return ESL_FAIL; - } - memset(new_buffer->data, 0, start_len); + if (!start_len) { + start_len = 250; } + if (!block_size) { + block_size = start_len; + } + + new_buffer->data = malloc(start_len); + if (!new_buffer->data) { + free(new_buffer); + return ESL_FAIL; + } + memset(new_buffer->data, 0, start_len); + new_buffer->max_len = max_len; new_buffer->datalen = start_len; new_buffer->id = buffer_id++; diff --git a/libs/freetdm/src/ftdm_buffer.c b/libs/freetdm/src/ftdm_buffer.c index 48e8a36554..e241d24568 100644 --- a/libs/freetdm/src/ftdm_buffer.c +++ b/libs/freetdm/src/ftdm_buffer.c @@ -57,15 +57,21 @@ FT_DECLARE(ftdm_status_t) ftdm_buffer_create(ftdm_buffer_t **buffer, ftdm_size_t if (new_buffer) { memset(new_buffer, 0, sizeof(*new_buffer)); - if (start_len) { - new_buffer->data = ftdm_malloc(start_len); - if (!new_buffer->data) { - ftdm_safe_free(new_buffer); - return FTDM_MEMERR; - } - memset(new_buffer->data, 0, start_len); + if (!start_len) { + start_len = 250; } + if (!block_size) { + block_size = start_len; + } + + new_buffer->data = ftdm_malloc(start_len); + if (!new_buffer->data) { + ftdm_safe_free(new_buffer); + return FTDM_MEMERR; + } + memset(new_buffer->data, 0, start_len); + new_buffer->max_len = max_len; new_buffer->datalen = start_len; new_buffer->id = buffer_id++; diff --git a/src/switch_buffer.c b/src/switch_buffer.c index 58e524490d..deaa7a0599 100644 --- a/src/switch_buffer.c +++ b/src/switch_buffer.c @@ -118,15 +118,22 @@ SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **b if ((new_buffer = malloc(sizeof(*new_buffer)))) { memset(new_buffer, 0, sizeof(*new_buffer)); - if (start_len) { - if (!(new_buffer->data = malloc(start_len))) { - free(new_buffer); - *buffer = NULL; - return SWITCH_STATUS_MEMERR; - } - memset(new_buffer->data, 0, start_len); + if (!start_len) { + start_len = 250; } + if (!block_size) { + block_size = start_len; + } + + if (!(new_buffer->data = malloc(start_len))) { + free(new_buffer); + *buffer = NULL; + return SWITCH_STATUS_MEMERR; + } + + memset(new_buffer->data, 0, start_len); + new_buffer->max_len = max_len; new_buffer->datalen = start_len; new_buffer->id = buffer_id++; diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 9f10bf5955..7e54d7bfab 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -828,7 +828,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t if (!switch_channel_media_ready(session->channel)) { - if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) { + if (switch_channel_direction(session->channel == SWITCH_CALL_DIRECTION_OUTBOUND) || + switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot establish media. Media bug add failed.\n"); return SWITCH_STATUS_FALSE; } } @@ -890,8 +892,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t } bug->stop_time = stop_time; - bytes = bug->read_impl.decoded_bytes_per_packet; + if (!(bytes = bug->read_impl.decoded_bytes_per_packet)) { + bytes = 320; + } + if (!bug->flags) { bug->flags = (SMBF_READ_STREAM | SMBF_WRITE_STREAM); } @@ -1031,6 +1036,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_c switch_media_bug_t *new_bug = NULL, *cur = NULL, *bp = NULL, *last = NULL; int total = 0; + if (!switch_channel_media_ready(new_session->channel)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_WARNING, "Cannot transfer media bugs to a channel with no media.\n"); + return SWITCH_STATUS_FALSE; + } + switch_thread_rwlock_wrlock(orig_session->bug_rwlock); bp = orig_session->bugs; while (bp) {