[asterisk-commits] dvossel: branch dvossel/hd_confbridge r314405 - in /team/dvossel/hd_confbridg...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 20 09:27:46 CDT 2011


Author: dvossel
Date: Wed Apr 20 09:27:41 2011
New Revision: 314405

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=314405
Log:
Addresses various reviewboard comments

Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c

Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=314405&r1=314404&r2=314405
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Wed Apr 20 09:27:41 2011
@@ -88,7 +88,7 @@
 				<para>Type refers to which type of profile the option belongs too.  Type can be <literal>bridge</literal> or <literal>user</literal>.</para>
 			</parameter>
             <parameter name="option" required="true">
-				<para>Option refers to confbridge.conf option that is being set dynamically on this channel.</para>
+				<para>Option refers to <filename>confbridge.conf</filename> option that is being set dynamically on this channel.</para>
 			</parameter>
 		</syntax>
 		<description>
@@ -345,7 +345,7 @@
 	struct conference_bridge *conference_bridge = obj;
 	struct ast_app *mixmonapp = pbx_findapp("MixMonitor");
 	struct ast_channel *chan;
-	struct ast_str *filename = ast_str_alloca(128);
+	struct ast_str *filename = ast_str_alloca(PATH_MAX);
 
 	if (!mixmonapp) {
 		ao2_ref(conference_bridge, -1);
@@ -465,9 +465,16 @@
 
 	cap = ast_format_cap_destroy(cap);
 	ao2_ref(conference_bridge, +1); /* give the record thread a ref */
+
+	if (ast_pthread_create_background(&conference_bridge->record_thread, NULL, record_thread, conference_bridge)) {
+		ast_log(LOG_WARNING, "Failed to create recording channel for conference %s\n", conference_bridge->name);
+
+		ao2_unlock(conference_bridge);
+		ao2_ref(conference_bridge, -1); /* error so remove ref */
+		return -1;
+	}
+
 	ao2_unlock(conference_bridge);
-
-	ast_pthread_create_detached_background(&conference_bridge->record_thread, NULL, record_thread, conference_bridge);
 	return 0;
 }
 
@@ -946,7 +953,7 @@
 /*!
  * \internal
  * \brief allocates playback chan on a channel
- * \note expects conference to be locked before calling this function
+ * \pre expects conference to be locked before calling this function
  */
 static int alloc_playback_chan(struct conference_bridge *conference_bridge)
 {
@@ -1048,11 +1055,15 @@
 {
 	char *conf_name = pvt_data;
 	int talking;
-	if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_START_TALKING) {
+
+	switch (bridge_channel->state) {
+	case AST_BRIDGE_CHANNEL_STATE_START_TALKING:
 		talking = 1;
-	} else if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_STOP_TALKING) {
+		break;
+	case AST_BRIDGE_CHANNEL_STATE_STOP_TALKING:
 		talking = 0;
-	} else {
+		break;
+	default:
 		return; /* uhh this shouldn't happen, but bail if it does. */
 	}
 
@@ -1087,11 +1098,14 @@
 			chan->language);
 		res = ast_waitstream(chan, AST_DIGIT_ANY);
 		if (res > 0) {
+			/* Account for digit already read during ivalid pin playback
+			 * resetting pin buf. */
 			pin_guess[0] = res;
 			pin_guess[1] = '\0';
 			tmp = pin_guess + 1;
 			len = MAX_PIN - 2;
 		} else {
+			/* reset pin buf as empty buffer. */
 			tmp = pin_guess;
 			len = MAX_PIN - 1;
 		}
@@ -1510,7 +1524,7 @@
 				bridge_channel->chan);
 			break;
 		case MENU_ACTION_PLAYBACK:
-			if (!(stop_prompts)) {
+			if (!stop_prompts) {
 				res |= action_playback(bridge_channel, menu_action->data.playback_file);
 			}
 			break;
@@ -1598,7 +1612,6 @@
 	struct conf_menu *menu)
 {
 	struct conference_bridge *conference_bridge = conference_bridge_user->conference_bridge;
-	int res = 0;
 
 	/* See if music on hold is playing */
 	ao2_lock(conference_bridge);
@@ -1618,7 +1631,7 @@
 	}
 	ao2_unlock(conference_bridge);
 
-	return res;
+	return 0;
 }
 
 static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
@@ -1797,7 +1810,7 @@
 	}
 	ao2_lock(bridge);
 	AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
