[asterisk-commits] mmichelson: trunk r197543 - in /trunk: ./ apps/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 28 09:58:13 CDT 2009


Author: mmichelson
Date: Thu May 28 09:58:06 2009
New Revision: 197543

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=197543
Log:
Merged revisions 197537 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r197537 | mmichelson | 2009-05-28 09:49:13 -0500 (Thu, 28 May 2009) | 21 lines
  
  Add flags to chanspy audiohook so that audio stays in sync.
  
  There are two flags being added to the chanspy audiohook here. One
  is the pre-existing AST_AUDIOHOOK_TRIGGER_SYNC flag. With this set,
  we ensure that the read and write slinfactories on the audiohook do
  not skew beyond a certain tolerance.
  
  In addition, there is a new audiohook flag added here,
  AST_AUDIOHOOK_SMALL_QUEUE. With this flag set, we do not allow for
  a slinfactory to build up a substantial amount of audio before 
  flushing it. For this particular issue, this means that the person 
  spying on the call will hear the conversations in real time with very 
  little delay in the audio.
  
  (closes issue #13745)
  Reported by: geoffs
  Patches:
        13745.patch uploaded by mmichelson (license 60)
  Tested by: snblitz
........

Modified:
    trunk/   (props changed)
    trunk/apps/app_chanspy.c
    trunk/include/asterisk/audiohook.h
    trunk/main/audiohook.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_chanspy.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=197543&r1=197542&r2=197543
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Thu May 28 09:58:06 2009
@@ -455,6 +455,7 @@
 
 	ast_log(LOG_NOTICE, "Attaching %s to %s\n", spychan_name, autochan->chan->name);
 
+	ast_set_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC | AST_AUDIOHOOK_SMALL_QUEUE);
 	res = ast_audiohook_attach(autochan->chan, audiohook);
 
 	if (!res && ast_test_flag(autochan->chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(autochan->chan))) {

Modified: trunk/include/asterisk/audiohook.h
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/include/asterisk/audiohook.h?view=diff&rev=197543&r1=197542&r2=197543
==============================================================================
--- trunk/include/asterisk/audiohook.h (original)
+++ trunk/include/asterisk/audiohook.h Thu May 28 09:58:06 2009
@@ -58,6 +58,10 @@
 	AST_AUDIOHOOK_TRIGGER_WRITE = (2 << 0), /*!< Audiohook wants to be triggered when writing audio out */
 	AST_AUDIOHOOK_WANTS_DTMF = (1 << 1),    /*!< Audiohook also wants to receive DTMF frames */
 	AST_AUDIOHOOK_TRIGGER_SYNC = (1 << 2),  /*!< Audiohook wants to be triggered when both sides have combined audio available */
+	/*! Audiohooks with this flag set will not allow for a large amount of samples to build up on its
+	 * slinfactories. We will flush the factories if they contain too many samples.
+	 */
+	AST_AUDIOHOOK_SMALL_QUEUE = (1 << 3),
 };
 
 #define AST_AUDIOHOOK_SYNC_TOLERANCE 100 /*< Tolerance in milliseconds for audiohooks synchronization */

Modified: trunk/main/audiohook.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/audiohook.c?view=diff&rev=197543&r1=197542&r2=197543
==============================================================================
--- trunk/main/audiohook.c (original)
+++ trunk/main/audiohook.c Thu May 28 09:58:06 2009
@@ -123,6 +123,7 @@
 	struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
 	struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory);
 	struct timeval *rwtime = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *rwtime;
+	int our_factory_samples;
 	int our_factory_ms;
 	int other_factory_samples;
 	int other_factory_ms;
@@ -130,13 +131,22 @@
 	/* Update last feeding time to be current */
 	*rwtime = ast_tvnow();
 
-	our_factory_ms = ast_tvdiff_ms(*rwtime, previous_time) + (ast_slinfactory_available(factory) / 8);
+	our_factory_samples = ast_slinfactory_available(factory);
+	our_factory_ms = ast_tvdiff_ms(*rwtime, previous_time) + (our_factory_samples / 8);
 	other_factory_samples = ast_slinfactory_available(other_factory);
 	other_factory_ms = other_factory_samples / 8;
 
 	if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && other_factory_samples && (our_factory_ms - other_factory_ms > AST_AUDIOHOOK_SYNC_TOLERANCE)) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Flushing audiohook %p so it remains in sync\n", audiohook);
+		ast_slinfactory_flush(factory);
+		ast_slinfactory_flush(other_factory);
+	}
+
+	if (ast_test_flag(audiohook, AST_AUDIOHOOK_SMALL_QUEUE) && (our_factory_samples > 640 || other_factory_samples > 640)) {
+		if (option_debug) {
+			ast_log(LOG_DEBUG, "Audiohook %p has stale audio in its factories. Flushing them both\n", audiohook);
+		}
 		ast_slinfactory_flush(factory);
 		ast_slinfactory_flush(other_factory);
 	}




More information about the asterisk-commits mailing list