[svn-commits] jpeeler: branch jpeeler/bug13173 r150315 - /team/jpeeler/bug13173/apps/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 16 19:20:45 CDT 2008


Author: jpeeler
Date: Thu Oct 16 19:20:45 2008
New Revision: 150315

URL: http://svn.digium.com/view/asterisk?view=rev&rev=150315
Log:
check in point, code performance improved to an acceptable level now, but more may be done

Modified:
    team/jpeeler/bug13173/apps/app_meetme.c

Modified: team/jpeeler/bug13173/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/bug13173/apps/app_meetme.c?view=diff&rev=150315&r1=150314&r2=150315
==============================================================================
--- team/jpeeler/bug13173/apps/app_meetme.c (original)
+++ team/jpeeler/bug13173/apps/app_meetme.c Thu Oct 16 19:20:45 2008
@@ -334,6 +334,8 @@
 	unsigned int locked:1;                  /*!< Is the conference locked? */
 	pthread_t recordthread;                 /*!< thread for recording */
 	ast_mutex_t recordthreadlock;		/*!< control threads trying to start recordthread */
+	pthread_t announcethread;
+	ast_mutex_t announcethreadlock;
 	pthread_attr_t attr;                    /*!< thread attribute */
 	const char *recordingfilename;          /*!< Filename to record the Conference into */
 	const char *recordingformat;            /*!< Format to record the Conference in */
@@ -347,6 +349,17 @@
 };
 
 static AST_LIST_HEAD_STATIC(confs, ast_conference);
+
+struct announce_listitem {
+	AST_LIST_ENTRY(announce_listitem) list;
+	char namerecloc[PATH_MAX];				/*!< Name Recorded file Location */
+	char language[MAX_LANGUAGE];
+	struct ast_channel *confchan;
+	int confusers;
+};
+
+static AST_LIST_HEAD_STATIC(announcelist, announce_listitem);
+static ast_cond_t announcelist_addition;
 
 static unsigned int conf_map[1024] = {0, };
 
@@ -762,6 +775,8 @@
 	ast_mutex_init(&cnf->listenlock);
 	cnf->recordthread = AST_PTHREADT_NULL;
 	ast_mutex_init(&cnf->recordthreadlock);
+	cnf->announcethread = AST_PTHREADT_NULL;
+	ast_mutex_init(&cnf->announcethreadlock);
 	ast_copy_string(cnf->confno, confno, sizeof(cnf->confno));
 	ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
 	ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
@@ -1266,6 +1281,9 @@
 	ast_mutex_destroy(&conf->playlock);
 	ast_mutex_destroy(&conf->listenlock);
 	ast_mutex_destroy(&conf->recordthreadlock);
+	ast_mutex_destroy(&conf->announcethreadlock);
+	if (conf->announcethread != AST_PTHREADT_NULL)
+		pthread_cancel(conf->announcethread);
 	free(conf);
 
 	return 0;
@@ -1370,6 +1388,37 @@
 	return res;
 }
 
+static void *announce_thread(void *data)
+{
+
+	struct announce_listitem *next, *current;
+
+	for (;;) {
+		AST_LIST_LOCK(&announcelist);
+		if (AST_LIST_EMPTY(&announcelist))
+			ast_cond_wait(&announcelist_addition, &announcelist.lock);
+		next = AST_LIST_FIRST(&announcelist);
+		AST_LIST_HEAD_INIT_NOLOCK(&announcelist);
+		AST_LIST_UNLOCK(&announcelist);
+
+		while ((current = next)) {
+			next = AST_LIST_NEXT(current, list);
+
+			if (ast_fileexists(current->namerecloc, NULL, NULL)) {
+				if ((current->confchan) && (current->confusers > 1)) {
+					if (!ast_streamfile(current->confchan, current->namerecloc, current->language))
+						ast_waitstream(current->confchan, "");
+					if (!ast_streamfile(current->confchan, "conf-hasleft", current->language))
+						ast_waitstream(current->confchan, "");
+				}
+				ast_filedelete(current->namerecloc, NULL);
+			}
+			free(current);
+		}
+	}
+
+	return NULL;
+}
 
 static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int confflags, char *optargs[])
 {
@@ -1461,6 +1510,15 @@
 		}
 	}
 	ast_mutex_unlock(&conf->recordthreadlock);
+
+	ast_mutex_lock(&conf->announcethreadlock);
+	if ((conf->announcethread == AST_PTHREADT_NULL) && !(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
+		pthread_attr_init(&conf->attr);
+		pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED);
+		ast_pthread_create_background(&conf->announcethread, &conf->attr, announce_thread, conf);
+		pthread_attr_destroy(&conf->attr);
+	}
+	ast_mutex_unlock(&conf->announcethreadlock);
 
 	time(&user->jointime);
 
@@ -2265,15 +2323,15 @@
 		conf_play(chan, conf, LEAVE);
 
 	if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
-		if (ast_fileexists(user->namerecloc, NULL, NULL)) {
-			if ((conf->chan) && (conf->users > 1)) {
-				if (!ast_streamfile(conf->chan, user->namerecloc, chan->language))
-					ast_waitstream(conf->chan, "");
-				if (!ast_streamfile(conf->chan, "conf-hasleft", chan->language))
-					ast_waitstream(conf->chan, "");
-			}
-			ast_filedelete(user->namerecloc, NULL);
-		}
+		struct announce_listitem *item = ast_calloc(1, sizeof(*item));
+		ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc));
+		ast_copy_string(item->language, chan->language, sizeof(item->language));
+		item->confchan = conf->chan;
+		item->confusers = conf->users;
+		AST_LIST_LOCK(&announcelist);
+		AST_LIST_INSERT_TAIL(&announcelist, item, list);
+		ast_cond_signal(&announcelist_addition);
+		AST_LIST_UNLOCK(&announcelist);
 	}
 	AST_LIST_UNLOCK(&confs);
 




More information about the svn-commits mailing list