-		if (!strncmp(user, participant->chan->name, strlen(participant->chan->name))) {
+		if (!strncmp(user, participant->chan->name, strlen(user))) {
 			break;
 		}
 	}
@@ -1956,7 +1969,7 @@
 	bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
 	if (!bridge) {
 		ast_cli(a->fd, "Conference not found.\n");
-		return CLI_SUCCESS;
+		return CLI_FAILURE;
 	}
 	if (conf_is_recording(bridge)) {
 		ast_cli(a->fd, "Conference is already being recorded.\n");
@@ -1971,7 +1984,7 @@
 	if (conf_start_record(bridge)) {
 		ast_cli(a->fd, "Could not start recording due to internal error.\n");
 		ao2_ref(bridge, -1);
-		return 0;
+		return CLI_FAILURE;
 	}
 	ast_cli(a->fd, "Recording started\n");
 	ao2_ref(bridge, -1);
@@ -2095,7 +2108,7 @@
 	const char *actionid = astman_get_header(m, "ActionID");
 	struct conference_bridge *bridge = NULL;
 	struct ao2_iterator i;
-	char id_text[80] = "";
+	char id_text[512] = "";
 	int totalitems = 0;
 
 	if (!ast_strlen_zero(actionid)) {
@@ -2113,6 +2126,8 @@
 	i = ao2_iterator_init(conference_bridges, 0);
 	while ((bridge = ao2_iterator_next(&i))) {
 		totalitems++;
+
+		ao2_lock(bridge);
 		astman_append(s,
 		"Event: ConfbridgeListRooms\r\n"
 		"%s"
@@ -2126,6 +2141,7 @@
 		bridge->users,
 		bridge->markedusers,
 		bridge->locked ? "Yes" : "No"); 
+		ao2_unlock(bridge);
 
 		ao2_ref(bridge, -1);
 	}

Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=314405&r1=314404&r2=314405
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Wed Apr 20 09:27:41 2011
@@ -35,7 +35,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/pbx.h"
 
-#define CONF_CONFIG "confbridge.conf"
+#define CONFBRIDGE_CONFIG "confbridge.conf"
 
 static struct ao2_container *user_profiles;
 static struct ao2_container *bridge_profiles;
@@ -44,14 +44,14 @@
 /*! bridge profile container functions */
 static int bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	struct bridge_profile *entry1 = obj;
-	struct bridge_profile *entry2 = arg;
+	const struct bridge_profile *entry1 = obj;
+	const struct bridge_profile *entry2 = arg;
 	return (!strcasecmp(entry1->name, entry2->name)) ? CMP_MATCH | CMP_STOP : 0;
 }
 static int bridge_hash_cb(const void *obj, const int flags)
 {
 	const struct bridge_profile *b_profile = obj;
-	return ast_str_hash(b_profile->name);
+	return ast_str_case_hash(b_profile->name);
 }
 static int bridge_mark_delme_cb(void *obj, void *arg, int flag)
 {
@@ -61,21 +61,21 @@
 }
 static int match_bridge_delme_cb(void *obj, void *arg, int flag)
 {
-	struct bridge_profile *entry = obj;
+	const struct bridge_profile *entry = obj;
 	return entry->delme ? CMP_MATCH : 0;
 }
 
 /*! menu container functions */
 static int menu_cmp_cb(void *obj, void *arg, int flags)
 {
-	struct conf_menu *entry1 = obj;
-	struct conf_menu *entry2 = arg;
+	const struct conf_menu *entry1 = obj;
+	const struct conf_menu *entry2 = arg;
 	return (!strcasecmp(entry1->name, entry2->name)) ? CMP_MATCH | CMP_STOP : 0;
 }
 static int menu_hash_cb(const void *obj, const int flags)
 {
 	const struct conf_menu *menu = obj;
-	return ast_str_hash(menu->name);
+	return ast_str_case_hash(menu->name);
 }
 static int menu_mark_delme_cb(void *obj, void *arg, int flag)
 {
@@ -85,7 +85,7 @@
 }
 static int match_menu_delme_cb(void *obj, void *arg, int flag)
 {
-	struct conf_menu *entry = obj;
+	const struct conf_menu *entry = obj;
 	return entry->delme ? CMP_MATCH : 0;
 }
 static void menu_destructor(void *obj)
@@ -102,14 +102,14 @@
 /*! User profile container functions */
 static int user_cmp_cb(void *obj, void *arg, int flags)
 {
-	struct user_profile *entry1 = obj;
-	struct user_profile *entry2 = arg;
+	const struct user_profile *entry1 = obj;
+	const struct user_profile *entry2 = arg;
 	return (!strcasecmp(entry1->name, entry2->name)) ? CMP_MATCH | CMP_STOP : 0;
 }
 static int user_hash_cb(const void *obj, const int flags)
 {
 	const struct user_profile *u_profile = obj;
-	return ast_str_hash(u_profile->name);
+	return ast_str_case_hash(u_profile->name);
 }
 static int user_mark_delme_cb(void *obj, void *arg, int flag)
 {
@@ -119,25 +119,25 @@
 }
 static int match_user_delme_cb(void *obj, void *arg, int flag)
 {
-	struct user_profile *entry = obj;
+	const struct user_profile *entry = obj;
 	return entry->delme ? CMP_MATCH : 0;
 }
 
 /*! Bridge Profile Sounds functions */
 static void bridge_profile_sounds_destroy_cb(void *obj)
 {
+	struct bridge_profile_sounds *sounds = obj;
+	ast_string_field_free_memory(sounds);
+}
+
+static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void)
+{
 	struct bridge_profile_sounds *sounds = ao2_alloc(sizeof(*sounds), bridge_profile_sounds_destroy_cb);
-	ast_string_field_free_memory(sounds);
-}
-
-static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void)
-{
-	struct bridge_profile_sounds *sounds = ao2_alloc(sizeof(*sounds), bridge_profile_sounds_destroy_cb);
 
 	if (!sounds) {
 		return NULL;
 	}
-	if (ast_string_field_init(sounds, 1024)) {
+	if (ast_string_field_init(sounds, 512)) {
 		ao2_ref(sounds, -1);
 		return NULL;
 	}
@@ -361,8 +361,8 @@
 struct func_confbridge_data {
 	struct bridge_profile b_profile;
 	struct user_profile u_profile;
-	int b_usable:1; /*!< Tells if bridge profile is usable or not */
-	int u_usable:1; /*!< Tells if user profile is usable or not */
+	unsigned int b_usable:1; /*!< Tells if bridge profile is usable or not */
+	unsigned int u_usable:1; /*!< Tells if user profile is usable or not */
 };
 static void func_confbridge_destroy_cb(void *data)
 {
@@ -488,7 +488,7 @@
 			continue;
 		} else if (set_bridge_option(var->name, var->value, b_profile)) {
 			ast_log(LOG_WARNING, "Invalid: '%s' at line %d of %s is not supported.\n",
-				var->name, var->lineno, CONF_CONFIG);
+				var->name, var->lineno, CONFBRIDGE_CONFIG);
 		}
 	}
 	ao2_unlock(b_profile);
