]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypiax: more timin fixes, works well on linux, with skype beta 2, 100HZ, and switch_...
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Tue, 16 Feb 2010 20:21:57 +0000 (20:21 +0000)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Tue, 16 Feb 2010 20:21:57 +0000 (20:21 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16661 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 8b721557d29a24ea9df4e549e7cd2f850dc70df2..245593deaa6d07c33d0640ea800a5539c6511006 100644 (file)
@@ -845,14 +845,18 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
                switch_core_timer_sync(&tech_pvt->timer_write);
 #endif // TIMER_WRITE
                break;
-       default:
-               {
+       case SWITCH_MESSAGE_INDICATE_BRIDGE:
 
-                       switch_core_timer_sync(&tech_pvt->timer_read);
-#ifdef TIMER_WRITE
+               DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_BRIDGE\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
 
-                       switch_core_timer_sync(&tech_pvt->timer_write);
+               switch_core_timer_sync(&tech_pvt->timer_read);
+#ifdef TIMER_WRITE
+               switch_core_timer_sync(&tech_pvt->timer_write);
 #endif // TIMER_WRITE
+               break;
+
+       default:
+               {
 
                        DEBUGA_SKYPE("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->message_id);
                }
@@ -987,7 +991,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                        switch_mutex_unlock(globals.mutex);
                        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
                }
-               switch_channel_set_variable(channel, "send_silence_when_idle", "true");
+               switch_channel_set_variable(channel, "send_silence_when_idle", "1500");
+               switch_channel_set_variable(channel, "waste", "false");
                if (skypiax_tech_init(tech_pvt, *new_session) != SWITCH_STATUS_SUCCESS) {
                        ERRORA("Doh! no tech_init?\n", SKYPIAX_P_LOG);
                        switch_core_session_destroy(new_session);
@@ -1809,7 +1814,8 @@ int new_inbound_channel(private_t * tech_pvt)
                        switch_core_session_destroy(&session);
                        return 0;
                }
-               switch_channel_set_variable(channel, "send_silence_when_idle", "true");
+               switch_channel_set_variable(channel, "send_silence_when_idle", "1500");
+               switch_channel_set_variable(channel, "waste", "false");
                if (skypiax_tech_init(tech_pvt, session) != SWITCH_STATUS_SUCCESS) {
                        ERRORA("Doh! no tech_init?\n", SKYPIAX_P_LOG);
                        switch_core_session_destroy(&session);
index a1f5a5e22cc8036209a8f8088759020b59f84161..35af7680033df55a40cc5ba2c257eabfd48bb992 100644 (file)
@@ -828,7 +828,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
                                                if (len == 320) {
                                                        unsigned int howmany;
 
-                                                               //DEBUGA_SKYPE("320!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", SKYPIAX_P_LOG);
+                                                               NOTICA("320!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", SKYPIAX_P_LOG);
                                                        if (samplerate_skypiax == 8000) {
                                                                /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
                                                                a = 0;
@@ -889,14 +889,24 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
                                                        }
 
                                                } else if (len == 640) {
+                                                       int waitin;
+                                                       int max_waitin=20;
 
-                                                               if (tech_pvt->flag_audio_srv == 1) {
-                                                                       switch_sleep(1000);     //1 millisec
+                                                       waitin=0;
+                                                       while (tech_pvt->flag_audio_srv == 1) {
+                                                               switch_sleep(1000);     //1 millisec
+                                                               waitin++;
+                                                               if(waitin == max_waitin){
+                                                                       break;
                                                                }
-                       switch_mutex_lock(tech_pvt->mutex_audio_srv);
-                                                                       memcpy(tech_pvt->audiobuf_srv, srv_in, SAMPLES_PER_FRAME * sizeof(short));
-                                                                       tech_pvt->flag_audio_srv = 1;
-                       switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+                                                       }
+
+                                                       if(waitin > 1)
+                                                               ERRORA("waitin is %d\n", SKYPIAX_P_LOG, waitin);
+                                                       switch_mutex_lock(tech_pvt->mutex_audio_srv);
+                                                       memcpy(tech_pvt->audiobuf_srv, srv_in, SAMPLES_PER_FRAME * sizeof(short));
+                                                       tech_pvt->flag_audio_srv = 1;
+                                                       switch_mutex_unlock(tech_pvt->mutex_audio_srv);
                                                } else if (len == 0) {
                                                        skypiax_sleep(1000);
                                                } else {
@@ -1036,8 +1046,10 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
                                        fd_set fs;
                                        struct timeval to;
                                        int waitin;
-                                       //int big_waitin=40;
-                                       //int lil_waitin=20;
+#if 1
+                                       int big_waitin=40;
+                                       int lil_waitin=20;
+#endif//0
                                        int big_waited;
 
                                        if (!(running && tech_pvt->running))
@@ -1071,7 +1083,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
                                                skypiax_sleep(1000);    //1 millisec
 #endif //WIN32
                                                waitin++;
-#if 0
+#if 1
                                                if(big_waited == 1 && waitin==lil_waitin && tech_pvt->flag_audio_cli == 0){
                                                        memset(cli_out, 255, SAMPLES_PER_FRAME * sizeof(short));
                                                        send(fd, (char *) cli_out, SAMPLES_PER_FRAME * sizeof(short), 0);
@@ -1091,7 +1103,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
 #endif //0
                                        }
                                        if(waitin > 21){
-                                               //NOTICA("waitin is now %d\n", SKYPIAX_P_LOG, waitin);
+                                               NOTICA("waitin is now %d\n", SKYPIAX_P_LOG, waitin);
                                        }
                                        rt = 1;
 
@@ -1205,7 +1217,7 @@ int skypiax_audio_read(private_t * tech_pvt)
                //WARNINGA("read now is 0\n", SKYPIAX_P_LOG);
        }
        if(waitin > 21){
-               //DEBUGA_SKYPE("read is now %d\n", SKYPIAX_P_LOG, waitin);
+               ERRORA("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);