skypopen: added a second timer on read from Skype client (timer_read_srv), so not to depend anymore from select on that socket

This commit is contained in:
Giovanni Maruzzelli 2010-12-07 00:19:49 -06:00
parent 34e44f92a1
commit 9350fb9626
3 changed files with 31 additions and 4 deletions

View File

@ -526,6 +526,10 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
switch_core_timer_destroy(&tech_pvt->timer_read);
}
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_destroy(&tech_pvt->timer_read_srv);
}
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
switch_core_timer_destroy(&tech_pvt->timer_write);
}
@ -1121,6 +1125,9 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read);
}
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read_srv);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
@ -1146,6 +1153,9 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read);
}
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read_srv);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
@ -1168,6 +1178,9 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read);
}
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read_srv);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
@ -2168,6 +2181,13 @@ int start_audio_threads(private_t *tech_pvt)
switch_core_timer_sync(&tech_pvt->timer_read);
if (switch_core_timer_init(&tech_pvt->timer_read_srv, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) {
ERRORA("setup timer failed\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
switch_core_timer_sync(&tech_pvt->timer_read_srv);
if (switch_core_timer_init(&tech_pvt->timer_write, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) {
ERRORA("setup timer failed\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;

View File

@ -76,8 +76,8 @@
#define SAMPLERATE_SKYPOPEN 16000
#define MS_SKYPOPEN 20
#define SAMPLES_PER_FRAME SAMPLERATE_SKYPOPEN/(1000/MS_SKYPOPEN)
#define BYTES_PER_FRAME SAMPLES_PER_FRAME * sizeof(short)
#define SAMPLES_PER_FRAME (SAMPLERATE_SKYPOPEN/(1000/MS_SKYPOPEN))
#define BYTES_PER_FRAME (SAMPLES_PER_FRAME * sizeof(short))
#ifdef SKYPOPEN_C_VER
#ifdef MODSKYPOPEN_C_VER
@ -341,6 +341,7 @@ struct private_object {
chat_t chats[MAX_CHATS];
uint32_t report_incoming_chatmessages;
switch_timer_t timer_read;
switch_timer_t timer_read_srv;
switch_timer_t timer_write;
int begin_to_write;
int begin_to_read;

View File

@ -547,6 +547,9 @@ int skypopen_signaling_read(private_t *tech_pvt)
if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read);
}
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_sync(&tech_pvt->timer_read_srv);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
@ -878,7 +881,7 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) {
unsigned int fdselect;
int rt;
int rt=1;
fd_set fs;
struct timeval to;
int nospace;
@ -891,7 +894,10 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
to.tv_usec = MS_SKYPOPEN * 1000 * 3;
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_next(&tech_pvt->timer_read_srv);
}
//rt = select(fdselect + 1, &fs, NULL, NULL, &to);
if (rt > 0) {
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {