skypiax: indenting

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16824 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Giovanni Maruzzelli 2010-02-25 18:17:38 +00:00
parent 05048ba11f
commit a15fd5a9a0
3 changed files with 111 additions and 117 deletions

View File

@ -258,7 +258,6 @@ switch_status_t skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *s
ERRORA("skypiax_codec FAILED\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
#if 0
if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, tech_pvt->read_codec.implementation->samples_per_packet, skypiax_module_pool) !=
SWITCH_STATUS_SUCCESS) {
@ -279,8 +278,8 @@ switch_status_t skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *s
#endif // TIMER_WRITE
#endif
dtmf_rx_init(&tech_pvt->dtmf_state, NULL, NULL);
dtmf_rx_parms(&tech_pvt->dtmf_state, 0, 10, 10, -99);
dtmf_rx_init(&tech_pvt->dtmf_state, NULL, NULL);
dtmf_rx_parms(&tech_pvt->dtmf_state, 0, 10, 10, -99);
DEBUGA_SKYPE("skypiax_tech_init SUCCESS\n", SKYPIAX_P_LOG);
@ -548,15 +547,15 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
//memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
//*tech_pvt->session_uuid_str = '\0';
if (tech_pvt->tcp_cli_thread) {
switch_thread_join(&status, tech_pvt->tcp_cli_thread);
}
//if(status!=SWITCH_STATUS_SUCCESS)
if (tech_pvt->tcp_cli_thread) {
switch_thread_join(&status, tech_pvt->tcp_cli_thread);
}
//if(status!=SWITCH_STATUS_SUCCESS)
//ERRORA("%s cli_join HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
if (tech_pvt->tcp_srv_thread) {
switch_thread_join(&status, tech_pvt->tcp_srv_thread);
}
//if(status!=SWITCH_STATUS_SUCCESS)
if (tech_pvt->tcp_srv_thread) {
switch_thread_join(&status, tech_pvt->tcp_srv_thread);
}
//if(status!=SWITCH_STATUS_SUCCESS)
//ERRORA("%s srv_join 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);
@ -700,10 +699,10 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
switch_byte_t *data;
char digit_str[256];
short *frame_16_khz;
short frame_8_khz[160];
short frame_8_khz[160];
unsigned int i;
unsigned int a;
size_t bytes_read=0;
size_t bytes_read = 0;
channel = switch_core_session_get_channel(session);
@ -726,7 +725,7 @@ size_t bytes_read=0;
switch_buffer_create(skypiax_module_pool, &tech_pvt->read_buffer, max_len);
switch_assert(tech_pvt->read_buffer);
switch_buffer_zero(tech_pvt->read_buffer);
tech_pvt->begin_to_read=1;
tech_pvt->begin_to_read = 1;
//switch_sleep(40000);
}
@ -741,7 +740,7 @@ size_t bytes_read=0;
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);
tech_pvt->read_frame.datalen = bytes_read;
}
@ -797,7 +796,7 @@ size_t bytes_read=0;
if (digit_str[0]) {
switch_time_t new_dtmf_timestamp = switch_time_now();
if ((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) { //FIXME: make it configurable
if ((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) { //FIXME: make it configurable
char *p = digit_str;
switch_channel_t *channel = switch_core_session_get_channel(session);
@ -809,16 +808,11 @@ size_t bytes_read=0;
p++;
}
NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPIAX_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
(unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
(unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
}
}
}
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
@ -835,7 +829,7 @@ size_t bytes_read=0;
DEBUGA_SKYPE("CHANNEL READ FALSE\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
cng:
cng:
data = (switch_byte_t *) tech_pvt->read_frame.data;
data[0] = 65;
data[1] = 0;
@ -876,14 +870,14 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
}
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);
switch_buffer_toss(tech_pvt->write_buffer, frame->datalen);
}
switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
tech_pvt->begin_to_write=1;
tech_pvt->begin_to_write = 1;
return SWITCH_STATUS_SUCCESS;
}
@ -1270,7 +1264,7 @@ static switch_status_t load_config(int reload_type)
}
}
globals.start_port=32769;
globals.start_port = 32769;
if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) {
int i = 0;
@ -1332,7 +1326,7 @@ static switch_status_t load_config(int reload_type)
tcp_cli_port = val;
} else if (!strcasecmp(var, "tcp_srv_port")) {
tcp_srv_port = val;
#endif//0
#endif //0
} else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) {
X11_display = val;
} else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
@ -1374,7 +1368,7 @@ static switch_status_t load_config(int reload_type)
ERRORA("interface missing REQUIRED param 'tcp_srv_port'\n", SKYPIAX_P_LOG);
continue;
}
#endif//0
#endif //0
if (!id) {
ERRORA("interface missing REQUIRED param 'id'\n", SKYPIAX_P_LOG);
continue;
@ -1442,7 +1436,7 @@ static switch_status_t load_config(int reload_type)
globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
#endif /* WIN32 */
#endif//0
#endif //0
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
@ -1477,7 +1471,7 @@ static switch_status_t load_config(int reload_type)
DEBUGA_SKYPE
("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n",
SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
#endif//0
#endif //0
DEBUGA_SKYPE("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n",
SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].name);
DEBUGA_SKYPE
@ -1565,14 +1559,14 @@ static switch_status_t load_config(int reload_type)
switch_sleep(10000);
skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET USERSTATUS ONLINE");
switch_sleep(10000);
if(globals.SKYPIAX_INTERFACES[interface_id].silent_mode){
if (globals.SKYPIAX_INTERFACES[interface_id].silent_mode) {
skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET SILENT_MODE ON");
switch_sleep(10000);
skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET SILENT_MODE OFF");
switch_sleep(10000);
skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET SILENT_MODE ON");
switch_sleep(10000);
}
}
} else {
ERRORA
("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n",
@ -1606,8 +1600,7 @@ static switch_status_t load_config(int reload_type)
DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].destination=%s\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].destination);
DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].report_incoming_chatmessages=%d\n", SKYPIAX_P_LOG, i, i,
globals.SKYPIAX_INTERFACES[i].report_incoming_chatmessages);
DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].silent_mode=%d\n", SKYPIAX_P_LOG, i, i,
globals.SKYPIAX_INTERFACES[i].silent_mode);
DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].silent_mode=%d\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].silent_mode);
}
}
}
@ -1793,7 +1786,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
skypiax_signaling_write(tech_pvt, "DIE");
switch_sleep(10000);
switch_file_write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
#else /* WIN32 */
howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", howmany);
#endif /* WIN32 */
@ -1805,7 +1798,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError());
//globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
}
//cicopet
#else
if (tech_pvt->SkypiaxHandles.disp) {
@ -1832,12 +1824,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
}
if(status != SWITCH_STATUS_SUCCESS)
if (status != SWITCH_STATUS_SUCCESS)
DEBUGA_SKYPE("got FALSE here, thread was not joined\n", SKYPIAX_P_LOG);
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
}
if(status != SWITCH_STATUS_SUCCESS)
if (status != SWITCH_STATUS_SUCCESS)
DEBUGA_SKYPE("got FALSE here, thread was not joined\n", SKYPIAX_P_LOG);
#ifndef WIN32
WARNINGA("SHUTDOWN interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
@ -1893,11 +1885,13 @@ int dtmf_received(private_t * tech_pvt, char *value)
if (channel) {
if (switch_channel_test_flag(channel, CF_BRIDGED) && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
if (switch_channel_test_flag(channel, CF_BRIDGED)
&& !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
NOTICA
("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n", SKYPIAX_P_LOG, value[0], switch_channel_get_name(channel));
("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n",
SKYPIAX_P_LOG, value[0], switch_channel_get_name(channel));
} else {
@ -1923,11 +1917,10 @@ int start_audio_threads(private_t * tech_pvt)
{
switch_threadattr_t *thd_attr = NULL;
tech_pvt->begin_to_write=0;
tech_pvt->begin_to_read=0;
tech_pvt->begin_to_write = 0;
tech_pvt->begin_to_read = 0;
#if 1
if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, 320, skypiax_module_pool) !=
SWITCH_STATUS_SUCCESS) {
if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, 320, skypiax_module_pool) != SWITCH_STATUS_SUCCESS) {
ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
@ -1936,8 +1929,7 @@ tech_pvt->begin_to_read=0;
#ifdef TIMER_WRITE
//if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 10, 320, skypiax_module_pool) !=
if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 20, 320, skypiax_module_pool) !=
SWITCH_STATUS_SUCCESS) {
if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 20, 320, skypiax_module_pool) != SWITCH_STATUS_SUCCESS) {
ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
@ -2699,11 +2691,12 @@ SWITCH_STANDARD_API(skypiax_chat_function)
return SWITCH_STATUS_SUCCESS;
}
int next_port(void){
int next_port(void)
{
switch_mutex_lock(globals.mutex);
globals.start_port++;
if(globals.start_port == 65000)
globals.start_port=32769;
if (globals.start_port == 65000)
globals.start_port = 32769;
switch_mutex_unlock(globals.mutex);
return (globals.start_port - 1);
}

View File

@ -284,13 +284,13 @@ struct private_object {
uint32_t report_incoming_chatmessages;
switch_timer_t timer_read;
switch_timer_t timer_write;
int begin_to_write;
int begin_to_read;
dtmf_rx_state_t dtmf_state;
switch_time_t old_dtmf_timestamp;
switch_buffer_t *write_buffer;
switch_buffer_t *read_buffer;
int silent_mode;
int begin_to_write;
int begin_to_read;
dtmf_rx_state_t dtmf_state;
switch_time_t old_dtmf_timestamp;
switch_buffer_t *write_buffer;
switch_buffer_t *read_buffer;
int silent_mode;
};

View File

@ -55,9 +55,9 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
if (*which_port != 0)
start_port = *which_port;
#ifdef WIN32
start_port=(unsigned short)next_port();
start_port = (unsigned short) next_port();
#else
start_port=(unsigned short)next_port();
start_port = (unsigned short) next_port();
#endif
my_addr.sin_port = htons(start_port);
//fcntl(s, F_SETFL, O_NONBLOCK);
@ -161,7 +161,7 @@ int skypiax_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
//}
if (!strcasecmp(message, "SILENT_MODE OFF")) {
if(tech_pvt->silent_mode){
if (tech_pvt->silent_mode) {
DEBUGA_SKYPE("Resetting SILENT_MODE on skype_call: %s.\n", SKYPIAX_P_LOG, id);
skypiax_signaling_write(tech_pvt, "SET SILENT_MODE ON");
switch_sleep(1000);
@ -201,9 +201,9 @@ int skypiax_signaling_read(private_t * tech_pvt)
} else if (!strncasecmp(message, "ERROR 592 ALTER CALL", 19)) {
ERRORA("Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n", SKYPIAX_P_LOG, message);
} else if (!strncasecmp(message, "ERROR 559 CALL", 13)) {
if(tech_pvt->interface_state == SKYPIAX_STATE_PREANSWER){
if (tech_pvt->interface_state == SKYPIAX_STATE_PREANSWER) {
DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to ANSWER A CALL), let's go down: |||%s|||\n", SKYPIAX_P_LOG,
message);
message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
ERRORA("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
@ -212,7 +212,7 @@ int skypiax_signaling_read(private_t * tech_pvt)
} else {
DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n", SKYPIAX_P_LOG,
message);
message);
}
} else {
ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
@ -510,11 +510,11 @@ int skypiax_signaling_read(private_t * tech_pvt)
if (!strcasecmp(prop, "FAILUREREASON")) {
DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id);
}
if (!strcasecmp(prop, "DURATION")) { /* each 20 seconds, we sync ithe timers */
if(!((atoi(value) % 20))){
switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write);
DEBUGA_SKYPE("Synching on skype_call: %s.\n", SKYPIAX_P_LOG, id);
if (!strcasecmp(prop, "DURATION")) { /* each 20 seconds, we sync ithe timers */
if (!((atoi(value) % 20))) {
switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write);
DEBUGA_SKYPE("Synching on skype_call: %s.\n", SKYPIAX_P_LOG, id);
}
}
if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
@ -761,7 +761,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
unsigned int size = sizeof(int);
#endif /* WIN32 */
unsigned int fd;
short srv_in[SAMPLES_PER_FRAME*10];
short srv_in[SAMPLES_PER_FRAME * 10];
//short srv_out[SAMPLES_PER_FRAME / 2];
//struct sockaddr_in my_addr;
struct sockaddr_in remote_addr;
@ -784,9 +784,9 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
/****************************/
while (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)) {
&& (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)) {
unsigned int fdselectgio;
int rtgio;
@ -823,9 +823,9 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
if (!(running && tech_pvt->running))
break;
while (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)) {
&& (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)) {
unsigned int fdselect;
int rt;
@ -849,26 +849,26 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
} else {
continue;
}
if(tech_pvt->begin_to_read==0){
if (tech_pvt->begin_to_read == 0) {
DEBUGA_SKYPE("len=%d\n", SKYPIAX_P_LOG, len);
continue;
}
if (len == -1) {
DEBUGA_SKYPE("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;
}
nospace=0;
nospace = 0;
if (len > 0) {
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);
nospace=1;
nospace = 1;
switch_buffer_toss(tech_pvt->read_buffer, len);
}
switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
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);
}
} else if (len == 0) {
@ -878,7 +878,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
DEBUGA_SKYPE("len=%d\n", SKYPIAX_P_LOG, len);
}
} else if(rt==0){
} else if (rt == 0) {
continue;
} else {
DEBUGA_SKYPE("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
@ -941,9 +941,9 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
/****************************/
while (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)) {
&& (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)) {
unsigned int fdselectgio;
int rtgio;
@ -981,9 +981,9 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
if (!(running && tech_pvt->running))
break;
while (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)) {
&& (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)) {
unsigned int fdselect;
int rt;
fd_set fs;
@ -999,34 +999,35 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
fdselect = fd;
FD_SET(fdselect, &fs);
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next && tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
switch_core_timer_next(&tech_pvt->timer_write);
}
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next
&& tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
switch_core_timer_next(&tech_pvt->timer_write);
}
#if 1
if(tech_pvt->begin_to_write==0){
memset(cli_out, 255, sizeof(cli_out));
bytes_to_write = 640;
len = send(fd, (char *)cli_out, bytes_to_write, 0);
if (len == -1) {
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
break;
}
continue;
if (tech_pvt->begin_to_write == 0) {
memset(cli_out, 255, sizeof(cli_out));
bytes_to_write = 640;
len = send(fd, (char *) cli_out, bytes_to_write, 0);
if (len == -1) {
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
break;
}
continue;
}
#endif//0
#endif //0
rt=1;
rt = 1;
if (rt > 0) {
bytes_to_write=0;
bytes_to_write = 0;
if(tech_pvt->skype_callflow == CALLFLOW_INCOMING_HANGUP){
if (tech_pvt->skype_callflow == CALLFLOW_INCOMING_HANGUP) {
break;
}
switch_mutex_lock(tech_pvt->mutex_audio_cli);
if(switch_buffer_inuse(tech_pvt->write_buffer)){
if (switch_buffer_inuse(tech_pvt->write_buffer)) {
bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, 640);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
@ -1039,16 +1040,16 @@ 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 */
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
len = send(fd, (char *)cli_out, bytes_to_write, 0);
len = send(fd, (char *) cli_out, bytes_to_write, 0);
if (len == -1) {
DEBUGA_SKYPE("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;
}
if (len != bytes_to_write) {
DEBUGA_SKYPE("len=%d\n", SKYPIAX_P_LOG, len);
}
}
} else if(rt==0){
} else if (rt == 0) {
DEBUGA_SKYPE("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
continue;
} else {
@ -1077,31 +1078,31 @@ int skypiax_audio_read(private_t * tech_pvt)
{
unsigned int samples;
int waitin;
int max_waitin=30;
int max_waitin = 30;
waitin=0;
waitin = 0;
while (tech_pvt->flag_audio_srv == 0) {
#ifdef WIN32
skypiax_sleep(1000); //0.1 millisec
skypiax_sleep(1000); //0.1 millisec
#else
skypiax_sleep(1000); //1 millisec
#endif //WIN32
waitin++;
if(waitin == max_waitin){
if (waitin == max_waitin) {
DEBUGA_SKYPE("read is now at max_waitin: %d\n", SKYPIAX_P_LOG, waitin);
break;
}
//WARNINGA("read now is 0\n", SKYPIAX_P_LOG);
}
if(waitin > 22){
if (waitin > 22) {
DEBUGA_SKYPE("read is now %d\n", SKYPIAX_P_LOG, waitin);
}
//samples = skypiax_pipe_read(tech_pvt->audiopipe_srv[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_mutex_lock(tech_pvt->mutex_audio_srv);
memcpy(tech_pvt->read_frame.data, tech_pvt->audiobuf_srv, SAMPLES_PER_FRAME * sizeof(short));
tech_pvt->flag_audio_srv = 0;
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
samples = SAMPLES_PER_FRAME * sizeof(short);
if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
@ -1316,14 +1317,14 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, L
fIssueDefProc = 0;
tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
//if (!running)
// return lReturnCode;
// return lReturnCode;
if(!running){
if (!running) {
DEBUGA_SKYPE("let's DIE!\n", SKYPIAX_P_LOG);
tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
PostQuitMessage(0);
return lReturnCode;
}
}
switch (uiMessage) {
case WM_CREATE:
tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;