[asterisk-commits] rmudgett: trunk r394825 - in /trunk: bridges/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 19 17:47:11 CDT 2013


Author: rmudgett
Date: Fri Jul 19 17:47:10 2013
New Revision: 394825

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394825
Log:
Extract a repeated test into ast_channel_has_audio_frame_or_monitor().

Modified:
    trunk/bridges/bridge_native_rtp.c
    trunk/include/asterisk/channel.h
    trunk/main/bridging.c
    trunk/main/channel.c

Modified: trunk/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/trunk/bridges/bridge_native_rtp.c?view=diff&rev=394825&r1=394824&r2=394825
==============================================================================
--- trunk/bridges/bridge_native_rtp.c (original)
+++ trunk/bridges/bridge_native_rtp.c Fri Jul 19 17:47:10 2013
@@ -45,7 +45,6 @@
 #include "asterisk/bridging_technology.h"
 #include "asterisk/frame.h"
 #include "asterisk/rtp_engine.h"
-#include "asterisk/audiohook.h"
 
 /*! \brief Forward declarations for frame hook usage */
 static int native_rtp_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
@@ -85,13 +84,7 @@
 /*! \brief Internal helper function which checks whether the channels are compatible with our native bridging */
 static int native_rtp_bridge_capable(struct ast_channel *chan)
 {
-	if (ast_channel_monitor(chan) || (ast_channel_audiohooks(chan) &&
-		!ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))) ||
-		!ast_framehook_list_contains_no_active(ast_channel_framehooks(chan))) {
-		return 0;
-	} else {
-		return 1;
-	}
+	return ast_channel_has_audio_frame_or_monitor(chan);
 }
 
 /*! \brief Internal helper function which gets all RTP information (glue and instances) relating to the given channels */

Modified: trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/channel.h?view=diff&rev=394825&r1=394824&r2=394825
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Fri Jul 19 17:47:10 2013
@@ -4336,6 +4336,16 @@
 const char *ast_channel_oldest_linkedid(const char *a, const char *b);
 
 /*!
+ * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
+ * \since 12.0.0
+ *
+ * \param chan The channel to check.
+ *
+ * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
+ */
+int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan);
+
+/*!
  * \brief Removes the trailing identifiers from a channel name string
  * \since 12.0.0
  *

Modified: trunk/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridging.c?view=diff&rev=394825&r1=394824&r2=394825
==============================================================================
--- trunk/main/bridging.c (original)
+++ trunk/main/bridging.c Fri Jul 19 17:47:10 2013
@@ -63,7 +63,6 @@
 #include "asterisk/core_local.h"
 #include "asterisk/core_unreal.h"
 #include "asterisk/features_config.h"
-#include "asterisk/audiohook.h"
 
 /*! All bridges container. */
 static struct ao2_container *bridges;
@@ -4722,10 +4721,7 @@
 	if (!AST_LIST_EMPTY(ast_channel_readq(chan))) {
 		return NULL;
 	}
-	if (ast_channel_monitor(chan)
-		|| (ast_channel_audiohooks(chan)
-			&& !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan)))
-		|| !ast_framehook_list_contains_no_active(ast_channel_framehooks(chan))) {
+	if (ast_channel_has_audio_frame_or_monitor(chan)) {
 		/* Channel has an active monitor, audiohook, or framehook. */
 		return NULL;
 	}
@@ -4771,10 +4767,7 @@
 		ast_channel_unlock(peer);
 		return NULL;
 	}
-	if (ast_channel_monitor(peer)
-		|| (ast_channel_audiohooks(peer)
-			&& !ast_audiohook_write_list_empty(ast_channel_audiohooks(peer)))
-		|| !ast_framehook_list_contains_no_active(ast_channel_framehooks(peer))) {
+	if (ast_channel_has_audio_frame_or_monitor(peer)) {
 		/* Peer has an active monitor, audiohook, or framehook. */
 		ast_channel_unlock(peer);
 		return NULL;

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=394825&r1=394824&r2=394825
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Fri Jul 19 17:47:10 2013
@@ -2627,6 +2627,14 @@
 		ast_channel_unlock(bridge);
 		ast_channel_unref(bridge);
 	}
+}
+
+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_framehook_list_contains_no_active(ast_channel_framehooks(chan));
 }
 
 static void destroy_hooks(struct ast_channel *chan)




More information about the asterisk-commits mailing list