diff --git a/src/switch_apr.c b/src/switch_apr.c index 104f50b59a..9a09c4ad23 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -761,9 +761,9 @@ SWITCH_DECLARE(switch_status_t) switch_socket_atmark(switch_socket_t *sock, int 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); diff --git a/src/switch_channel.c b/src/switch_channel.c index 70cf968691..1d8f8797e5 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1647,8 +1647,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel 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 { @@ -1679,7 +1679,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel 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); @@ -1784,7 +1784,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t * 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); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 00b24c9eb2..28e0fe5cdc 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -64,8 +64,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, 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, @@ -94,6 +93,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, } + if (!write_frame.datalen) { + sval = 0; + } + cng_frame.data = data; cng_frame.datalen = 2; cng_frame.buflen = 2; @@ -177,7 +180,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, 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 { diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 8bb21d6f29..35d562c557 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -41,7 +41,11 @@ static switch_status_t originate_on_consume_media_transmit(switch_core_session_t 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); + } } }