[asterisk-commits] file: branch 1.6.0 r113298 - in /branches/1.6.0: ./ main/audiohook.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 8 10:06:44 CDT 2008


Author: file
Date: Tue Apr  8 10:06:28 2008
New Revision: 113298

URL: http://svn.digium.com/view/asterisk?view=rev&rev=113298
Log:
Merged revisions 113297 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r113297 | file | 2008-04-08 12:05:35 -0300 (Tue, 08 Apr 2008) | 12 lines

Merged revisions 113296 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r113296 | file | 2008-04-08 12:03:43 -0300 (Tue, 08 Apr 2008) | 4 lines

If audio suddenly gets fed into one side of a channel after a lapse of frames flush the other factory so that old audio does not remain in the factory causing the sync code to not execute.
(closes issue #12296)
Reported by: jvandal

........

................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/main/audiohook.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/main/audiohook.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/audiohook.c?view=diff&rev=113298&r1=113297&r2=113298
==============================================================================
--- branches/1.6.0/main/audiohook.c (original)
+++ branches/1.6.0/main/audiohook.c Tue Apr  8 10:06:28 2008
@@ -121,13 +121,22 @@
 int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction, struct ast_frame *frame)
 {
 	struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
-	struct timeval *time = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time);
+	struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory);
+	struct timeval *time = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *time;
+
+	/* Update last feeding time to be current */
+	*time = ast_tvnow();
+
+	/* If we are using a sync trigger and this factory suddenly got audio fed in after a lapse, then flush both factories to ensure they remain in sync */
+	if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && ast_slinfactory_available(other_factory) && (ast_tvdiff_ms(*time, previous_time) > (ast_slinfactory_available(other_factory) / 8))) {
+		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);
+	}
 
 	/* Write frame out to respective factory */
 	ast_slinfactory_feed(factory, frame);
-
-	/* Update last fed time for the above factory */
-	*time = ast_tvnow();
 
 	/* If we need to notify the respective handler of this audiohook, do so */
 	if ((ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_MODE) == AST_AUDIOHOOK_TRIGGER_READ) && (direction == AST_AUDIOHOOK_DIRECTION_READ)) {




More information about the asterisk-commits mailing list