Revision
16661
Author
gmaruzz
Date
2010-02-16 14:21:57 -0600 (Tue, 16 Feb 2010)

Log Message

skypiax: more timin fixes, works well on linux, with skype beta 2, 100HZ, and switch_ivr.c line 157 set to ms>1. Let's see on windoz

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (16660 => 16661)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2010-02-16 17:34:32 UTC (rev 16660)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2010-02-16 20:21:57 UTC (rev 16661)
@@ -845,15 +845,19 @@
 		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);
+		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_read);
 #ifdef TIMER_WRITE
-
-			switch_core_timer_sync(&tech_pvt->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);
 		}
 		break;
@@ -987,7 +991,8 @@
 			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 @@
 			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);

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (16660 => 16661)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	2010-02-16 17:34:32 UTC (rev 16660)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	2010-02-16 20:21:57 UTC (rev 16661)
@@ -828,7 +828,7 @@
 						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 @@
 							}
 
 						} 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 @@
 					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 @@
 						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 @@
 #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 @@
 		//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);