SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len)
{
- apr_status_t r;
+ apr_status_t r = SWITCH_STATUS_GENERR;
- if ((r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) {
+ if (from && sock && (r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) {
from->port = ntohs(from->sa.sin.sin_port);
/* from->ipaddr_ptr = &(from->sa.sin.sin_addr);
* from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr);
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
msg.from = channel->name;
- status = switch_core_session_receive_message(channel->session, &msg);
-
+ status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
+
if (status == SWITCH_STATUS_SUCCESS) {
switch_channel_perform_mark_pre_answered(channel, file, func, line);
} else {
msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
msg.from = channel->name;
- status = switch_core_session_receive_message(channel->session, &msg);
+ status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
if (status == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
msg.message_id = SWITCH_MESSAGE_INDICATE_ANSWER;
msg.from = channel->name;
- status = switch_core_session_receive_message(channel->session, &msg);
+ status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
if (status == SWITCH_STATUS_SUCCESS) {
switch_channel_perform_mark_answered(channel, file, func, line);
media_ready = (switch_channel_media_ready(channel) && !switch_channel_test_flag(channel, CF_SERVICE));
-
- if (media_ready && (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var)) && sval >= 100) {
+ if (ms > 100 && media_ready && (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
switch_core_session_get_read_impl(session, &imp);
if (switch_core_codec_init(&codec,
}
+ if (!write_frame.datalen) {
+ sval = 0;
+ }
+
cng_frame.data = data;
cng_frame.datalen = 2;
cng_frame.buflen = 2;
break;
}
- if (sval) {
+ if (sval && write_frame.datalen) {
switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, sval);
switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
} else {
if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) {
while (switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) {
- switch_ivr_sleep(session, 10, SWITCH_FALSE, NULL);
+ if (!switch_channel_media_ready(channel)) {
+ switch_yield(10000);
+ } else {
+ switch_ivr_sleep(session, 10, SWITCH_FALSE, NULL);
+ }
}
}