mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-02 11:19:28 +00:00
skypiax: works well again on Virtual Machines
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16867 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e575fa6e87
commit
d82d868ffe
@ -652,6 +652,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int a;
|
unsigned int a;
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
|
int try=0;
|
||||||
|
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
@ -680,6 +681,13 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
|
|
||||||
switch_core_timer_next(&tech_pvt->timer_read);
|
switch_core_timer_next(&tech_pvt->timer_read);
|
||||||
|
|
||||||
|
read:
|
||||||
|
|
||||||
|
|
||||||
|
if (tech_pvt && tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
||||||
|
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
||||||
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
||||||
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
||||||
switch_mutex_lock(tech_pvt->mutex_audio_srv);
|
switch_mutex_lock(tech_pvt->mutex_audio_srv);
|
||||||
if (switch_buffer_inuse(tech_pvt->read_buffer)) {
|
if (switch_buffer_inuse(tech_pvt->read_buffer)) {
|
||||||
bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, 640);
|
bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, 640);
|
||||||
@ -687,12 +695,21 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
}
|
}
|
||||||
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
|
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
|
||||||
|
|
||||||
|
try=0;
|
||||||
if (!bytes_read) {
|
if (!bytes_read) {
|
||||||
//NOTICA("skypiax_audio_read Silence\n", SKYPIAX_P_LOG);
|
switch_sleep(1000);
|
||||||
|
try++;
|
||||||
|
if(try < 5)
|
||||||
|
goto read;
|
||||||
|
NOTICA("skypiax_audio_read Silence\n", SKYPIAX_P_LOG);
|
||||||
memset(tech_pvt->read_frame.data, 255, SAMPLES_PER_FRAME * sizeof(short));
|
memset(tech_pvt->read_frame.data, 255, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
tech_pvt->read_frame.datalen = SAMPLES_PER_FRAME * sizeof(short);
|
tech_pvt->read_frame.datalen = 640;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
memset(tech_pvt->read_frame.data, 255, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
|
tech_pvt->read_frame.datalen = 640;
|
||||||
|
}
|
||||||
|
|
||||||
switch_set_flag(tech_pvt, TFLAG_VOICE);
|
switch_set_flag(tech_pvt, TFLAG_VOICE);
|
||||||
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||||
@ -805,8 +822,9 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
|||||||
|
|
||||||
switch_mutex_lock(tech_pvt->mutex_audio_cli);
|
switch_mutex_lock(tech_pvt->mutex_audio_cli);
|
||||||
if (switch_buffer_freespace(tech_pvt->write_buffer) < frame->datalen) {
|
if (switch_buffer_freespace(tech_pvt->write_buffer) < frame->datalen) {
|
||||||
//WARNINGA("NO SPACE WRITE: %d\n", SKYPIAX_P_LOG, frame->datalen);
|
WARNINGA("NO SPACE WRITE: %d\n", SKYPIAX_P_LOG, frame->datalen);
|
||||||
switch_buffer_toss(tech_pvt->write_buffer, frame->datalen);
|
//switch_buffer_toss(tech_pvt->write_buffer, frame->datalen);
|
||||||
|
switch_buffer_zero(tech_pvt->write_buffer);
|
||||||
}
|
}
|
||||||
switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen);
|
switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen);
|
||||||
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
|
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
|
||||||
@ -1667,6 +1685,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypiax_api_thread_func die
|
if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypiax_api_thread_func die
|
||||||
DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError());
|
DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError());
|
||||||
|
tech_pvt->skypiax_api_thread=NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (tech_pvt->SkypiaxHandles.disp) {
|
if (tech_pvt->SkypiaxHandles.disp) {
|
||||||
|
@ -103,7 +103,7 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
|
|||||||
sockbufsize = SAMPLES_PER_FRAME * 8;
|
sockbufsize = SAMPLES_PER_FRAME * 8;
|
||||||
#endif //WIN32
|
#endif //WIN32
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
//setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, size);
|
setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, size);
|
||||||
|
|
||||||
sockbufsize = 0;
|
sockbufsize = 0;
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
@ -120,7 +120,7 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
|
|||||||
sockbufsize = SAMPLES_PER_FRAME * 8;
|
sockbufsize = SAMPLES_PER_FRAME * 8;
|
||||||
#endif //WIN32
|
#endif //WIN32
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
//setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, size);
|
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, size);
|
||||||
|
|
||||||
sockbufsize = 0;
|
sockbufsize = 0;
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
@ -844,14 +844,14 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
switch_mutex_lock(tech_pvt->mutex_audio_srv);
|
switch_mutex_lock(tech_pvt->mutex_audio_srv);
|
||||||
if (switch_buffer_freespace(tech_pvt->read_buffer) < len) {
|
if (switch_buffer_freespace(tech_pvt->read_buffer) < len) {
|
||||||
//switch_buffer_zero(tech_pvt->read_buffer);
|
switch_buffer_zero(tech_pvt->read_buffer);
|
||||||
nospace = 1;
|
nospace = 1;
|
||||||
switch_buffer_toss(tech_pvt->read_buffer, len);
|
//switch_buffer_toss(tech_pvt->read_buffer, len);
|
||||||
}
|
}
|
||||||
switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
|
switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
|
||||||
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
|
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
|
||||||
if (nospace) {
|
if (nospace) {
|
||||||
//WARNINGA("NO SPACE READ: there was no space for: %d\n", SKYPIAX_P_LOG, len);
|
WARNINGA("NO SPACE READ: there was no space for: %d\n", SKYPIAX_P_LOG, len);
|
||||||
}
|
}
|
||||||
} else if (len == 0) {
|
} else if (len == 0) {
|
||||||
DEBUGA_SKYPE("CLOSED\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("CLOSED\n", SKYPIAX_P_LOG);
|
||||||
@ -992,6 +992,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
|
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
|
||||||
|
|
||||||
if (!bytes_to_write) {
|
if (!bytes_to_write) {
|
||||||
|
continue;
|
||||||
memset(cli_out, 255, sizeof(cli_out));
|
memset(cli_out, 255, sizeof(cli_out));
|
||||||
bytes_to_write = 640;
|
bytes_to_write = 640;
|
||||||
//NOTICA("WRITE Silence!\n", SKYPIAX_P_LOG);
|
//NOTICA("WRITE Silence!\n", SKYPIAX_P_LOG);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user