[asterisk-commits] russell: branch group/res_fax r233870 - /team/group/res_fax/res/res_fax.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 9 11:09:56 CST 2009


Author: russell
Date: Wed Dec  9 11:09:51 2009
New Revision: 233870

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=233870
Log:
Generate silence in between CNG tones.

Previously, the loop that generates the CNG tone sent no other audio in between
tones.  This resulted in a failure to detect CNG when the receiver was some
some versions of Asterisk.  The cause of this failure is that the CNG detection
code will not report successful detection of the tone until it sees the tone
end.  Since no other audio was being sent, the detection was never reported.

The code now enables a silence generator on the channel while CNG is not being
sent.  CNG is now properly detected on the receiving side.

Modified:
    team/group/res_fax/res/res_fax.c

Modified: team/group/res_fax/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/group/res_fax/res/res_fax.c?view=diff&rev=233870&r1=233869&r2=233870
==============================================================================
--- team/group/res_fax/res/res_fax.c (original)
+++ team/group/res_fax/res/res_fax.c Wed Dec  9 11:09:51 2009
@@ -709,10 +709,19 @@
 	}
 
 	if (request_t38 || !details->option.allow_audio) {
+		struct ast_silence_generator *silence_gen;
+
+		silence_gen = ast_channel_start_silence_generator(chan);
+
 		while (timeout > 0) {
 			if (send_cng > 3000) {
+				ast_channel_stop_silence_generator(chan, silence_gen);
+				silence_gen = NULL;
 				ast_tonepair_start(chan, 1100, 0, 500, 0);
 				send_cng = 0;
+			} else if (!chan->generator) {
+				/* The CNG tone is done so restart silence generation. */
+				silence_gen = ast_channel_start_silence_generator(chan);
 			}
 			/* this timeout *MUST* be 500ms, in order to keep the spacing
 			 * of CNG tones correct when this loop is sending them
@@ -738,6 +747,10 @@
 				}
 			}
 			if (!(frame = ast_read(chan))) {
+				if (silence_gen) {
+					ast_channel_stop_silence_generator(chan, silence_gen);
+					silence_gen = NULL;
+				}
 				return -1;
 			}
 			if ((frame->frametype == AST_FRAME_CONTROL) &&
@@ -775,6 +788,11 @@
 				}
 			}
 			ast_frfree(frame);
+		}
+
+		if (silence_gen) {
+			ast_channel_stop_silence_generator(chan, silence_gen);
+			silence_gen = NULL;
 		}
 	}
 




More information about the asterisk-commits mailing list