[svn-commits] rmudgett: trunk r394836 - in /trunk: include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 19 18:30:12 CDT 2013


Author: rmudgett
Date: Fri Jul 19 18:30:10 2013
New Revision: 394836

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394836
Log:
Minor optimizations.

* Made ast_audiohook_detach_list() and ast_audiohook_write_list_empty()
NULL tolerant.

* Made ast_audiohook_detach_list() return void since it is a destructor.

Modified:
    trunk/include/asterisk/audiohook.h
    trunk/main/audiohook.c
    trunk/main/channel.c

Modified: trunk/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/audiohook.h?view=diff&rev=394836&r1=394835&r2=394836
==============================================================================
--- trunk/include/asterisk/audiohook.h (original)
+++ trunk/include/asterisk/audiohook.h Fri Jul 19 18:30:10 2013
@@ -175,11 +175,12 @@
  */
 int ast_audiohook_detach(struct ast_audiohook *audiohook);
 
-/*! \brief Detach audiohooks from list and destroy said list
- * \param audiohook_list List of audiohooks
- * \return Returns 0 on success, -1 on failure
- */
-int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list);
+/*!
+ * \brief Detach audiohooks from list and destroy said list
+ * \param audiohook_list List of audiohooks (NULL tolerant)
+ * \return Nothing
+ */
+void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list);
 
 /*! \brief Move an audiohook from one channel to a new one
  *
@@ -221,7 +222,9 @@
 int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook);
 
 /*!
- * \brief determines if a audiohook_list is empty or not.
+ * \brief Determine if a audiohook_list is empty or not.
+ *
+ * \param audiohook Audiohook to check.  (NULL also means empty)
  *
  * retval 0 false, 1 true
  */

Modified: trunk/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/audiohook.c?view=diff&rev=394836&r1=394835&r2=394836
==============================================================================
--- trunk/main/audiohook.c (original)
+++ trunk/main/audiohook.c Fri Jul 19 18:30:10 2013
@@ -512,14 +512,14 @@
 	return 0;
 }
 
-/*! \brief Detach audiohooks from list and destroy said list
- * \param audiohook_list List of audiohooks
- * \return Returns 0 on success, -1 on failure
- */
-int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
-{
-	int i = 0;
-	struct ast_audiohook *audiohook = NULL;
+void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
+{
+	int i;
+	struct ast_audiohook *audiohook;
+
+	if (!audiohook_list) {
+		return;
+	}
 
 	/* Drop any spies */
 	while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->spy_list, list))) {
@@ -547,8 +547,6 @@
 
 	/* Free ourselves */
 	ast_free(audiohook_list);
-
-	return 0;
 }
 
 /*! \brief find an audiohook based on its source
@@ -899,13 +897,10 @@
 
 int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
 {
-	if (AST_LIST_EMPTY(&audiohook_list->spy_list) &&
-		AST_LIST_EMPTY(&audiohook_list->whisper_list) &&
-		AST_LIST_EMPTY(&audiohook_list->manipulate_list)) {
-
-		return 1;
-	}
-	return 0;
+	return !audiohook_list
+		|| (AST_LIST_EMPTY(&audiohook_list->spy_list)
+			&& AST_LIST_EMPTY(&audiohook_list->whisper_list)
+			&& AST_LIST_EMPTY(&audiohook_list->manipulate_list));
 }
 
 /*! \brief Pass a frame off to be handled by the audiohook core

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=394836&r1=394835&r2=394836
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Fri Jul 19 18:30:10 2013
@@ -2632,8 +2632,7 @@
 int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan)
 {
 	return ast_channel_monitor(chan)
-		|| (ast_channel_audiohooks(chan)
-			&& !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan)))
+		|| !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))
 		|| !ast_framehook_list_contains_no_active(ast_channel_framehooks(chan));
 }
 




More information about the svn-commits mailing list