[asterisk-commits] file: branch file/ah r59061 - /team/file/ah/main/audiohook.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Mar 19 20:49:43 MST 2007


Author: file
Date: Mon Mar 19 22:49:43 2007
New Revision: 59061

URL: http://svn.digium.com/view/asterisk?view=rev&rev=59061
Log:
Only create/destroy the factories needed for the specific audiohook type.

Modified:
    team/file/ah/main/audiohook.c

Modified: team/file/ah/main/audiohook.c
URL: http://svn.digium.com/view/asterisk/team/file/ah/main/audiohook.c?view=diff&rev=59061&r1=59060&r2=59061
==============================================================================
--- team/file/ah/main/audiohook.c (original)
+++ team/file/ah/main/audiohook.c Mon Mar 19 22:49:43 2007
@@ -71,11 +71,16 @@
 	ast_mutex_init(&audiohook->lock);
 	ast_cond_init(&audiohook->trigger, NULL);
 
-	/* Initialize our factories */
-	ast_slinfactory_init(&audiohook->read_factory);
-	/* Manipulate type only needs one factory */
-	if (type != AST_AUDIOHOOK_TYPE_MANIPULATE)
+	/* Setup the factories that are needed for this audiohook type */
+	switch (type) {
+	case AST_AUDIOHOOK_TYPE_SPY:
+		ast_slinfactory_init(&audiohook->read_factory);
+	case AST_AUDIOHOOK_TYPE_WHISPER:
 		ast_slinfactory_init(&audiohook->write_factory);
+		break;
+	default:
+		break;
+	}
 
 	/* Since we are just starting out... this audiohook is new */
 	audiohook->status = AST_AUDIOHOOK_STATUS_NEW;
@@ -89,10 +94,16 @@
  */
 int ast_audiohook_destroy(struct ast_audiohook *audiohook)
 {
-	/* Drop the factories */
-	ast_slinfactory_destroy(&audiohook->read_factory);
-	if (audiohook->type != AST_AUDIOHOOK_TYPE_MANIPULATE)
+	/* Drop the factories used by this audiohook type */
+	switch (audiohook->type) {
+	case AST_AUDIOHOOK_TYPE_SPY:
+		ast_slinfactory_destroy(&audiohook->read_factory);
+	case AST_AUDIOHOOK_TYPE_WHISPER:
 		ast_slinfactory_destroy(&audiohook->write_factory);
+		break;
+	default:
+		break;
+	}
 
 	/* Destroy translation path if present */
 	if (audiohook->trans_pvt)



More information about the asterisk-commits mailing list