[Freeswitch-branches] [commit] r3688 - freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference

Freeswitch SVN knhor at freeswitch.org
Sun Dec 17 16:00:26 EST 2006


Author: knhor
Date: Sun Dec 17 16:00:24 2006
New Revision: 3688

Modified:
   freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
crazy add null protection for conf api sub functions

Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c	Sun Dec 17 16:00:24 2006
@@ -256,9 +256,9 @@
 static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member);
 static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id);
 static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id);
-static void member_del_relationship(conference_member_t *member, uint32_t id);
+static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id);
 static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member);
-static void conference_del_member(conference_obj_t *conference, conference_member_t *member);
+static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member);
 static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj);
 static void conference_loop_output(conference_member_t *member);
 static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop);
@@ -321,31 +321,35 @@
 /* if other_member has a relationship with member, produce it */
 static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member)
 {
-	conference_relationship_t *rel = NULL, *global = NULL;
+	conference_relationship_t *rel = NULL;
 
-	switch_mutex_lock(member->flag_mutex);
-	switch_mutex_lock(other_member->flag_mutex);
+	if(member != NULL && other_member != NULL) {
+		conference_relationship_t *global = NULL;
 
-	if (member->relationships) {
-		for (rel = member->relationships; rel; rel = rel->next) {
-			if (rel->id == other_member->id) {
-				break;
-			}
+		switch_mutex_lock(member->flag_mutex);
+		switch_mutex_lock(other_member->flag_mutex);
 
-			/* 0 matches everyone.
-			   (We will still test the others brcause a real match carries more clout) */
+		if (member->relationships) {
+			for (rel = member->relationships; rel; rel = rel->next) {
+				if (rel->id == other_member->id) {
+					break;
+				}
 
-			if (rel->id == 0) { 
-				global = rel;
+				/* 0 matches everyone.
+				   (We will still test the others brcause a real match carries more clout) */
+
+				if (rel->id == 0) { 
+					global = rel;
+				}
 			}
 		}
-	}
 
-	switch_mutex_unlock(other_member->flag_mutex);
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_unlock(other_member->flag_mutex);
+		switch_mutex_unlock(member->flag_mutex);
 
-	if (!rel && global) {
-		rel = global;
+		if (!rel && global) {
+			rel = global;
+		}
 	}
 
 	return rel;
@@ -356,14 +360,16 @@
 {
 	conference_member_t *member = NULL;
 
-	for(member = conference->members; member; member = member->next) {
+	if (conference != NULL && id != 0) {
+		for(member = conference->members; member; member = member->next) {
 
-		if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-			continue;
-		}
+			if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+				continue;
+			}
 
-		if (member->id == id) {
-			break;
+			if (member->id == id) {
+				break;
+			}
 		}
 	}
 
@@ -376,10 +382,12 @@
 	conference_member_t *member = NULL;
 	int count = 0;
 
-	for(member = conference->members; member; member = member->next) {
-		if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) {
-			switch_clear_flag_locked(member, MFLAG_RUNNING);
-			count++;
+	if (conference != NULL) {
+		for(member = conference->members; member; member = member->next) {
+			if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) {
+				switch_clear_flag_locked(member, MFLAG_RUNNING);
+				count++;
+			}
 		}
 	}
 
@@ -391,7 +399,7 @@
 {
 	conference_relationship_t *rel = NULL;
 
-	if ((rel = switch_core_alloc(member->pool, sizeof(*rel)))) {
+	if (member != NULL && id != 0 && (rel = switch_core_alloc(member->pool, sizeof(*rel)))) {
 		rel->id = id;
 
 		switch_mutex_lock(member->flag_mutex);
@@ -404,171 +412,191 @@
 }
 
 /* Remove a custom relationship from a member */
-static void member_del_relationship(conference_member_t *member, uint32_t id)
+static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id)
 {
+	switch_status_t status = SWITCH_STATUS_FALSE;
 	conference_relationship_t *rel, *last = NULL;
 
-	switch_mutex_lock(member->flag_mutex);
-	for (rel = member->relationships; rel; rel = rel->next) {
-		if (rel->id == id) {
-			/* we just forget about rel here cos it was allocated by the member's pool 
-			   it will be freed when the member is */
-			if (last) {
-				last->next = rel->next;
-			} else {
-				member->relationships = rel->next;
+	if (member != NULL && id != 0) {
+		switch_mutex_lock(member->flag_mutex);
+		for (rel = member->relationships; rel; rel = rel->next) {
+			if (rel->id == id) {
+				/* we just forget about rel here cos it was allocated by the member's pool 
+				   it will be freed when the member is */
+				status = SWITCH_STATUS_SUCCESS;
+				if (last) {
+					last->next = rel->next;
+				} else {
+					member->relationships = rel->next;
+				}
 			}
+			last = rel;
 		}
-		last = rel;
+		switch_mutex_unlock(member->flag_mutex);
 	}
-	switch_mutex_unlock(member->flag_mutex);
+
+	return status;
 }
 
 /* Gain exclusive access and add the member to the list */
 static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member)
 {
-	switch_event_t *event;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	switch_mutex_lock(conference->mutex);
-	switch_mutex_lock(conference->member_mutex);
-	switch_mutex_lock(member->audio_in_mutex);
-	switch_mutex_lock(member->audio_out_mutex);
-	switch_mutex_lock(member->flag_mutex);
-	member->conference = member->last_conference = conference;
-	member->next = conference->members;
-	member->energy_level = conference->energy_level;
-	conference->members = member;
+	if(conference != NULL && member != NULL) {
+		switch_event_t *event;
 
+		switch_mutex_lock(conference->mutex);
+		switch_mutex_lock(conference->member_mutex);
+		switch_mutex_lock(member->audio_in_mutex);
+		switch_mutex_lock(member->audio_out_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->conference = member->last_conference = conference;
+		member->next = conference->members;
+		member->energy_level = conference->energy_level;
+		conference->members = member;
 
-	if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
-		conference->count++;
-		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
-			switch_event_fire(&event);
-		}
 
+		if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			conference->count++;
+			if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+				switch_event_fire(&event);
+			}
 
-		if (conference->enter_sound) {
-			conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session));
-		}
 
-		if (conference->count == 1 && conference->alone_sound) {
-			conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session));
-		}
+			if (conference->enter_sound) {
+				conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session));
+			}
 
-		if (conference->min && conference->count >= conference->min) {
-			switch_set_flag(conference, CFLAG_ENFORCE_MIN);	
-		}
+			if (conference->count == 1 && conference->alone_sound) {
+				conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session));
+			}
 
-		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-			switch_channel_t *channel = switch_core_session_get_channel(member->session);
-			switch_channel_event_set_data(channel, event);
+			if (conference->min && conference->count >= conference->min) {
+				switch_set_flag(conference, CFLAG_ENFORCE_MIN);	
+			}
 
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member");
-			switch_event_fire(&event);
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
+
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member");
+				switch_event_fire(&event);
+			}
 		}
