forked from Mirrors/freeswitch
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1215 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
da448c26a3
commit
a84fce3eb9
|
@ -440,14 +440,14 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
||||||
*frame = NULL;
|
*frame = NULL;
|
||||||
memset(tech_pvt->databuf, 0, sizeof(tech_pvt->databuf));
|
memset(tech_pvt->databuf, 0, sizeof(tech_pvt->databuf));
|
||||||
while (bytes < globals.mtu) {
|
while (bytes < globals.mtu) {
|
||||||
|
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
if ((res = sangoma_socket_waitfor(tech_pvt->socket, timeout, POLLIN | POLLERR)) < 0) {
|
|
||||||
|
|
||||||
|
if (sangoma_socket_waitfor(tech_pvt->socket, 1000, POLLIN | POLLERR | POLLHUP) <= 0) {
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
} else if (res == 0) {
|
|
||||||
tech_pvt->read_frame.datalen = 0;
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = sangoma_readmsg_socket(tech_pvt->socket,
|
if ((res = sangoma_readmsg_socket(tech_pvt->socket,
|
||||||
|
@ -464,7 +464,7 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
||||||
bp += bytes;
|
bp += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
if (!bytes || switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,9 +527,9 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sangoma_socket_waitfor(tech_pvt->socket, 1000, POLLOUT | POLLERR | POLLHUP) <= 0) {
|
||||||
sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DOTRACE
|
#ifdef DOTRACE
|
||||||
write(tech_pvt->fd, dtmf, (int) bread);
|
write(tech_pvt->fd, dtmf, (int) bread);
|
||||||
|
@ -565,12 +565,13 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr
|
||||||
|
|
||||||
while (bytes > 0) {
|
while (bytes > 0) {
|
||||||
unsigned int towrite;
|
unsigned int towrite;
|
||||||
|
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
#if 0
|
||||||
|
if (sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP) <= 0) {
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
|
||||||
#ifdef DOTRACE
|
#ifdef DOTRACE
|
||||||
write(tech_pvt->fd, bp, (int) globals.mtu);
|
write(tech_pvt->fd, bp, (int) globals.mtu);
|
||||||
#endif
|
#endif
|
||||||
|
@ -649,8 +650,10 @@ static switch_status wanpipe_kill_channel(switch_core_session *session, int sig)
|
||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
assert(tech_pvt != NULL);
|
assert(tech_pvt != NULL);
|
||||||
|
|
||||||
|
|
||||||
switch_set_flag(tech_pvt, TFLAG_BYE);
|
switch_set_flag(tech_pvt, TFLAG_BYE);
|
||||||
switch_clear_flag(tech_pvt, TFLAG_MEDIA);
|
switch_clear_flag(tech_pvt, TFLAG_MEDIA);
|
||||||
|
sangoma_socket_close(&tech_pvt->socket);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -793,7 +796,7 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||||
|
|
||||||
if (sangoma_span_chan_fromif(bchan, &span, &chan)) {
|
if (sangoma_span_chan_fromif(bchan, &span, &chan)) {
|
||||||
if ((tech_pvt->socket = sangoma_open_tdmapi_span_chan(span, chan)) < 0) {
|
if ((tech_pvt->socket = sangoma_open_tdmapi_span_chan(span, chan)) < 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span, chan, strerror(errno));
|
||||||
switch_core_session_destroy(new_session);
|
switch_core_session_destroy(new_session);
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -688,6 +688,7 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
|
||||||
int *stream_id_p;
|
int *stream_id_p;
|
||||||
int stream_id = 0, ans_a = 0, ans_b = 0;
|
int stream_id = 0, ans_a = 0, ans_b = 0;
|
||||||
switch_dtmf_callback_function dtmf_callback;
|
switch_dtmf_callback_function dtmf_callback;
|
||||||
|
switch_core_session_message msg = {0};
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
||||||
switch_channel *chan_a, *chan_b;
|
switch_channel *chan_a, *chan_b;
|
||||||
|
@ -760,17 +761,22 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
|
||||||
/* read audio from 1 channel and write it to the other */
|
/* read audio from 1 channel and write it to the other */
|
||||||
if (switch_core_session_read_frame(session_a, &read_frame, -1, stream_id) == SWITCH_STATUS_SUCCESS && read_frame->datalen) {
|
if (switch_core_session_read_frame(session_a, &read_frame, -1, stream_id) == SWITCH_STATUS_SUCCESS && read_frame->datalen) {
|
||||||
if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "write: %s Bad Frame....[%u] Bubye!\n", switch_channel_get_name(chan_b), read_frame->datalen);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "write: %s Bad Frame....[%u] Bubye!\n", switch_channel_get_name(chan_b), read_frame->datalen);
|
||||||
data->running = -1;
|
data->running = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "read: %s Bad Frame.... Bubye!\n", switch_channel_get_name(chan_a));
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "read: %s Bad Frame.... Bubye!\n", switch_channel_get_name(chan_a));
|
||||||
data->running = -1;
|
data->running = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//switch_yield(1000);
|
//switch_yield(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
|
||||||
|
msg.from = __FILE__;
|
||||||
|
switch_core_session_receive_message(session_a, &msg);
|
||||||
|
|
||||||
data->running = 0;
|
data->running = 0;
|
||||||
|
|
||||||
if (his_thread->running > 0 && switch_channel_test_flag(chan_a, CF_ORIGINATOR)) {
|
if (his_thread->running > 0 && switch_channel_test_flag(chan_a, CF_ORIGINATOR)) {
|
||||||
|
@ -936,6 +942,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
|
||||||
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
|
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
|
||||||
msg.from = __FILE__;
|
msg.from = __FILE__;
|
||||||
msg.pointer_arg = session;
|
msg.pointer_arg = session;
|
||||||
|
|
||||||
switch_core_session_receive_message(peer_session, &msg);
|
switch_core_session_receive_message(peer_session, &msg);
|
||||||
msg.pointer_arg = peer_session;
|
msg.pointer_arg = peer_session;
|
||||||
switch_core_session_receive_message(session, &msg);
|
switch_core_session_receive_message(session, &msg);
|
||||||
|
@ -944,11 +951,6 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
|
||||||
switch_core_session_launch_thread(peer_session, audio_bridge_thread, (void *) &other_audio_thread);
|
switch_core_session_launch_thread(peer_session, audio_bridge_thread, (void *) &other_audio_thread);
|
||||||
audio_bridge_thread(NULL, (void *) &this_audio_thread);
|
audio_bridge_thread(NULL, (void *) &this_audio_thread);
|
||||||
|
|
||||||
msg.pointer_arg = NULL;
|
|
||||||
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
|
|
||||||
switch_core_session_receive_message(peer_session, &msg);
|
|
||||||
switch_core_session_receive_message(session, &msg);
|
|
||||||
|
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_channel_event_set_data(caller_channel, event);
|
switch_channel_event_set_data(caller_channel, event);
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
|
|
Loading…
Reference in New Issue