[asterisk-commits] oej: branch oej/mutestream-trunk r215152 - /team/oej/mutestream-trunk/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 1 13:27:57 CDT 2009


Author: oej
Date: Tue Sep  1 13:27:54 2009
New Revision: 215152

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=215152
Log:
More changes from reviewboard. "Getting close" said Russell. "thanks" said Olle :-)

Modified:
    team/oej/mutestream-trunk/res/res_mutestream.c

Modified: team/oej/mutestream-trunk/res/res_mutestream.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/oej/mutestream-trunk/res/res_mutestream.c?view=diff&rev=215152&r1=215151&r2=215152
==============================================================================
--- team/oej/mutestream-trunk/res/res_mutestream.c (original)
+++ team/oej/mutestream-trunk/res/res_mutestream.c Tue Sep  1 13:27:54 2009
@@ -139,6 +139,7 @@
 	ast_channel_lock(chan);
 	/* Grab datastore which contains our mute information */
 	if (!(datastore = ast_channel_datastore_find(chan, &mute_datastore, NULL))) {
+		ast_channel_unlock(chan);
 		ast_debug(2, "Can't find any datastore to use. Bad. \n");
 		return 0;
 	}
@@ -162,7 +163,7 @@
 }
 
 /*! \brief Initialize mute hook on channel, but don't activate it
-	Assumes that the channel is locked
+	\pre Assumes that the channel is locked
 */
 static struct ast_datastore *initialize_mutehook(struct ast_channel *chan)
 {
@@ -231,7 +232,12 @@
 	}
 
 	if (is_new) {
-		mute_add_audiohook(chan, mute, datastore);
+		if(mute_add_audiohook(chan, mute, datastore)) {
+			/* Can't add audiohook - already printed error message */
+			ast_datastore_free(datastore);
+			ast_free(mute);
+		}
+		
 	}
 	ast_channel_unlock(chan);
 
@@ -302,7 +308,11 @@
 	}
 
 	if (is_new) {
-		mute_add_audiohook(c, mute, datastore);
+		if(mute_add_audiohook(c, mute, datastore)) {
+			/* Can't add audiohook - already printed error message */
+			ast_datastore_free(datastore);
+			ast_free(mute);
+		}
 	}
 	ast_channel_unlock(c);
 	ast_channel_unref(c);
@@ -325,11 +335,13 @@
 
 static int load_module(void)
 {
-	ast_custom_function_register(&mute_function);
-
-	ast_manager_register2("MuteStream", EVENT_FLAG_SYSTEM, manager_mutestream,
+	int res;
+	res = ast_custom_function_register(&mute_function);
+
+	res |= ast_manager_register2("MuteStream", EVENT_FLAG_SYSTEM, manager_mutestream,
                         "Mute an audio stream", mandescr_mutestream);
-	return AST_MODULE_LOAD_SUCCESS;
+	
+	return (res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS);
 }
 
 static int unload_module(void)
@@ -341,7 +353,4 @@
 	return 0;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "MUTE resource",
-		.load = load_module,
-		.unload = unload_module,
-	       );
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mute audio stream resources");




More information about the asterisk-commits mailing list