[Freeswitch-svn] [commit] r13070 - freeswitch/trunk/src/mod/applications/mod_cluechoo

FreeSWITCH SVN anthm at freeswitch.org
Thu Apr 16 20:38:40 PDT 2009


Author: anthm
Date: Thu Apr 16 22:38:40 2009
New Revision: 13070

Log:
up

Modified:
   freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c

Modified: freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c	Thu Apr 16 22:38:40 2009
@@ -217,7 +217,7 @@
 	int hangover = 40, hangunder = 15;
 	int talking = 0;
 	int energy_level = 500;
-
+	int done = 0;
     switch_core_session_get_read_impl(session, &read_impl);
 
 	printf("%s", SWITCH_SEQ_CLEARSCR);
@@ -245,15 +245,18 @@
 
     for (x = COLS - 1; ; --x) {
 
-		if (!switch_channel_ready(channel)) {
-			break;
+		if (!done && !switch_channel_ready(channel)) {
+			done = 1;
 		}
-
-		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-		if (!SWITCH_READ_ACCEPTABLE(status)) {
-			break;
+		
+		if (!done) {
+			status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
+				done = 1;
+			}
 		}
-
+		
+		if (!done)
 		{
 			int16_t *fdata = (int16_t *) read_frame->data;
 			uint32_t samples = read_frame->datalen / sizeof(*fdata);
@@ -261,6 +264,7 @@
 			double energy = 0;
 			int divisor = 0;
 
+			
 			for (count = 0; count < samples; count++) {
 				energy += abs(fdata[j]);
 				j += read_impl.number_of_channels;
@@ -296,11 +300,13 @@
 					}
 				}
 			}
-		}
 
-		if (!talking) {
-			x++;
-			continue;
+			if (!talking) {
+				x++;
+				continue;
+			}
+		} else {
+			usleep(20000);
 		}
 
 		if (LOGO == 0) {
@@ -310,8 +316,6 @@
 		}
 		refresh();
 
-		
-
 		/*
 		if (x == COLS / 4) {
 			sleep(2);



More information about the Freeswitch-svn mailing list