Revision
14683
Author
gmaruzz
Date
2009-08-30 14:44:25 -0500 (Sun, 30 Aug 2009)

Log Message

celliax: initialize alsa only at module loading, and give the serial monitoring loop a breach where other threads can enter

Modified Paths

Diff

Modified: freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c (14682 => 14683)


--- freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c	2009-08-30 05:30:19 UTC (rev 14682)
+++ freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c	2009-08-30 19:44:25 UTC (rev 14683)
@@ -253,15 +253,6 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	int res;
-	res = alsa_init(tech_pvt);
-	if (res == -1) {
-		ERRORA("Failed initializing sound device\n", SKYPIAX_P_LOG);
-		/* we failed, free the PVT */
-		//if (tmp)
-		//free(tmp);
-		//return NULL;
-	}
 	//teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, tech_pvt->read_codec.implementation->actual_samples_per_second);
 	teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, 8000);
 
@@ -479,7 +470,6 @@
 
 		switch_core_timer_destroy(&tech_pvt->timer);
 
-		alsa_shutdown(tech_pvt);
 
 		*tech_pvt->session_uuid_str = '\0';
 		tech_pvt->interface_state = SKYPIAX_STATE_IDLE;
@@ -1514,7 +1504,6 @@
 
 				switch_sleep(100000);
 
-#ifdef NOTDEF
 				res = alsa_init(&globals.SKYPIAX_INTERFACES[interface_id]);
 				if (res == -1) {
 					ERRORA("Failed initializing sound device\n", SKYPIAX_P_LOG);
@@ -1524,6 +1513,7 @@
 					//return NULL;
 				}
 
+#ifdef NOTDEF
 				switch_threadattr_create(&celliax_signaling_thread_attr, celliax_module_pool);
 				switch_threadattr_stacksize_set(celliax_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
 				switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].celliax_signaling_thread, celliax_signaling_thread_attr,
@@ -1654,6 +1644,10 @@
 		tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
 
 		if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
+
+
+
+		alsa_shutdown(&globals.SKYPIAX_INTERFACES[interface_id]);
 			if (globals.SKYPIAX_INTERFACES[interface_id].celliax_signaling_thread) {
 #ifdef WIN32
 				switch_file_write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", &howmany);	// let's the controldev_thread die
@@ -2386,6 +2380,7 @@
 				//FIXME ERRORA("celliax_new failed! BAD BAD BAD\n", CELLIAX_P_LOG);
 				//FIXME }
 			}
+usleep(100); //give other threads a chance
 		}
 	} else {
 		ERRORA("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", SKYPIAX_P_LOG);