[asterisk-commits] dvossel: branch 1.6.0 r230587 - in /branches/1.6.0: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 20 11:37:08 CST 2009


Author: dvossel
Date: Fri Nov 20 11:37:03 2009
New Revision: 230587

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

........
  r230583 | dvossel | 2009-11-20 11:26:20 -0600 (Fri, 20 Nov 2009) | 6 lines
  
  audiohook signal trigger on every status change
  
  (issue #14618)
  
  Review: https://reviewboard.asterisk.org/r/434/
........

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

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

Modified: branches/1.6.0/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/include/asterisk/audiohook.h?view=diff&rev=230587&r1=230586&r2=230587
==============================================================================
--- branches/1.6.0/include/asterisk/audiohook.h (original)
+++ branches/1.6.0/include/asterisk/audiohook.h Fri Nov 20 11:37:03 2009
@@ -202,6 +202,12 @@
  */
 struct ast_frame *ast_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame);
 
+/*! \brief Update audiohook's status
+ * \param audiohook Audiohook structure
+ * \param audiohook status enum
+ */
+void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audiohook_status status);
+
 /*! \brief Wait for audiohook trigger to be triggered
  * \param audiohook Audiohook to wait on
  */

Modified: branches/1.6.0/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/main/audiohook.c?view=diff&rev=230587&r1=230586&r2=230587
==============================================================================
--- branches/1.6.0/main/audiohook.c (original)
+++ branches/1.6.0/main/audiohook.c Fri Nov 20 11:37:03 2009
@@ -79,7 +79,7 @@
 	}
 
 	/* Since we are just starting out... this audiohook is new */
-	audiohook->status = AST_AUDIOHOOK_STATUS_NEW;
+	ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_NEW);
 
 	return 0;
 }
@@ -351,11 +351,25 @@
 		AST_LIST_INSERT_TAIL(&chan->audiohooks->manipulate_list, audiohook, list);
 
 	/* Change status over to running since it is now attached */
-	audiohook->status = AST_AUDIOHOOK_STATUS_RUNNING;
+	ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_RUNNING);
 
 	ast_channel_unlock(chan);
 
 	return 0;
+}
+
+/*! \brief Update audiohook's status
+ * \param audiohook status enum
+ * \param audiohook Audiohook structure
+ */
+void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audiohook_status status)
+{
+	ast_audiohook_lock(audiohook);
+	if (audiohook->status != AST_AUDIOHOOK_STATUS_DONE) {
+		audiohook->status = status;
+		ast_cond_signal(&audiohook->trigger);
+	}
+	ast_audiohook_unlock(audiohook);
 }
 
 /*! \brief Detach audiohook from channel
@@ -367,7 +381,7 @@
 	if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE)
 		return 0;
 
-	audiohook->status = AST_AUDIOHOOK_STATUS_SHUTDOWN;
+	ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_SHUTDOWN);
 
 	while (audiohook->status != AST_AUDIOHOOK_STATUS_DONE)
 		ast_audiohook_trigger_wait(audiohook);
@@ -386,25 +400,17 @@
 
 	/* Drop any spies */
 	while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->spy_list, list))) {
-		ast_audiohook_lock(audiohook);
-		audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
-		ast_cond_signal(&audiohook->trigger);
-		ast_audiohook_unlock(audiohook);
+		ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 	}
 
 	/* Drop any whispering sources */
 	while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->whisper_list, list))) {
-		ast_audiohook_lock(audiohook);
-		audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
-		ast_cond_signal(&audiohook->trigger);
-		ast_audiohook_unlock(audiohook);
+		ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 	}
 
 	/* Drop any manipulaters */
 	while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->manipulate_list, list))) {
-		ast_audiohook_lock(audiohook);
-		audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
-		ast_audiohook_unlock(audiohook);
+		ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 		audiohook->manipulate_callback(audiohook, NULL, NULL, 0);
 	}
 
@@ -490,7 +496,7 @@
 	ast_channel_unlock(chan);
 
 	if (audiohook && audiohook->status != AST_AUDIOHOOK_STATUS_DONE)
-		audiohook->status = AST_AUDIOHOOK_STATUS_SHUTDOWN;
+		ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_SHUTDOWN);
 
 	return (audiohook ? 0 : -1);
 }
@@ -521,10 +527,7 @@
 	else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
 		AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list);
 
-	ast_audiohook_lock(audiohook);
-	audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
-	ast_cond_signal(&audiohook->trigger);
-	ast_audiohook_unlock(audiohook);
+	ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 
 	ast_channel_unlock(chan);
 
@@ -546,7 +549,7 @@
 		ast_audiohook_lock(audiohook);
 		if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) {
 			AST_LIST_REMOVE_CURRENT(list);
-			audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
+			ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 			ast_audiohook_unlock(audiohook);
 			audiohook->manipulate_callback(audiohook, NULL, NULL, 0);
 			continue;
@@ -594,8 +597,7 @@
 		ast_audiohook_lock(audiohook);
 		if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) {
 			AST_LIST_REMOVE_CURRENT(list);
-			audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
-			ast_cond_signal(&audiohook->trigger);
+			ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 			ast_audiohook_unlock(audiohook);
 			continue;
 		}
@@ -613,8 +615,7 @@
 			ast_audiohook_lock(audiohook);
 			if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) {
 				AST_LIST_REMOVE_CURRENT(list);
-				audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
-				ast_cond_signal(&audiohook->trigger);
+				ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 				ast_audiohook_unlock(audiohook);
 				continue;
 			}
@@ -638,7 +639,7 @@
 			ast_audiohook_lock(audiohook);
 			if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) {
 				AST_LIST_REMOVE_CURRENT(list);
-				audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
+				ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 				ast_audiohook_unlock(audiohook);
 				/* We basically drop all of our links to the manipulate audiohook and prod it to do it's own destructive things */
 				audiohook->manipulate_callback(audiohook, chan, NULL, direction);




More information about the asterisk-commits mailing list