+		switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_unlock(member->audio_out_mutex);
+		switch_mutex_unlock(member->audio_in_mutex);
+		switch_mutex_unlock(conference->member_mutex);
+		switch_mutex_unlock(conference->mutex);
+
+		status = SWITCH_STATUS_SUCCESS;
 	}
-	switch_mutex_unlock(member->flag_mutex);
-	switch_mutex_unlock(member->audio_out_mutex);
-	switch_mutex_unlock(member->audio_in_mutex);
-	switch_mutex_unlock(conference->member_mutex);
-	switch_mutex_unlock(conference->mutex);
 
-	return SWITCH_STATUS_SUCCESS;
+	return status;
 }
 
 /* Gain exclusive access and remove the member from the list */
-static void conference_del_member(conference_obj_t *conference, conference_member_t *member)
+static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member)
 {
-	conference_member_t *imember, *last = NULL;
-	switch_event_t *event;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	switch_mutex_lock(conference->mutex);
-	switch_mutex_lock(conference->member_mutex);
-	switch_mutex_lock(member->audio_in_mutex);
-	switch_mutex_lock(member->audio_out_mutex);
-	switch_mutex_lock(member->flag_mutex);
+	if(conference != NULL && member != NULL ) {
+		conference_member_t *imember, *last = NULL;
+		switch_event_t *event;
 
-	for (imember = conference->members; imember; imember = imember->next) {
-		if (imember == member ) {
-			if (last) {
-				last->next = imember->next;
-			} else {
-				conference->members = imember->next;
+		switch_mutex_lock(conference->mutex);
+		switch_mutex_lock(conference->member_mutex);
+		switch_mutex_lock(member->audio_in_mutex);
+		switch_mutex_lock(member->audio_out_mutex);
+		switch_mutex_lock(member->flag_mutex);
+
+		for (imember = conference->members; imember; imember = imember->next) {
+			if (imember == member ) {
+				if (last) {
+					last->next = imember->next;
+				} else {
+					conference->members = imember->next;
+				}
+				break;
 			}
-			break;
+			last = imember;
 		}
-		last = imember;
-	}
 
-	/* Close Unused Handles */
-	if (member->fnode) {
-		conference_file_node_t *fnode, *cur;
-		switch_memory_pool_t *pool;
+		/* Close Unused Handles */
+		if (member->fnode) {
+			conference_file_node_t *fnode, *cur;
+			switch_memory_pool_t *pool;
 
-		fnode = member->fnode;
-		while(fnode) {
-			cur = fnode;
-			fnode = fnode->next;
+			fnode = member->fnode;
+			while(fnode) {
+				cur = fnode;
+				fnode = fnode->next;
 
-			if (cur->type == NODE_TYPE_SPEECH) {
-				switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-				switch_core_speech_close(&cur->sh, &flags);
-			} else {
-				switch_core_file_close(&cur->fh);
-			}
+				if (cur->type == NODE_TYPE_SPEECH) {
+					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+					switch_core_speech_close(&cur->sh, &flags);
+				} else {
+					switch_core_file_close(&cur->fh);
+				}
 
-			pool = cur->pool;
-			switch_core_destroy_memory_pool(&pool);
+				pool = cur->pool;
+				switch_core_destroy_memory_pool(&pool);
+			}
 		}
-	}
 
-	member->conference = NULL;
+		member->conference = NULL;
 
-	if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
-		conference->count--;
-		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
-			switch_event_fire(&event);
-		}
+		if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			conference->count--;
+			if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+				switch_event_fire(&event);
+			}
 
-		if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min) 
-			|| (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0) ) {
-				switch_set_flag(conference, CFLAG_DESTRUCT);
-		} else { 
-			if (conference->exit_sound) {
-				conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session));
+			if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min) 
+				|| (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0) ) {
+					switch_set_flag(conference, CFLAG_DESTRUCT);
+			} else { 
+				if (conference->exit_sound) {
+					conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session));
+				}
+				if (conference->count == 1 && conference->alone_sound) {
+					conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session));
+				} 
 			}
-			if (conference->count == 1 && conference->alone_sound) {
-				conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session));
-			} 
-		}
 
-		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-			switch_channel_t *channel = switch_core_session_get_channel(member->session);
-			switch_channel_event_set_data(channel, event);
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
 
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member");
-			switch_event_fire(&event);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member");
+				switch_event_fire(&event);
+			}
 		}
+		switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_unlock(member->audio_out_mutex);
+		switch_mutex_unlock(member->audio_in_mutex);
+		switch_mutex_unlock(conference->member_mutex);
+		switch_mutex_unlock(conference->mutex);
+
+		status = SWITCH_STATUS_SUCCESS;
 	}
-	switch_mutex_unlock(member->flag_mutex);
-	switch_mutex_unlock(member->audio_out_mutex);
-	switch_mutex_unlock(member->audio_in_mutex);
-	switch_mutex_unlock(conference->member_mutex);
-	switch_mutex_unlock(conference->mutex);
+
+	return status;
 }
 
 /* Main monitor thread (1 per distinct conference room) */
