]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypiax: new audio threading works on windoz, little cleaning
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Sat, 20 Feb 2010 13:18:04 +0000 (13:18 +0000)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Sat, 20 Feb 2010 13:18:04 +0000 (13:18 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16709 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_skypiax/mod_skypiax.c
src/mod/endpoints/mod_skypiax/skypiax_protocol.c

index 0776e01c6fd046b6cb756003bba8bde73b02e952..bfcb45a1c1bfca5e0256e3587797b8ed1e492990 100644 (file)
@@ -538,7 +538,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
        tech_pvt->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
 
        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);
                sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
                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) {
                                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(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)
-       ERRORA("%s srv_join HANGUP\n", SKYPIAX_P_LOG, tech_pvt->name);
+                       //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);
        globals.calls--;
@@ -883,8 +882,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
        char digit_str[256];
        short *frame_16_khz;
        short frame_8_khz[160]; 
-       int i;
-       int a;
+       unsigned int i;
+       unsigned int a;
 size_t bytes_read;
 
 
@@ -928,7 +927,7 @@ size_t 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));
                tech_pvt->read_frame.datalen = SAMPLES_PER_FRAME * sizeof(short);
 
index 61f378cda68678c75ff82a7776a3698aff9a00ad..4ae53a53674974165b6d5bb8dbfbb61cd49f6704 100644 (file)
@@ -39,7 +39,7 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
        unsigned short start_port = 6001;
 #endif //WIN32
        int sockbufsize = 0;
-       unsigned int size = sizeof(int);
+       int size = sizeof(int);
 
 
        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 totalbuf[SAMPLES_PER_FRAME];
        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);
        if (s < 0) {
@@ -1390,7 +1390,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
                                                }
 
                                                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;
                                                }
                                                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_mutex_unlock(tech_pvt->mutex_audio_srv);
                                                } 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;
                                                } 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){
                                                continue;
                                        } else {
-                                               ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
+                                               DEBUGA_SKYPE("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
                                                break;
                                        }
 
@@ -1415,7 +1415,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
 
                                DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
                                tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP;
-                               skypiax_sleep(20000);
+                               //skypiax_sleep(20000);
                                skypiax_close_socket(fd);
                                break;
                        }
@@ -1449,7 +1449,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
        unsigned int sin_size;
 #endif /* WIN32 */
        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);
        if (s < 0) {
@@ -1555,7 +1555,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
                                                if(!switch_buffer_inuse(tech_pvt->write_buffer)){
                                                        memset(cli_out, 255, sizeof(cli_out));
                                                        bytes_to_write = 320;
-                                                       DEBUGA_SKYPE("Silence!\n", SKYPIAX_P_LOG);
+                                                       //DEBUGA_SKYPE("Silence!\n", SKYPIAX_P_LOG);
                                                }else {
                                                        switch_mutex_lock(tech_pvt->mutex_audio_cli);
                                                        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 */
                                                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) {
-                                                               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;
                                                        }
                                                        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){
                                                continue;
                                        } else {
-                                               ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
+                                               DEBUGA_SKYPE("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
                                                break;
                                        }
 
                                }
                                DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
                                tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP;
-                               skypiax_sleep(20000);
+                               //skypiax_sleep(20000);
                                skypiax_close_socket(fd);
                                break;
                        }