[asterisk-commits] jpeeler: branch jpeeler/bug13173 r156072 - /team/jpeeler/bug13173/apps/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 11 18:58:42 CST 2008
Author: jpeeler
Date: Tue Nov 11 18:58:42 2008
New Revision: 156072
URL: http://svn.digium.com/view/asterisk?view=rev&rev=156072
Log:
Grouped announce_thread data in ast_conference. Removed debug comments, unnecessary whitespace and indentation, and fixed some style issues.
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=156072&r1=156071&r2=156072
==============================================================================
--- team/jpeeler/bug13173/apps/app_meetme.c (original)
+++ team/jpeeler/bug13173/apps/app_meetme.c Tue Nov 11 18:58:42 2008
@@ -348,10 +348,7 @@
unsigned int isdynamic:1; /*!< Created on the fly? */
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;
- unsigned int announcethread_stop:1;
+ ast_mutex_t recordthreadlock; /*!< control threads trying to start recordthread */
pthread_attr_t attr; /*!< thread attribute */
const char *recordingfilename; /*!< Filename to record the Conference into */
const char *recordingformat; /*!< Format to record the Conference in */
@@ -361,7 +358,11 @@
struct ast_frame *origframe;
struct ast_trans_pvt *transpath[32];
AST_LIST_HEAD_NOLOCK(, ast_conf_user) userlist;
+ /* announce_thread related data */
AST_LIST_ENTRY(ast_conference) list;
+ pthread_t announcethread;
+ ast_mutex_t announcethreadlock;
+ unsigned int announcethread_stop:1;
ast_cond_t announcelist_addition;
AST_LIST_HEAD_NOLOCK(, announce_listitem) announcelist;
ast_mutex_t announcelistlock;
@@ -1281,15 +1282,12 @@
if (conf->announcethread != AST_PTHREADT_NULL) {
ast_mutex_lock(&conf->announcelistlock);
conf->announcethread_stop = 1;
-ast_log(LOG_NOTICE, "jpeeler: announce thread marked to be stopped\n");
ast_softhangup(conf->chan, AST_SOFTHANGUP_EXPLICIT);
ast_cond_signal(&conf->announcelist_addition);
ast_mutex_unlock(&conf->announcelistlock);
pthread_join(conf->announcethread, NULL);
-ast_log(LOG_NOTICE, "jpeeler: announce thread stopped\n");
while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) {
- ast_log(LOG_NOTICE, "jpeeler: deleting %s from announcelist\n", item->namerecloc);
ast_filedelete(item->namerecloc, NULL);
ao2_ref(item, -1);
}
@@ -1308,7 +1306,7 @@
ast_mutex_destroy(&conf->listenlock);
ast_mutex_destroy(&conf->recordthreadlock);
ast_mutex_destroy(&conf->announcethreadlock);
-
+
free(conf);
return 0;
@@ -1440,7 +1438,7 @@
ast_mutex_lock(&conf->announcelistlock);
if (conf->announcethread_stop) {
ast_mutex_unlock(&conf->announcelistlock);
- goto finish;
+ break;
}
if (AST_LIST_EMPTY(&conf->announcelist))
ast_cond_wait(&conf->announcelist_addition, &conf->announcelistlock);
@@ -1450,35 +1448,30 @@
ast_mutex_unlock(&conf->announcelistlock);
if (conf->announcethread_stop) {
- goto finish;
- }
-
- while (!conf->announcethread_stop && (current = AST_LIST_REMOVE_HEAD(&local_list, entry))) {
+ break;
+ }
+
+ for (; !conf->announcethread_stop && (current = AST_LIST_REMOVE_HEAD(&local_list, entry)); ao2_ref(current, -1)) {
ast_log(LOG_DEBUG, "About to play %s\n", current->namerecloc);
- if (ast_fileexists(current->namerecloc, NULL, NULL)) {
- if ((current->confchan) && (current->confusers > 1) && !ast_check_hangup(current->confchan)) {
- if (!ast_streamfile(current->confchan, current->namerecloc, current->language))
- res = ast_waitstream(current->confchan, "");
- if (!res) {
- ast_copy_string(filename, get_announce_filename(current->announcetype), sizeof(filename));
- if (!ast_streamfile(current->confchan, filename, current->language))
- ast_waitstream(current->confchan, "");
- }
- }
- if (current->announcetype == CONF_HASLEFT) {
- ast_log(LOG_DEBUG, "jpeeler: deleting %s %d\n", current->namerecloc, ao2_ref(current, 0));
- ast_filedelete(current->namerecloc, NULL);
- } else {
- ast_log(LOG_DEBUG, "jpeeler type= %d\n", current->announcetype);
+ if (!ast_fileexists(current->namerecloc, NULL, NULL))
+ continue;
+ if ((current->confchan) && (current->confusers > 1) && !ast_check_hangup(current->confchan)) {
+ if (!ast_streamfile(current->confchan, current->namerecloc, current->language))
+ res = ast_waitstream(current->confchan, "");
+ if (!res) {
+ ast_copy_string(filename, get_announce_filename(current->announcetype), sizeof(filename));
+ if (!ast_streamfile(current->confchan, filename, current->language))
+ ast_waitstream(current->confchan, "");
}
}
- ao2_ref(current, -1);
- }
- }
-
-finish:
+ if (current->announcetype == CONF_HASLEFT) {
+ ast_filedelete(current->namerecloc, NULL);
+ }
+ }
+ }
+
+ /* thread marked to stop, clean up */
while ((current = AST_LIST_REMOVE_HEAD(&local_list, entry))) {
- ast_log(LOG_DEBUG, "jpeeler: deleting %s\n", current->namerecloc);
ast_filedelete(current->namerecloc, NULL);
ao2_ref(current, -1);
}
@@ -1803,9 +1796,7 @@
ast_cond_signal(&conf->announcelist_addition);
ast_mutex_unlock(&conf->announcelistlock);
- while (!ast_check_hangup(conf->chan) && ao2_ref(item, 0) == 2 && !ast_safe_sleep(chan, 1000)) {
- ast_log(LOG_NOTICE, "jpeeler: waiting for announcement to finish for %s...\n", chan->name);
- }
+ while (!ast_check_hangup(conf->chan) && ao2_ref(item, 0) == 2 && !ast_safe_sleep(chan, 1000));
ao2_ref(item, -1);
}
@@ -1817,7 +1808,7 @@
ztc.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER;
else
ztc.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER;
-
+
if (ioctl(fd, DAHDI_SETCONF, &ztc)) {
ast_log(LOG_WARNING, "Error setting conference\n");
close(fd);
@@ -2407,7 +2398,6 @@
ast_mutex_unlock(&conf->announcelistlock);
} else if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users == 1) {
/* Last person is leaving, so no reason to try and announce, but should delete the name recording */
- ast_log(LOG_DEBUG, "jpeeler: deleting %s\n", user->namerecloc);
ast_filedelete(user->namerecloc, NULL);
}
More information about the asterisk-commits
mailing list