@@ -855,247 +883,269 @@
 
 static void conference_loop_fn_mute_toggle(conference_member_t *member, void *data)
 {
-	if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-		conf_api_sub_mute(member, NULL, NULL);
-	} else {
-		conf_api_sub_unmute(member, NULL, NULL);
+	if (member != NULL) {
+		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+			conf_api_sub_mute(member, NULL, NULL);
+		} else {
+			conf_api_sub_unmute(member, NULL, NULL);
+		}
 	}
 }
 
 static void conference_loop_fn_deafmute_toggle(conference_member_t *member, void *data)
 {
-	if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-		conf_api_sub_mute(member, NULL, NULL);
-		conf_api_sub_deaf(member, NULL, NULL);
-	} else {
-		conf_api_sub_unmute(member, NULL, NULL);
-		conf_api_sub_undeaf(member, NULL, NULL);
+	if (member != NULL) {
+		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+			conf_api_sub_mute(member, NULL, NULL);
+			conf_api_sub_deaf(member, NULL, NULL);
+		} else {
+			conf_api_sub_unmute(member, NULL, NULL);
+			conf_api_sub_undeaf(member, NULL, NULL);
+		}
 	}
 }
 
 static void conference_loop_fn_energy_up(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member != NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->energy_level += 100;
-	if (member->energy_level > 1200) {
-		member->energy_level = 1200;
-	}
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->energy_level += 100;
+		if (member->energy_level > 1200) {
+			member->energy_level = 1200;
+		}
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_energy_equ_conf(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->energy_level = member->conference->energy_level;
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->energy_level = member->conference->energy_level;
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 					
 static void conference_loop_fn_energy_dn(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->energy_level -= 100;
-	if (member->energy_level < 0) {
-		member->energy_level = 0;
-	}
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->energy_level -= 100;
+		if (member->energy_level < 0) {
+			member->energy_level = 0;
+		}
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_volume_talk_up(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->volume_out_level++;
-	switch_normalize_volume(member->volume_out_level);
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->volume_out_level++;
+		switch_normalize_volume(member->volume_out_level);
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_volume_talk_zero(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->volume_out_level = 0;
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->volume_out_level = 0;
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_volume_talk_dn(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->volume_out_level--;
-	switch_normalize_volume(member->volume_out_level);
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->volume_out_level--;
+		switch_normalize_volume(member->volume_out_level);
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_volume_listen_up(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->volume_in_level++;
-	switch_normalize_volume(member->volume_in_level);
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->volume_in_level++;
+		switch_normalize_volume(member->volume_in_level);
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_volume_listen_zero(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->volume_in_level = 0;
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->volume_in_level = 0;
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
 static void conference_loop_fn_volume_listen_dn(conference_member_t *member, void *data)
 {
-	char msg[512];
-	switch_event_t *event;
+	if (member!= NULL) {
+		char msg[512];
+		switch_event_t *event;
 
-	switch_mutex_lock(member->flag_mutex);
-	member->volume_in_level--;
-	switch_normalize_volume(member->volume_in_level);
-	switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		member->volume_in_level--;
+		switch_normalize_volume(member->volume_in_level);
+		switch_mutex_unlock(member->flag_mutex);
 
-	snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
-	conference_member_say(member, msg, 0);
+		snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+		conference_member_say(member, msg, 0);
 
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
 
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
-		switch_event_fire(&event);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
+			switch_event_fire(&event);
+		}
 	}
 }
 
@@ -1113,7 +1163,7 @@
 
 static void conference_loop_fn_menu(conference_member_t *member, void *data)
 {
-	if (data != NULL) {
+	if (member != NULL && data != NULL) {
 		caller_control_menu_ctx_t *menu_ctx = (caller_control_menu_ctx_t *)data;
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "conference_loop_fn_menu handler '%s'\n",menu_ctx->name);
@@ -1289,14 +1339,16 @@
 /* launch an input thread for the call leg */
 static void launch_conference_loop_input(conference_member_t *member, switch_memory_pool_t *pool)
 {
-	switch_thread_t *thread;
-	switch_threadattr_t *thd_attr = NULL;
+	if (member != NULL) {
+		switch_thread_t *thread;
+		switch_threadattr_t *thd_attr = NULL;
 
-	switch_threadattr_create(&thd_attr, pool);
-	switch_threadattr_detach_set(thd_attr, 1);
-	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-	switch_set_flag_locked(member, MFLAG_ITHREAD);
-	switch_thread_create(&thread, thd_attr, conference_loop_input, member, pool);
+		switch_threadattr_create(&thd_attr, pool);
+		switch_threadattr_detach_set(thd_attr, 1);
+		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+		switch_set_flag_locked(member, MFLAG_ITHREAD);
+		switch_thread_create(&thread, thd_attr, conference_loop_input, member, pool);
+	}
 }
 
 static caller_control_fn_table_t ccfntbl[] = {
@@ -1676,136 +1728,146 @@
 /* Make files stop playing in a conference either the current one or all of them */
 static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop)
 {
-	conference_file_node_t *nptr;
 	uint32_t count = 0;
 
-	switch_mutex_lock(conference->mutex);
+	if (conference != NULL) {
+		conference_file_node_t *nptr;
 
-	if (stop == FILE_STOP_ALL) {
-		for (nptr = conference->fnode; nptr; nptr = nptr->next) {
-			nptr->done++;
-			count++;
+		switch_mutex_lock(conference->mutex);
+
+		if (stop == FILE_STOP_ALL) {
+			for (nptr = conference->fnode; nptr; nptr = nptr->next) {
+				nptr->done++;
+				count++;
+			}
+		} else {
+			if (conference->fnode) {
+				conference->fnode->done++;
+				count++;
+			}
 		}
-	} else {
-		if (conference->fnode) {
-			conference->fnode->done++;
-			count++;
-		}
+
+		switch_mutex_unlock(conference->mutex);
 	}
 
-	switch_mutex_unlock(conference->mutex);
-
 	return count;
 }
 
 /* stop playing a file for the member of the conference */
 static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop)
 {
-	conference_file_node_t *nptr;
 	uint32_t count = 0;
 
-	switch_mutex_lock(member->flag_mutex);
+	if (member != NULL) {
+		conference_file_node_t *nptr;
 
-	if (stop == FILE_STOP_ALL) {
-		for (nptr = member->fnode; nptr; nptr = nptr->next) {
-			nptr->done++;
-			count++;
+		switch_mutex_lock(member->flag_mutex);
+
+		if (stop == FILE_STOP_ALL) {
+			for (nptr = member->fnode; nptr; nptr = nptr->next) {
+				nptr->done++;
+				count++;
+			}
+		} else {
+			if (member->fnode) {
+				member->fnode->done++;
+				count++;
+			}
 		}
-	} else {
-		if (member->fnode) {
-			member->fnode->done++;
-			count++;
-		}
+
+		switch_mutex_unlock(member->flag_mutex);
 	}
 
-	switch_mutex_unlock(member->flag_mutex);
-
 	return count;
 }
 
 /* Play a file in the conference room */
 static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel)
 {
-	conference_file_node_t *fnode, *nptr;
-	switch_memory_pool_t *pool;
-	uint32_t count;
-	char *expanded = NULL;
-	uint8_t frexp = 0;
-	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	switch_mutex_lock(conference->mutex);
-	switch_mutex_lock(conference->member_mutex);
-	count = conference->count;
-	switch_mutex_unlock(conference->member_mutex);
-	switch_mutex_unlock(conference->mutex);	
+	if (conference != NULL && channel != NULL) {
+		conference_file_node_t *fnode, *nptr;
+		switch_memory_pool_t *pool;
+		uint32_t count;
+		char *expanded = NULL;
+		uint8_t frexp = 0;
 
-	if (!count) {
-		return SWITCH_STATUS_FALSE;
-	}
+		switch_mutex_lock(conference->mutex);
+		switch_mutex_lock(conference->member_mutex);
+		count = conference->count;
+		switch_mutex_unlock(conference->member_mutex);
+		switch_mutex_unlock(conference->mutex);	
 
-	if (channel) {
-		if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
-			file = expanded;
-			frexp = 1;
+		if (!count) {
+			status = SWITCH_STATUS_FALSE;
+			goto done;
 		}
-	}
 
+		if (channel) {
+			if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
+				file = expanded;
+				frexp = 1;
+			}
+		}
 
+
 #ifdef WIN32
-	if (*(file +1) != ':' && *file != '/') {
+		if (*(file +1) != ':' && *file != '/') {
 #else
-	if (*file != '/') {
+		if (*file != '/') {
 #endif
-		status = conference_say(conference, file, leadin);
-		goto done;
-	}
+			status = conference_say(conference, file, leadin);
+			goto done;
+		}
 
-	/* Setup a memory pool to use. */
-	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-		status = SWITCH_STATUS_MEMERR;
-		goto done;
-	}
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			status = SWITCH_STATUS_MEMERR;
+			goto done;
+		}
 
-	/* Create a node object*/
-	if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-		switch_core_destroy_memory_pool(&pool);
-		status = SWITCH_STATUS_MEMERR;
-		goto done;
-	}
+		/* Create a node object*/
+		if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+			switch_core_destroy_memory_pool(&pool);
+			status = SWITCH_STATUS_MEMERR;
+			goto done;
+		}
 
-	fnode->type = NODE_TYPE_FILE;
-	fnode->leadin = leadin;
+		fnode->type = NODE_TYPE_FILE;
+		fnode->leadin = leadin;
 
-	/* Open the file */
-	if (switch_core_file_open(&fnode->fh,
-							  file,
-							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-							  pool) != SWITCH_STATUS_SUCCESS) {
-		switch_core_destroy_memory_pool(&pool);
-		status = SWITCH_STATUS_NOTFOUND;
-		goto done;
-	}
+		/* Open the file */
+		if (switch_core_file_open(&fnode->fh,
+								  file,
+								  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+								  pool) != SWITCH_STATUS_SUCCESS) {
+			switch_core_destroy_memory_pool(&pool);
+			status = SWITCH_STATUS_NOTFOUND;
+			goto done;
+		}
 
-	fnode->pool = pool;
+		fnode->pool = pool;
 
-	/* Queue the node */
-	switch_mutex_lock(conference->mutex);
-	for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
+		/* Queue the node */
+		switch_mutex_lock(conference->mutex);
+		for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
 
-	if (nptr) {
-		nptr->next = fnode;
-	} else {
-		conference->fnode = fnode;
-	}
-	switch_mutex_unlock(conference->mutex);
+		if (nptr) {
+			nptr->next = fnode;
+		} else {
+			conference->fnode = fnode;
+		}
+		switch_mutex_unlock(conference->mutex);
 
-    done:
+	    done:
 
-    if (frexp) {
-        switch_safe_free(expanded);
-    }
+	    if (frexp) {
+		switch_safe_free(expanded);
+	    }
+	}
 
 	return status;
 }
@@ -1813,184 +1875,202 @@
 /* Play a file in the conference room to a member */
 static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin)
 {
-	conference_file_node_t *fnode, *nptr;
-	switch_memory_pool_t *pool;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	if (*file != '/') {
-		return conference_member_say(member, file, leadin);
-	}
+	if (member != NULL && file != NULL) {
+		conference_file_node_t *fnode, *nptr;
+		switch_memory_pool_t *pool;
 
-	/* Setup a memory pool to use. */
-	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-		return SWITCH_STATUS_MEMERR;
-	}
+		if (*file != '/') {
+			return conference_member_say(member, file, leadin);
+		}
 
-	/* Create a node object*/
-	if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-		switch_core_destroy_memory_pool(&pool);
-		return SWITCH_STATUS_MEMERR;
-	}
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			return SWITCH_STATUS_MEMERR;
+		}
 
-	fnode->type = NODE_TYPE_FILE;
-	fnode->leadin = leadin;
+		/* Create a node object*/
+		if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+			switch_core_destroy_memory_pool(&pool);
+			return SWITCH_STATUS_MEMERR;
+		}
 
-	/* Open the file */
-	if (switch_core_file_open(&fnode->fh,
-							  file,
-							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-							  pool) != SWITCH_STATUS_SUCCESS) {
-		switch_core_destroy_memory_pool(&pool);
-		return SWITCH_STATUS_NOTFOUND;
-	}
+		fnode->type = NODE_TYPE_FILE;
+		fnode->leadin = leadin;
 
-	fnode->pool = pool;
+		/* Open the file */
+		if (switch_core_file_open(&fnode->fh,
+								  file,
+								  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+								  pool) != SWITCH_STATUS_SUCCESS) {
+			switch_core_destroy_memory_pool(&pool);
+			return SWITCH_STATUS_NOTFOUND;
+		}
 
-	/* Queue the node */
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n",file);
-	switch_mutex_lock(member->flag_mutex);
-	for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
+		fnode->pool = pool;
 
-	if (nptr) {
-		nptr->next = fnode;
-	} else {
-		member->fnode = fnode;
+		/* Queue the node */
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n",file);
+		switch_mutex_lock(member->flag_mutex);
+		for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
+
+		if (nptr) {
+			nptr->next = fnode;
+		} else {
+			member->fnode = fnode;
+		}
+		switch_mutex_unlock(member->flag_mutex);
+
+		status = SWITCH_STATUS_SUCCESS;
 	}
-	switch_mutex_unlock(member->flag_mutex);
 
-	return SWITCH_STATUS_SUCCESS;
+	return status;
 }
 
 /* Say some thing with TTS in the conference room */
 static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin)
 {
-	conference_obj_t *conference = (member != NULL ? member->conference : NULL);
-	conference_file_node_t *fnode, *nptr;
-	switch_memory_pool_t *pool;
-	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	if (conference == NULL) {
-		return SWITCH_STATUS_FALSE;
-	}
+	if (member != NULL && !switch_strlen_zero(text)) {
+		conference_obj_t *conference = (member != NULL ? member->conference : NULL);
+		conference_file_node_t *fnode, *nptr;
+		switch_memory_pool_t *pool;
+		switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
 
-	if (!(conference->tts_engine && conference->tts_voice)) {
-		return SWITCH_STATUS_SUCCESS;
-	}
+		if (conference == NULL) {
+			return SWITCH_STATUS_FALSE;
+		}
 
-	/* Setup a memory pool to use. */
-	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-		return SWITCH_STATUS_MEMERR;
-	}
+		if (!(conference->tts_engine && conference->tts_voice)) {
+			return SWITCH_STATUS_SUCCESS;
+		}
 
-	/* Create a node object*/
-	if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-		switch_core_destroy_memory_pool(&pool);
-		return SWITCH_STATUS_MEMERR;
-	}
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			return SWITCH_STATUS_MEMERR;
+		}
 
-	fnode->type = NODE_TYPE_SPEECH;
-	fnode->leadin = leadin;
+		/* Create a node object*/
+		if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+			switch_core_destroy_memory_pool(&pool);
+			return SWITCH_STATUS_MEMERR;
+		}
 
-	memset(&fnode->sh, 0, sizeof(fnode->sh));
-	if (switch_core_speech_open(&fnode->sh,
-								conference->tts_engine,
-								conference->tts_voice,
-								conference->rate,
-								&flags,
-								conference->pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
-		return SWITCH_STATUS_FALSE;
-	}
+		fnode->type = NODE_TYPE_SPEECH;
+		fnode->leadin = leadin;
 
-	fnode->pool = pool;
+		memset(&fnode->sh, 0, sizeof(fnode->sh));
+		if (switch_core_speech_open(&fnode->sh,
+									conference->tts_engine,
+									conference->tts_voice,
+									conference->rate,
+									&flags,
+									conference->pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
+			return SWITCH_STATUS_FALSE;
+		}
 
-	/* Queue the node */
-	switch_mutex_lock(member->flag_mutex);
-	for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
+		fnode->pool = pool;
 
-	if (nptr) {
-		nptr->next = fnode;
-	} else {
-		member->fnode = fnode;
-	}
+		/* Queue the node */
+		switch_mutex_lock(member->flag_mutex);
+		for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
 
-	/* Begin Generation */
-	switch_sleep(200000);
-	switch_core_speech_feed_tts(&fnode->sh, text, &flags);
-	switch_mutex_unlock(member->flag_mutex);
+		if (nptr) {
+			nptr->next = fnode;
+		} else {
+			member->fnode = fnode;
+		}
 
-	return SWITCH_STATUS_SUCCESS;
+		/* Begin Generation */
+		switch_sleep(200000);
+		switch_core_speech_feed_tts(&fnode->sh, text, &flags);
+		switch_mutex_unlock(member->flag_mutex);
+
+		status = SWITCH_STATUS_SUCCESS;
+	}
+
+	return status;
 }
 
 /* Say some thing with TTS in the conference room */
 static switch_status_t conference_say(conference_obj_t *conference, char *text, uint32_t leadin)
 {
-	conference_file_node_t *fnode, *nptr;
-	switch_memory_pool_t *pool;
-	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-	uint32_t count;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	switch_mutex_lock(conference->mutex);
-	switch_mutex_lock(conference->member_mutex);
-	count = conference->count;
-	if (!(conference->tts_engine && conference->tts_voice)) {
-		count = 0;
-	}
-	switch_mutex_unlock(conference->member_mutex);
-	switch_mutex_unlock(conference->mutex);	
+	if (conference != NULL && !switch_strlen_zero(text)) {
+		conference_file_node_t *fnode, *nptr;
+		switch_memory_pool_t *pool;
+		switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+		uint32_t count;
 
-	if (!count) {
-		return SWITCH_STATUS_FALSE;
-	}
+		switch_mutex_lock(conference->mutex);
+		switch_mutex_lock(conference->member_mutex);
+		count = conference->count;
+		if (!(conference->tts_engine && conference->tts_voice)) {
+			count = 0;
+		}
+		switch_mutex_unlock(conference->member_mutex);
+		switch_mutex_unlock(conference->mutex);	
 
-	/* Setup a memory pool to use. */
-	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-		return SWITCH_STATUS_MEMERR;
-	}
+		if (!count) {
+			return SWITCH_STATUS_FALSE;
+		}
 
-	/* Create a node object*/
-	if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-		switch_core_destroy_memory_pool(&pool);
-		return SWITCH_STATUS_MEMERR;
-	}
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			return SWITCH_STATUS_MEMERR;
+		}
 
