提交 13336a93 authored 作者: Giovanni Maruzzelli's avatar Giovanni Maruzzelli

skypiax: fixed MODSKYPIAX-73, and manage when REMOTEHOLD hangs up

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16877 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 54510a37
...@@ -448,12 +448,20 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) ...@@ -448,12 +448,20 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
switch_core_codec_destroy(&tech_pvt->write_codec); switch_core_codec_destroy(&tech_pvt->write_codec);
} }
switch_core_timer_destroy(&tech_pvt->timer_read); if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
switch_core_timer_destroy(&tech_pvt->timer_read);
}
switch_core_timer_destroy(&tech_pvt->timer_write); if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
switch_core_timer_destroy(&tech_pvt->timer_write);
}
switch_buffer_destroy(&tech_pvt->read_buffer); if(tech_pvt->read_buffer){
switch_buffer_destroy(&tech_pvt->write_buffer); switch_buffer_destroy(&tech_pvt->read_buffer);
}
if(tech_pvt->write_buffer){
switch_buffer_destroy(&tech_pvt->write_buffer);
}
*tech_pvt->session_uuid_str = '\0'; *tech_pvt->session_uuid_str = '\0';
tech_pvt->interface_state = SKYPIAX_STATE_IDLE; tech_pvt->interface_state = SKYPIAX_STATE_IDLE;
...@@ -570,23 +578,20 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int ...@@ -570,23 +578,20 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
DEBUGA_SKYPE("%s CHANNEL KILL_CHANNEL\n", SKYPIAX_P_LOG, tech_pvt->name); DEBUGA_SKYPE("%s CHANNEL KILL_CHANNEL\n", SKYPIAX_P_LOG, tech_pvt->name);
switch (sig) { switch (sig) {
case SWITCH_SIG_KILL: case SWITCH_SIG_KILL:
DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
switch_mutex_lock(tech_pvt->flag_mutex); switch_mutex_lock(tech_pvt->flag_mutex);
switch_clear_flag(tech_pvt, TFLAG_IO); DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
switch_clear_flag(tech_pvt, TFLAG_VOICE);
switch_set_flag(tech_pvt, TFLAG_HANGUP);
if (tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD) { if (tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD) {
ERRORA("FYI %s CHANNEL in CALLFLOW_STATUS_REMOTEHOLD got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel)); DEBUGA_SKYPE("FYI %s CHANNEL in CALLFLOW_STATUS_REMOTEHOLD got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
channel_on_hangup(session);
} }
if (switch_channel_get_state(channel) == CS_NEW) { if (switch_channel_get_state(channel) == CS_NEW) {
ERRORA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel)); ERRORA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
channel_on_hangup(session);
} }
if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) { if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) {
ERRORA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel), switch_channel_get_state(channel)); ERRORA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG, switch_channel_get_name(channel), switch_channel_get_state(channel));
channel_on_hangup(session);
} }
switch_clear_flag(tech_pvt, TFLAG_IO);
switch_clear_flag(tech_pvt, TFLAG_VOICE);
switch_set_flag(tech_pvt, TFLAG_HANGUP);
switch_mutex_unlock(tech_pvt->flag_mutex); switch_mutex_unlock(tech_pvt->flag_mutex);
break; break;
case SWITCH_SIG_BREAK: case SWITCH_SIG_BREAK:
...@@ -679,7 +684,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch ...@@ -679,7 +684,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
tech_pvt->read_frame.flags = SFF_NONE; tech_pvt->read_frame.flags = SFF_NONE;
*frame = NULL; *frame = NULL;
switch_core_timer_next(&tech_pvt->timer_read); if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
switch_core_timer_next(&tech_pvt->timer_read);
}
read: read:
...@@ -872,14 +879,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s ...@@ -872,14 +879,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
if(tech_pvt->read_buffer){ if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv); switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer); switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read); if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_read);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv); switch_mutex_unlock(tech_pvt->mutex_audio_srv);
} }
if(tech_pvt->write_buffer){ if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli); switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer); switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write); if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_write);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli); switch_mutex_unlock(tech_pvt->mutex_audio_cli);
} }
DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG); DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG);
...@@ -893,14 +904,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s ...@@ -893,14 +904,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
if(tech_pvt->read_buffer){ if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv); switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer); switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read); if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_read);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv); switch_mutex_unlock(tech_pvt->mutex_audio_srv);
} }
if(tech_pvt->write_buffer){ if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli); switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer); switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write); if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_write);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli); switch_mutex_unlock(tech_pvt->mutex_audio_cli);
} }
DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG); DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG);
...@@ -911,14 +926,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s ...@@ -911,14 +926,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
if(tech_pvt->read_buffer){ if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv); switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer); switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read); if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_read);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv); switch_mutex_unlock(tech_pvt->mutex_audio_srv);
} }
if(tech_pvt->write_buffer){ if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli); switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer); switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write); if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_write);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli); switch_mutex_unlock(tech_pvt->mutex_audio_cli);
} }
DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG); DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG);
......
...@@ -506,14 +506,18 @@ int skypiax_signaling_read(private_t * tech_pvt) ...@@ -506,14 +506,18 @@ int skypiax_signaling_read(private_t * tech_pvt)
if(tech_pvt->read_buffer){ if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv); switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer); switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read); if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_read);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv); switch_mutex_unlock(tech_pvt->mutex_audio_srv);
} }
if(tech_pvt->write_buffer){ if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli); switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer); switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write); if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next){
switch_core_timer_sync(&tech_pvt->timer_write);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli); switch_mutex_unlock(tech_pvt->mutex_audio_cli);
} }
DEBUGA_SKYPE("Synching audio on skype_call: %s.\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("Synching audio on skype_call: %s.\n", SKYPIAX_P_LOG, id);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论