]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypopen: avoid accumulating delay on VMs, better debug logging
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Sat, 6 Aug 2011 08:28:26 +0000 (03:28 -0500)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Sat, 6 Aug 2011 08:28:26 +0000 (03:28 -0500)
src/mod/endpoints/mod_skypopen/mod_skypopen.c
src/mod/endpoints/mod_skypopen/skypopen_protocol.c

index 63f99c567a28f4589e5cc401d5e71c0ca21bfc9d..4f095ff88601b6995af9c9a87764d34a8c1ee06f 100644 (file)
@@ -838,7 +838,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 
        if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) {
                //DEBUGA_SKYPE("CHANNEL READ FRAME in TFLAG_PROGRESS goto CNG\n", SKYPOPEN_P_LOG);
-               switch_sleep(MS_SKYPOPEN * 1000);
+               //switch_sleep(MS_SKYPOPEN * 1000);
                goto cng;
        }
 
@@ -879,7 +879,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
                                DEBUGA_SKYPE("skypopen_audio_read going back to read\n", SKYPOPEN_P_LOG);
                                goto read;
                        }
-                       DEBUGA_SKYPE("skypopen_audio_read Silence\n", SKYPOPEN_P_LOG);
+                       DEBUGA_SKYPE("READ BUFFER EMPTY, skypopen_audio_read Silence\n", SKYPOPEN_P_LOG);
                        memset(tech_pvt->read_frame.data, 255, BYTES_PER_FRAME);
                        tech_pvt->read_frame.datalen = BYTES_PER_FRAME;
 
@@ -1022,17 +1022,16 @@ 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) {
-               DEBUGA_SKYPE("NO SPACE WRITE: %d\n", SKYPOPEN_P_LOG, frame->datalen);
                switch_buffer_zero(tech_pvt->write_buffer);
                no_space = 1;
        }
        switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen);
        switch_mutex_unlock(tech_pvt->mutex_audio_cli);
        if (no_space) {
-               switch_sleep(MS_SKYPOPEN * 1000);
-       } else {
-               tech_pvt->begin_to_write = 1;
+               //switch_sleep(MS_SKYPOPEN * 1000);
+               DEBUGA_SKYPE("NO SPACE in WRITE BUFFER: there was no space for %d\n", SKYPOPEN_P_LOG, frame->datalen);
        }
+       tech_pvt->begin_to_write = 1;
 
        return SWITCH_STATUS_SUCCESS;
 }
index 129e343ba6fb5e394ff21d4eb64173df1ebe0771..a308e2e551de77fd991eb8120dbfd336d0d4fe60 100644 (file)
@@ -540,6 +540,7 @@ int skypopen_signaling_read(private_t *tech_pvt)
                                        DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPOPEN_P_LOG, id);
                                }
 #if 0
+#ifndef WIN32
                                if (!strcasecmp(prop, "DURATION")) {    /* each 20 seconds, we zero the buffers and sync the timers */
                                        if (!((atoi(value) % 20))) {
                                                if (tech_pvt->read_buffer) {
@@ -565,6 +566,7 @@ int skypopen_signaling_read(private_t *tech_pvt)
                                                DEBUGA_SKYPE("Synching audio on skype_call: %s.\n", SKYPOPEN_P_LOG, id);
                                        }
                                }
+#endif //WIN32
 #endif //0
                                if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
                                        if (strcasecmp(id, tech_pvt->skype_call_id)) {
@@ -882,19 +884,21 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
                                                   || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
                                                   || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) {
 
-                                       unsigned int fdselect;
+                                       //unsigned int fdselect;
                                        int rt=1;
-                                       fd_set fs;
+                                       //fd_set fs;
                                        //struct timeval to;
                                        int nospace;
 
                                        if (!(running && tech_pvt->running))
                                                break;
+#if 0
                                        fdselect = fd;
                                        FD_ZERO(&fs);
                                        FD_SET(fdselect, &fs);
-                                       //to.tv_usec = MS_SKYPOPEN * 1000 * 3;
-                                       //to.tv_sec = 0;
+                                       to.tv_usec = MS_SKYPOPEN * 1000 * 3;
+                                       to.tv_sec = 0;
+#endif //0
 
                                        if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
                                                switch_core_timer_next(&tech_pvt->timer_read_srv);
@@ -935,7 +939,7 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
                                                        }
                                                        switch_mutex_unlock(tech_pvt->mutex_audio_srv);
                                                        if (nospace) {
-                                                               DEBUGA_SKYPE("NO SPACE READ: there was no space for: %d\n", SKYPOPEN_P_LOG, len);
+                                                               DEBUGA_SKYPE("NO SPACE in READ BUFFER: there was no space for: %d\n", SKYPOPEN_P_LOG, len);
                                                        }
                                                } else if (len == 0) {
                                                        DEBUGA_SKYPE("CLOSED\n", SKYPOPEN_P_LOG);
@@ -1080,7 +1084,7 @@ void *skypopen_do_tcp_cli_thread_func(void *obj)
                                                }
                                                switch_mutex_lock(tech_pvt->mutex_audio_cli);
                                                if (tech_pvt->write_buffer && switch_buffer_inuse(tech_pvt->write_buffer)) {
-                                                       bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, BYTES_PER_FRAME * 2);
+                                                       bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, BYTES_PER_FRAME);
                                                }
                                                switch_mutex_unlock(tech_pvt->mutex_audio_cli);