-	fnode->type = NODE_TYPE_SPEECH;
-	fnode->leadin = leadin;
+		/* Create a node object*/
+		if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+			switch_core_destroy_memory_pool(&pool);
+			return SWITCH_STATUS_MEMERR;
+		}
 
-	memset(&fnode->sh, 0, sizeof(fnode->sh));
-	if (switch_core_speech_open(&fnode->sh,
-								conference->tts_engine,
-								conference->tts_voice,
-								conference->rate,
-								&flags,
-								conference->pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
-		return SWITCH_STATUS_FALSE;
-	}
+		fnode->type = NODE_TYPE_SPEECH;
+		fnode->leadin = leadin;
 
-	fnode->pool = pool;
+		memset(&fnode->sh, 0, sizeof(fnode->sh));
+		if (switch_core_speech_open(&fnode->sh,
+									conference->tts_engine,
+									conference->tts_voice,
+									conference->rate,
+									&flags,
+									conference->pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
+			return SWITCH_STATUS_FALSE;
+		}
 
-	/* Queue the node */
-	switch_mutex_lock(conference->mutex);
-	for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
+		fnode->pool = pool;
 
-	if (nptr) {
-		nptr->next = fnode;
-	} else {
-		conference->fnode = fnode;
-	}
+		/* Queue the node */
+		switch_mutex_lock(conference->mutex);
+		for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
 
-	/* Begin Generation */
-	switch_sleep(200000);
-	switch_core_speech_feed_tts(&fnode->sh, text, &flags);
-	switch_mutex_unlock(conference->mutex);
+		if (nptr) {
+			nptr->next = fnode;
+		} else {
+			conference->fnode = fnode;
+		}
 
-	return SWITCH_STATUS_SUCCESS;
+		/* Begin Generation */
+		switch_sleep(200000);
+		switch_core_speech_feed_tts(&fnode->sh, text, &flags);
+		switch_mutex_unlock(conference->mutex);
+
+		status = SWITCH_STATUS_SUCCESS;
+	}
+
+	return status;
 }
 
 /* execute a callback for every member of the conference */
