mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 20:48:21 +00:00
skypiax: new audio threading works on windoz, little cleaning
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16709 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
48b0043ebd
commit
05f23d981a
@ -538,7 +538,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||||||
tech_pvt->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
|
tech_pvt->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
|
||||||
|
|
||||||
if (strlen(tech_pvt->skype_call_id)) {
|
if (strlen(tech_pvt->skype_call_id)) {
|
||||||
//switch_thread_cond_signal(tech_pvt->cond);
|
|
||||||
DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id);
|
DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id);
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
|
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
@ -549,13 +548,13 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||||||
if (tech_pvt->tcp_cli_thread) {
|
if (tech_pvt->tcp_cli_thread) {
|
||||||
switch_thread_join(&status, tech_pvt->tcp_cli_thread);
|
switch_thread_join(&status, tech_pvt->tcp_cli_thread);
|
||||||
}
|
}
|
||||||
if(status!=SWITCH_STATUS_SUCCESS)
|
//if(status!=SWITCH_STATUS_SUCCESS)
|
||||||
ERRORA("%s cli_join HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
|
//ERRORA("%s cli_join HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
|
||||||
if (tech_pvt->tcp_srv_thread) {
|
if (tech_pvt->tcp_srv_thread) {
|
||||||
switch_thread_join(&status, tech_pvt->tcp_srv_thread);
|
switch_thread_join(&status, tech_pvt->tcp_srv_thread);
|
||||||
}
|
}
|
||||||
if(status!=SWITCH_STATUS_SUCCESS)
|
//if(status!=SWITCH_STATUS_SUCCESS)
|
||||||
ERRORA("%s srv_join HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
|
//ERRORA("%s srv_join HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
|
||||||
DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
|
DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
|
||||||
switch_mutex_lock(globals.mutex);
|
switch_mutex_lock(globals.mutex);
|
||||||
globals.calls--;
|
globals.calls--;
|
||||||
@ -883,8 +882,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
char digit_str[256];
|
char digit_str[256];
|
||||||
short *frame_16_khz;
|
short *frame_16_khz;
|
||||||
short frame_8_khz[160];
|
short frame_8_khz[160];
|
||||||
int i;
|
unsigned int i;
|
||||||
int a;
|
unsigned int a;
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
|
|
||||||
|
|
||||||
@ -928,7 +927,7 @@ size_t bytes_read;
|
|||||||
|
|
||||||
|
|
||||||
if (!bytes_read) {
|
if (!bytes_read) {
|
||||||
ERRORA("skypiax_audio_read Silence\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("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 = SAMPLES_PER_FRAME * sizeof(short);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
|
|||||||
unsigned short start_port = 6001;
|
unsigned short start_port = 6001;
|
||||||
#endif //WIN32
|
#endif //WIN32
|
||||||
int sockbufsize = 0;
|
int sockbufsize = 0;
|
||||||
unsigned int size = sizeof(int);
|
int size = sizeof(int);
|
||||||
|
|
||||||
|
|
||||||
memset(&my_addr, 0, sizeof(my_addr));
|
memset(&my_addr, 0, sizeof(my_addr));
|
||||||
@ -1305,7 +1305,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
//short kill_cli_buff[SAMPLES_PER_FRAME];
|
//short kill_cli_buff[SAMPLES_PER_FRAME];
|
||||||
//short totalbuf[SAMPLES_PER_FRAME];
|
//short totalbuf[SAMPLES_PER_FRAME];
|
||||||
int sockbufsize = 0;
|
int sockbufsize = 0;
|
||||||
unsigned int size = sizeof(int);
|
int size = sizeof(int);
|
||||||
|
|
||||||
s = skypiax_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_srv_port);
|
s = skypiax_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_srv_port);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
@ -1390,7 +1390,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
ERRORA("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
|
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
@ -1398,16 +1398,16 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
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);
|
||||||
} else if (len == 0) {
|
} else if (len == 0) {
|
||||||
ERRORA("CLOSING, len=%d, expected 640\n", SKYPIAX_P_LOG, len);
|
DEBUGA_SKYPE("CLOSING, len=%d, expected 640\n", SKYPIAX_P_LOG, len);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
WARNINGA("len=%d, expected 640\n", SKYPIAX_P_LOG, len);
|
DEBUGA_SKYPE("len=%d, expected 640\n", SKYPIAX_P_LOG, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(rt==0){
|
} else if(rt==0){
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
|
DEBUGA_SKYPE("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1415,7 +1415,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
|
|
||||||
DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
|
||||||
tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP;
|
tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP;
|
||||||
skypiax_sleep(20000);
|
//skypiax_sleep(20000);
|
||||||
skypiax_close_socket(fd);
|
skypiax_close_socket(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1449,7 +1449,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
unsigned int sin_size;
|
unsigned int sin_size;
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
int sockbufsize = 0;
|
int sockbufsize = 0;
|
||||||
unsigned int size = sizeof(int);
|
int size = sizeof(int);
|
||||||
|
|
||||||
s = skypiax_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_cli_port);
|
s = skypiax_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_cli_port);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
@ -1555,7 +1555,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
if(!switch_buffer_inuse(tech_pvt->write_buffer)){
|
if(!switch_buffer_inuse(tech_pvt->write_buffer)){
|
||||||
memset(cli_out, 255, sizeof(cli_out));
|
memset(cli_out, 255, sizeof(cli_out));
|
||||||
bytes_to_write = 320;
|
bytes_to_write = 320;
|
||||||
DEBUGA_SKYPE("Silence!\n", SKYPIAX_P_LOG);
|
//DEBUGA_SKYPE("Silence!\n", SKYPIAX_P_LOG);
|
||||||
}else {
|
}else {
|
||||||
switch_mutex_lock(tech_pvt->mutex_audio_cli);
|
switch_mutex_lock(tech_pvt->mutex_audio_cli);
|
||||||
bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, 320);
|
bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, 320);
|
||||||
@ -1564,26 +1564,26 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
|
|
||||||
/* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
|
/* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
|
||||||
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
||||||
len = send(fd, cli_out, bytes_to_write, 0);
|
len = send(fd, (char *)cli_out, bytes_to_write, 0);
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
ERRORA("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
|
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (len != bytes_to_write) {
|
if (len != bytes_to_write) {
|
||||||
WARNINGA("len=%d\n", SKYPIAX_P_LOG, len);
|
DEBUGA_SKYPE("len=%d\n", SKYPIAX_P_LOG, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(rt==0){
|
} else if(rt==0){
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
|
DEBUGA_SKYPE("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
|
||||||
tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP;
|
tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP;
|
||||||
skypiax_sleep(20000);
|
//skypiax_sleep(20000);
|
||||||
skypiax_close_socket(fd);
|
skypiax_close_socket(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user