@@ -526,7 +526,7 @@
 			continue;
 		} else if (set_user_option(var->name, var->value, u_profile)) {
 			ast_log(LOG_WARNING, "Invalid option '%s' at line %d of %s is not supported.\n",
-				var->name, var->lineno, CONF_CONFIG);
+				var->name, var->lineno, CONFBRIDGE_CONFIG);
 		}
 	}
 	ao2_unlock(u_profile);
@@ -539,7 +539,7 @@
 {
 	struct conf_menu_action *menu_action = ast_calloc(1, sizeof(*menu_action));
 
-	if (!(menu_action)) {
+	if (!menu_action) {
 		return -1;
 	}
 	menu_action->id = id;
@@ -702,7 +702,7 @@
 			continue;
 		} else if (add_menu_entry(menu, var->name, var->value)) {
 			ast_log(LOG_WARNING, "Unknown option '%s' at line %d of %s is not supported.\n",
-				var->name, var->lineno, CONF_CONFIG);
+				var->name, var->lineno, CONFBRIDGE_CONFIG);
 		}
 	}
 	ao2_unlock(menu);
@@ -1188,7 +1188,7 @@
 int conf_load_config(int reload)
 {
 	struct ast_flags config_flags = { 0, };
-	struct ast_config *cfg = ast_config_load(CONF_CONFIG, config_flags);
+	struct ast_config *cfg = ast_config_load(CONFBRIDGE_CONFIG, config_flags);
 	const char *type = NULL;
 	char *cat = NULL;
 




More information about the asterisk-commits mailing list