@@ -2010,56 +2090,58 @@
 
 static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim)
 {
-	conference_member_t *member = NULL;
+	if (conference != NULL && stream != NULL && delim != NULL) {
+		conference_member_t *member = NULL;
 
-	switch_mutex_lock(conference->member_mutex);
+		switch_mutex_lock(conference->member_mutex);
 
-	for (member = conference->members; member; member = member->next) {
-		switch_channel_t *channel;
-		switch_caller_profile_t *profile;
-		char *uuid;
-		char *name;
-		uint32_t count = 0;
+		for (member = conference->members; member; member = member->next) {
+			switch_channel_t *channel;
+			switch_caller_profile_t *profile;
+			char *uuid;
+			char *name;
+			uint32_t count = 0;
 
-		if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-			continue;
-		}
+			if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+				continue;
+			}
 
-		uuid = switch_core_session_get_uuid(member->session);
-		channel = switch_core_session_get_channel(member->session);
-		profile = switch_channel_get_caller_profile(channel);
-		name = switch_channel_get_name(channel);
+			uuid = switch_core_session_get_uuid(member->session);
+			channel = switch_core_session_get_channel(member->session);
+			profile = switch_channel_get_caller_profile(channel);
+			name = switch_channel_get_name(channel);
 
 
-		stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s", 
-							   member->id,delim,
-							   name,delim,
-							   uuid,delim,
-							   profile->caller_id_name,delim,
-							   profile->caller_id_number, delim);
+			stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s", 
+								   member->id,delim,
+								   name,delim,
+								   uuid,delim,
+								   profile->caller_id_name,delim,
+								   profile->caller_id_number, delim);
 
-		if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
-			stream->write_function(stream, "hear");
-			count++;
-		}
+			if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
+				stream->write_function(stream, "hear");
+				count++;
+			}
 
-		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-			stream->write_function(stream, "%s%s", count ? "|" : "", "speak");
-			count++;
-		}
+			if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+				stream->write_function(stream, "%s%s", count ? "|" : "", "speak");
+				count++;
+			}
 
-		stream->write_function(stream, "%s%d%s%d%s%d\n",
-							delim,
-							member->volume_in_level, delim,
-							member->volume_out_level, delim,
-							member->energy_level);
+			stream->write_function(stream, "%s%d%s%d%s%d\n",
+								delim,
+								member->volume_in_level, delim,
+								member->volume_out_level, delim,
+								member->energy_level);
+		}
+		switch_mutex_unlock(conference->member_mutex);
 	}
-	switch_mutex_unlock(conference->member_mutex);
 }
 
 static int conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2086,15 +2168,15 @@
 			switch_event_fire(&event);
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2121,15 +2203,15 @@
 			switch_event_fire(&event);
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2148,15 +2230,15 @@
 			switch_event_fire(&event);
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2175,15 +2257,15 @@
 			switch_event_fire(&event);
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_kick(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2207,15 +2289,15 @@
 			switch_event_fire(&event);
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_energy(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2244,15 +2326,15 @@
 			}
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_volume_in(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2281,15 +2363,15 @@
 			}
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_volume_out(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
-	int err = 0;
+	int syntax_err = 0;
 
 	if (member != NULL) {
 		switch_event_t *event;
@@ -2319,274 +2401,292 @@
 			}
 		}
 	} else {
-		err = 1;
+		syntax_err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	switch_hash_index_t *hi;
-	void *val;
-	char *d = ";";
+	int syntax_err = 1;
 
-	if (argv[1]) {
-		if (argv[2] && !strcasecmp(argv[1], "delim")) {
-			d = argv[2];
+//	if (conference != NULL && stream != NULL) {
+	{
+		switch_hash_index_t *hi;
+		void *val;
+		char *d = ";";
 
-			if (*d == '"') {
-				if (++d) {
-					char *p;
-					if ((p = strchr(d, '"'))) {
-						*p = '\0';
+		if (argv[1]) {
+			if (argv[2] && !strcasecmp(argv[1], "delim")) {
+				d = argv[2];
+
+				if (*d == '"') {
+					if (++d) {
+						char *p;
+						if ((p = strchr(d, '"'))) {
+							*p = '\0';
+						}
+					} else {
+						d = ";";
 					}
-				} else {
-					d = ";";
 				}
 			}
 		}
-	}
 
-	for (hi = switch_hash_first(globals.conference_pool, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
-		switch_hash_this(hi, NULL, NULL, &val);
-		conference = (conference_obj_t *) val;
+		for (hi = switch_hash_first(globals.conference_pool, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
+			switch_hash_this(hi, NULL, NULL, &val);
+			conference = (conference_obj_t *) val;
 
-		stream->write_function(stream, "Conference %s (%u members)\n", conference->name, conference->count);
-		conference_list(conference, stream, d);
+			stream->write_function(stream, "Conference %s (%u members)\n", conference->name, conference->count);
+			conference_list(conference, stream, d);
+		}
+
+		syntax_err = 0;
 	}
 
-	return 0;
+	return syntax_err;
 }
 
 static int conf_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	switch_event_t *event;
+	int syntax_err = 1;
 
-	if (argc == 3) {
-		if (conference_play_file(conference, argv[2], 0, NULL) == SWITCH_STATUS_SUCCESS) {
-			stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
-			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[2]);
-				switch_event_fire(&event);
-			}
-		} else {
-			stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
-		}
-	} else if (argc == 4) {
-		uint32_t id = atoi(argv[3]);
-		conference_member_t *member;
+	if (conference != NULL && stream != NULL) {
+		switch_event_t *event;
 
-		if ((member = conference_member_get(conference, id))) {
-			if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
-				stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
+		if (argc == 3) {
+			if (conference_play_file(conference, argv[2], 0, NULL) == SWITCH_STATUS_SUCCESS) {
+				stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
 				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[2]);
 					switch_event_fire(&event);
 				}
 			} else {
 				stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
 			}
-		} else {
-			stream->write_function(stream, "Member: %u not found.\n", id);
+			syntax_err = 0;
+		} else if (argc == 4) {
+			uint32_t id = atoi(argv[3]);
+			conference_member_t *member;
+
+			if ((member = conference_member_get(conference, id))) {
+				if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
+					stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
+					if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[2]);
+						switch_event_fire(&event);
+					}
+				} else {
+					stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+				}
+				syntax_err = 0;
+			} else {
+				stream->write_function(stream, "Member: %u not found.\n", id);
+			}
 		}
 	}
 
-	return 0;
+	return syntax_err;
 }
 
 static int conf_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, char *text)
 {
-	int err = 0;
+	int syntax_err = 1;
 
-	if (text != NULL && !switch_strlen_zero(text)) {
-		if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
-			switch_event_t *event;
+	if (conference != NULL && stream != NULL) {
+		if (!switch_strlen_zero(text)) {
+			if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
+				switch_event_t *event;
 
-			stream->write_function(stream, "(say) OK\n");
-			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", text);
-				switch_event_fire(&event);
+				stream->write_function(stream, "(say) OK\n");
+				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", text);
+					switch_event_fire(&event);
+				}
+			} else {
+				stream->write_function(stream, "(say) Error!");
 			}
+			syntax_err = 0;
 		} else {
-			stream->write_function(stream, "(say) Error!");
+			stream->write_function(stream, "(say) Error! No text.");
 		}
-	} else {
-		stream->write_function(stream, "(say) Error! No text.");
-		err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_saymember(conference_obj_t *conference, switch_stream_handle_t *stream, char *text)
 {
-	int err = 0;
+	int syntax_err = 1;
 
-	if (text != NULL && !switch_strlen_zero(text)) {
-		char *name = strdup(text);
-		uint32_t id = 0;
-		conference_member_t *member;
+	if (conference != NULL) {
+		if (!switch_strlen_zero(text)) {
+			char *name = strdup(text);
+			uint32_t id = 0;
+			conference_member_t *member;
 
-		if (name != NULL && *name) {
-			text = strchr(name, ' ');
-			*name = '\0';
-			id = atoi(name);
-			free(name);
-		} else {
-			err = 1;
-		}
+			if (!switch_strlen_zero(name)) {
+				text = strchr(name, ' ');
+				*name = '\0';
+				id = atoi(name);
+				free(name);
+			}
 
-		if (id != 0 && (member = conference_member_get(conference, id))) {
-			if (text && conference_member_say(member, text, 0) == SWITCH_STATUS_SUCCESS) {
-				switch_event_t *event;
+			if (id != 0 && (member = conference_member_get(conference, id))) {
+				if (text && conference_member_say(member, text, 0) == SWITCH_STATUS_SUCCESS) {
+					switch_event_t *event;
 
-				stream->write_function(stream, "(saymember) OK\n");
-				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text-member");
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", text);
-					switch_event_fire(&event);
+					stream->write_function(stream, "(saymember) OK\n");
+					if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text-member");
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", text);
+						switch_event_fire(&event);
+					}
+				} else {
+					stream->write_function(stream, "(saymember) Error!");
 				}
+				syntax_err = 0;
 			} else {
-				stream->write_function(stream, "(saymember) Error!");
+				stream->write_function(stream, "(saymember) Unknown Member %u!", id);
 			}
-		} else {
-			stream->write_function(stream, "(saymember) Unknown Member %u!", id);
-			err = 1;
 		}
-	} else {
-		err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_stop(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	uint8_t current = 0, all = 0;
-	int err = 0;
+	int syntax_err = 1;
 
-	if (argc > 2) {
-		current = strcasecmp(argv[2], "current") ? 0 : 1;
-		all = strcasecmp(argv[2], "all") ? 0 : 1;
-	}
+	if (conference != NULL) {
+		uint8_t current = 0, all = 0;
 
-	if (current || all) {
-		if (argc == 4) {
-			uint32_t id = atoi(argv[3]);
-			conference_member_t *member;
+		if (argc > 2) {
+			current = strcasecmp(argv[2], "current") ? 0 : 1;
+			all = strcasecmp(argv[2], "all") ? 0 : 1;
+		}
 
-			if ((member = conference_member_get(conference, id))) {
-				uint32_t stopped = conference_member_stop_file(member, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
-				stream->write_function(stream, "Stopped %u files.\n", stopped);
+		if (current || all) {
+			if (argc == 4) {
+				uint32_t id = atoi(argv[3]);
+				conference_member_t *member;
+
+				if ((member = conference_member_get(conference, id))) {
+					uint32_t stopped = conference_member_stop_file(member, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+					stream->write_function(stream, "Stopped %u files.\n", stopped);
+				} else {
+					stream->write_function(stream, "Member: %u not found.\n", id);
+				}
+				syntax_err = 0;
 			} else {
-				stream->write_function(stream, "Member: %u not found.\n", id);
+				uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+				stream->write_function(stream, "Stopped %u files.\n", stopped);
+				syntax_err = 0;
 			}
-		} else {
-			uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
-			stream->write_function(stream, "Stopped %u files.\n", stopped);
 		}
-	} else {
-		err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	int err = 0;
+	int syntax_err = 1;
 
-	if (argc > 4) {
-		uint8_t nospeak = 0, nohear = 0, clear = 0;
-		nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
-		nohear = strstr(argv[4], "nohear") ? 1 : 0;
+	if (conference != NULL && stream != NULL) {
+		if (argc > 4) {
+			uint8_t nospeak = 0, nohear = 0, clear = 0;
+			nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
+			nohear = strstr(argv[4], "nohear") ? 1 : 0;
 
-		if (!strcasecmp(argv[4], "clear")) {
-			clear = 1;
-		}
+			if (!strcasecmp(argv[4], "clear")) {
+				clear = 1;
+			}
 
-		if (!(clear || nospeak || nohear)) { 
-			err = 1;
-			goto done;
-		}
-
-		if (clear) {
-			conference_member_t *member = NULL;
-			uint32_t id = atoi(argv[2]);
-			uint32_t oid = atoi(argv[3]);
-
-			switch_mutex_lock(conference->mutex);
-			switch_mutex_lock(conference->member_mutex);
-			if ((member = conference_member_get(conference, id))) {
-				member_del_relationship(member, oid);
-				stream->write_function(stream, "relationship %u->%u cleared.", id, oid);
-			} else {
-				stream->write_function(stream, "relationship %u->%u not found", id, oid);
+			if (!(clear || nospeak || nohear)) { 
+				syntax_err = 1;
+				goto done;
 			}
-			switch_mutex_unlock(conference->member_mutex);
-			switch_mutex_unlock(conference->mutex);
-		} else if (nospeak || nohear) {
-			conference_member_t *member = NULL, *other_member = NULL;
-			uint32_t id = atoi(argv[2]);
-			uint32_t oid = atoi(argv[3]);
+			syntax_err = 0;
 
-			switch_mutex_lock(conference->mutex);
-			switch_mutex_lock(conference->member_mutex);
-			if ((member = conference_member_get(conference, id)) && (other_member = conference_member_get(conference, oid))) {
-				conference_relationship_t *rel = NULL;
-				if ((rel = member_get_relationship(member, other_member))) {
-					rel->flags = 0;
+			if (clear) {
+				conference_member_t *member = NULL;
+				uint32_t id = atoi(argv[2]);
+				uint32_t oid = atoi(argv[3]);
+
+				switch_mutex_lock(conference->mutex);
+				switch_mutex_lock(conference->member_mutex);
+				if ((member = conference_member_get(conference, id))) {
+					member_del_relationship(member, oid);
+					stream->write_function(stream, "relationship %u->%u cleared.", id, oid);
 				} else {
-					rel = member_add_relationship(member, oid);
+					stream->write_function(stream, "relationship %u->%u not found", id, oid);
 				}
+				switch_mutex_unlock(conference->member_mutex);
+				switch_mutex_unlock(conference->mutex);
+			} else if (nospeak || nohear) {
+				conference_member_t *member = NULL, *other_member = NULL;
+				uint32_t id = atoi(argv[2]);
+				uint32_t oid = atoi(argv[3]);
 
-				if (rel) {
-					switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
-					if (nospeak) {
-						switch_clear_flag(rel, RFLAG_CAN_SPEAK);
+				switch_mutex_lock(conference->mutex);
+				switch_mutex_lock(conference->member_mutex);
+				if ((member = conference_member_get(conference, id)) && (other_member = conference_member_get(conference, oid))) {
+					conference_relationship_t *rel = NULL;
+					if ((rel = member_get_relationship(member, other_member))) {
+						rel->flags = 0;
+					} else {
+						rel = member_add_relationship(member, oid);
 					}
-					if (nohear) {
-						switch_clear_flag(rel, RFLAG_CAN_HEAR);
+
+					if (rel) {
+						switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
+						if (nospeak) {
+							switch_clear_flag(rel, RFLAG_CAN_SPEAK);
+						}
+						if (nohear) {
+							switch_clear_flag(rel, RFLAG_CAN_HEAR);
+						}
+						stream->write_function(stream, "ok %u->%u set\n", id, oid);
+					} else {
+						stream->write_function(stream, "error!\n");
 					}
-					stream->write_function(stream, "ok %u->%u set\n", id, oid);
 				} else {
-					stream->write_function(stream, "error!\n");
+					stream->write_function(stream, "relationship %u->%u not found", id, oid);
 				}
-			} else {
-				stream->write_function(stream, "relationship %u->%u not found", id, oid);
+				switch_mutex_unlock(conference->member_mutex);
+				switch_mutex_unlock(conference->mutex);
 			}
-			switch_mutex_unlock(conference->member_mutex);
-			switch_mutex_unlock(conference->mutex);
 		}
-
-	} else {
-		err = 1;
 	}
 
 done:
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_lock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	switch_event_t *event;
+	if (conference != NULL && stream != NULL) {
+		switch_event_t *event;
 
-	switch_set_flag_locked(conference, CFLAG_LOCKED);
-	stream->write_function(stream, "OK %s locked\n", argv[0]);
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
-		switch_event_fire(&event);
+		switch_set_flag_locked(conference, CFLAG_LOCKED);
+		stream->write_function(stream, "OK %s locked\n", argv[0]);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
+			switch_event_fire(&event);
+		}
 	}
 
 	return 0;
@@ -2594,14 +2694,16 @@
 
 static int conf_api_sub_unlock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	switch_event_t *event;
+	if (conference != NULL && stream != NULL) {
+		switch_event_t *event;
 
-	switch_clear_flag_locked(conference, CFLAG_LOCKED);
-	stream->write_function(stream, "OK %s unlocked\n", argv[0]);
-	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
-		switch_event_fire(&event);
+		switch_clear_flag_locked(conference, CFLAG_LOCKED);
+		stream->write_function(stream, "OK %s unlocked\n", argv[0]);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
+			switch_event_fire(&event);
+		}
 	}
 
 	return 0;
@@ -2609,91 +2711,94 @@
 
 static int conf_api_sub_dial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	int err = 0;
+	int syntax_err = 0;
 
-	if (argc > 2) {
-		conference_outcall(conference, NULL, argv[2], 60, NULL, argv[4], argv[3]);
-		stream->write_function(stream, "OK\n");
-	} else {
-		err = 1;
+	if (conference != NULL && stream != NULL) {
+		if (argc > 2) {
+			conference_outcall(conference, NULL, argv[2], 60, NULL, argv[4], argv[3]);
+			stream->write_function(stream, "OK\n");
+		} else {
+			syntax_err = 1;
+		}
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_transfer(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	int err = 0;
+	int syntax_err = 0;
 
-	if (argc > 3 && !switch_strlen_zero(argv[2])) {
-		int x;
+	if (conference != NULL && stream != NULL) {
+		if (argc > 3 && !switch_strlen_zero(argv[2])) {
+			int x;
 
-		for (x=3; x<argc; x++) {
-			conference_member_t *member = NULL;
-			uint32_t id = atoi(argv[x]);
-			conference_obj_t *new_conference = NULL;
-			switch_channel_t *channel;
-			switch_event_t *event;
-			char *profile_name;
-			switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
+			for (x=3; x<argc; x++) {
+				conference_member_t *member = NULL;
+				uint32_t id = atoi(argv[x]);
+				conference_obj_t *new_conference = NULL;
+				switch_channel_t *channel;
+				switch_event_t *event;
+				char *profile_name;
+				switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
 
-			if (!(member = conference_member_get(conference, id))) {								
-				stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
-				continue;
-			}
-
-			channel = switch_core_session_get_channel(member->session);
-
-			/* build a new conference if it doesn't exist */
-			if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
-				switch_memory_pool_t *pool = NULL;
-				char *conf_name;
-				conf_xml_cfg_t xml_cfg;
-
-				/* Setup a memory pool to use. */
-				if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-					goto done;
+				if (!(member = conference_member_get(conference, id))) {								
+					stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
+					continue;
 				}
 
-				conf_name = switch_core_strdup(pool, argv[2]);
+				channel = switch_core_session_get_channel(member->session);
 
-				if ((profile_name = strchr(conf_name, '@'))) {
-					*profile_name++ = '\0';
+				/* build a new conference if it doesn't exist */
+				if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
+					switch_memory_pool_t *pool = NULL;
+					char *conf_name;
+					conf_xml_cfg_t xml_cfg;
 
-					/* Open the config from the xml registry  */
-					if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+					/* Setup a memory pool to use. */
+					if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
 						goto done;
 					}
 
-					if ((profiles = switch_xml_child(cfg, "profiles"))) {
-						xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
-					}
-					xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
+					conf_name = switch_core_strdup(pool, argv[2]);
+
+					if ((profile_name = strchr(conf_name, '@'))) {
+						*profile_name++ = '\0';
+
+						/* Open the config from the xml registry  */
+						if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+							goto done;
+						}
+
+						if ((profiles = switch_xml_child(cfg, "profiles"))) {
+							xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
+						}
+						xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
 #ifdef OPTION_IVR_MENU_SUPPORT
-					xml_cfg.menus = switch_xml_child(cfg, "menus");
+						xml_cfg.menus = switch_xml_child(cfg, "menus");
 #endif
-				} 
+					} 
 
-				/* Release the config registry handle */
-				if (cxml) {
-					switch_xml_free(cxml);
-					cxml = NULL;
-				}
+					/* Release the config registry handle */
+					if (cxml) {
+						switch_xml_free(cxml);
+						cxml = NULL;
+					}
 
-				/* Create the conference object. */
-				new_conference = conference_new(conf_name, xml_cfg, pool);
+					/* Create the conference object. */
+					new_conference = conference_new(conf_name, xml_cfg, pool);
 
-				if (!new_conference) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-					if (pool != NULL) {
-						switch_core_destroy_memory_pool(&pool);
+					if (!new_conference) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+						if (pool != NULL) {
+							switch_core_destroy_memory_pool(&pool);
+						}
+						goto done;
 					}
-					goto done;
-				}
 
-				/* Set the minimum number of members (once you go above it you cannot go below it) */
+					/* Set the minimum number of members (once you go above it you cannot go below it) */
 				new_conference->min = 1;
 
 				/* Indicate the conference is dynamic */
@@ -2701,59 +2806,64 @@
 
 				/* Start the conference thread for this conference */
 				launch_conference_thread(new_conference);
-			}
+				}
 
-			/* move the member from the old conference to the new one */
-			conference_del_member(member->last_conference, member);
-			conference_add_member(new_conference, member);
+				/* move the member from the old conference to the new one */
+				conference_del_member(member->last_conference, member);
+				conference_add_member(new_conference, member);
 
-			stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
+				stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
 
-			/* tell them what happened */
-			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-				switch_channel_event_set_data(channel, event);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", conference->name);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", argv[3]);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
-				switch_event_fire(&event);
+				/* tell them what happened */
+				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+					switch_channel_event_set_data(channel, event);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", conference->name);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", argv[3]);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
+					switch_event_fire(&event);
+				}
 			}
+		} else {
+			syntax_err = 1;
 		}
-	} else {
-		err = 1;
 	}
 done:
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	int err = 0;
+	int syntax_err = 0;
 
-	if (argc > 2) {
-		launch_conference_record_thread(conference, argv[2]);
-	} else {
-		err = 1;
+	if (conference != NULL && stream != NULL) {
+		if (argc > 2) {
+			launch_conference_record_thread(conference, argv[2]);
+		} else {
+			syntax_err = 1;
+		}
 	}
 
-	return err;
+	return syntax_err;
 }
 
 static int conf_api_sub_norecord(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
 {
-	int err = 0;
+	int syntax_err = 0;
 
-	if (argc > 2) {
-		int all = (strcasecmp(argv[2], "all") == 0 );
+	if (conference != NULL && stream != NULL) {
+		if (argc > 2) {
+			int all = (strcasecmp(argv[2], "all") == 0 );
 
-		if(!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
-			stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
+			if(!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
+				stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
+			}
+		} else {
+			syntax_err = 1;
 		}
-	} else {
-		err = 1;
 	}
 
-	return err;
+	return syntax_err;
 }
 
 enum {
@@ -2843,7 +2953,7 @@
 
 							/* member specific command that can be itteratted */
 							case CONF_API_SUB_MEMBER_TARGET:
-								{
+								if (conference != NULL) {
 									uint32_t id = atoi(argv[argn+1]);
 									int all = ( id == 0 && strcasecmp(argv[argn+1], "all") == 0 );
 									int last = ( id == 0 && strcasecmp(argv[argn+1], "last") == 0 );
@@ -2886,6 +2996,9 @@
 											}
 										}
 									}
+								} else {
+									stream->write_function(stream, "Conference %s not found\n", argv[0]);
+									switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s not found\n", argv[0]);
 								}
 								break;
 



More information about the Freeswitch-branches mailing list