[asterisk-commits] oej: branch oej/realtimetext-t140 r54068 - in /team/oej/realtimetext-t140: ./...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 12 11:12:15 MST 2007


Author: oej
Date: Mon Feb 12 12:12:14 2007
New Revision: 54068

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54068
Log:
Reset branch

Modified:
    team/oej/realtimetext-t140/   (props changed)
    team/oej/realtimetext-t140/apps/app_voicemail.c
    team/oej/realtimetext-t140/res/res_musiconhold.c

Propchange: team/oej/realtimetext-t140/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/oej/realtimetext-t140/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/oej/realtimetext-t140/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Feb 12 12:12:14 2007
@@ -1,1 +1,1 @@
-/trunk:1-53021
+/trunk:1-51376

Modified: team/oej/realtimetext-t140/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/realtimetext-t140/apps/app_voicemail.c?view=diff&rev=54068&r1=54067&r2=54068
==============================================================================
--- team/oej/realtimetext-t140/apps/app_voicemail.c (original)
+++ team/oej/realtimetext-t140/apps/app_voicemail.c Mon Feb 12 12:12:14 2007
@@ -28,14 +28,20 @@
  * \note This module requires res_adsi to load.
  */
 
+/*** MODULEINFO
+	<depend>res_adsi</depend>
+ ***/
+
 /*** MAKEOPTS
 <category name="MENUSELECT_OPTS_app_voicemail" displayname="Voicemail Build Options" positive_output="yes" remove_on_change="apps/app_voicemail.o">
 	<member name="ODBC_STORAGE" displayname="Storage of Voicemail using ODBC">
 		<depend>unixodbc</depend>
+		<conflict>IMAP_STORAGE</conflict>
 		<defaultenabled>no</defaultenabled>
 	</member>
 	<member name="IMAP_STORAGE" displayname="Storage of Voicemail using IMAP4">
 		<depend>imap_tk</depend>
+		<conflict>ODBC_STORAGE</conflict>
 		<use>ssl</use>
 		<defaultenabled>no</defaultenabled>
 	</member>
@@ -1883,7 +1889,7 @@
 				memset(passdata, 0, vmlen);
 				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
 				pbx_substitute_variables_helper(ast, fromstring, passdata, vmlen);
-				len_passdata = strlen(passdata) * 2 + 1;
+				len_passdata = strlen(passdata) * 2 + 3;
 				passdata2 = alloca(len_passdata);
 				fprintf(p, "From: %s <%s>\r\n", quote(passdata, passdata2, len_passdata), who);
 			} else
@@ -1893,7 +1899,7 @@
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
 	} else
 		fprintf(p, "From: Asterisk PBX <%s>\r\n", who);
-	len_passdata = strlen(vmu->fullname) * 2 + 1;
+	len_passdata = strlen(vmu->fullname) * 2 + 3;
 	passdata2 = alloca(len_passdata);
 	fprintf(p, "To: %s <%s>\r\n", quote(vmu->fullname, passdata2, len_passdata), vmu->email);
 	if (emailsubject) {

Modified: team/oej/realtimetext-t140/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/oej/realtimetext-t140/res/res_musiconhold.c?view=diff&rev=54068&r1=54067&r2=54068
==============================================================================
--- team/oej/realtimetext-t140/res/res_musiconhold.c (original)
+++ team/oej/realtimetext-t140/res/res_musiconhold.c Mon Feb 12 12:12:14 2007
@@ -159,7 +159,7 @@
 	AST_LIST_ENTRY(mohdata) list;
 };
 
-AST_LIST_HEAD_STATIC(mohclasses, mohclass);
+AST_RWLIST_HEAD_STATIC(mohclasses, mohclass);
 
 #define LOCAL_MPG_123 "/usr/local/bin/mpg123"
 #define MPG_123 "/usr/bin/mpg123"
@@ -216,28 +216,29 @@
 	struct moh_files_state *state = chan->music_state;
 	int tries;
 
+	/* Discontinue a stream if it is running already */
+	if (chan->stream) {
+		ast_closestream(chan->stream);
+		chan->stream = NULL;
+	}
+
+	/* If a specific file has been saved, use it */
 	if (state->save_pos) {
 		state->pos = state->save_pos;
 		state->save_pos = 0;
-	}
-
-	state->samples = 0;
-	if (chan->stream) {
-		ast_closestream(chan->stream);
-		chan->stream = NULL;
+	} else if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
+		/* Get a random file and ensure we can open it */
+		for (tries = 0; tries < 20; tries++) {
+			state->pos = rand() % state->class->total_files;
+			if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) > 0)
+				break;
+		}
+		state->samples = 0;
+	} else {
+		/* This is easy, just increment our position and make sure we don't exceed the total file count */
 		state->pos++;
 		state->pos %= state->class->total_files;
-	}
-
-	if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
-		/* Try 20 times to find something good */
-		for (tries = 0; tries < 20; tries++) {
-			state->pos = rand() % state->class->total_files;
-
-			/* check to see if this file's format can be opened */
-			if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) > 0)
-				break;
-		}
+		state->samples = 0;
 	}
 
 	if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {
@@ -555,15 +556,15 @@
 			continue;
 		}
 		pthread_testcancel();
-		AST_LIST_LOCK(&mohclasses);
-		AST_LIST_TRAVERSE(&class->members, moh, list) {
+		AST_RWLIST_RDLOCK(&mohclasses);
+		AST_RWLIST_TRAVERSE(&class->members, moh, list) {
 			/* Write data */
 			if ((res = write(moh->pipe[1], sbuf, res2)) != res2) {
 				if (option_debug)
 					ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
 			}
 		}
-		AST_LIST_UNLOCK(&mohclasses);
+		AST_RWLIST_UNLOCK(&mohclasses);
 	}
 	return NULL;
 }
@@ -628,7 +629,7 @@
 {
 	struct mohclass *moh = NULL;
 
-	AST_LIST_TRAVERSE(&mohclasses, moh, list) {
+	AST_RWLIST_TRAVERSE(&mohclasses, moh, list) {
 		if (!strcasecmp(name, moh->name))
 			break;
 	}
@@ -671,9 +672,9 @@
 	struct mohdata *moh = data;
 	int oldwfmt;
 
-	AST_LIST_LOCK(&mohclasses);
-	AST_LIST_REMOVE(&moh->parent->members, moh, list);	
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_WRLOCK(&mohclasses);
+	AST_RWLIST_REMOVE(&moh->parent->members, moh, list);	
+	AST_RWLIST_UNLOCK(&mohclasses);
 	
 	close(moh->pipe[0]);
 	close(moh->pipe[1]);
@@ -837,7 +838,7 @@
 #ifdef HAVE_ZAPTEL
 	int x;
 #endif
-	AST_LIST_LOCK(&mohclasses);
+	AST_RWLIST_WRLOCK(&mohclasses);
 	if (get_mohbyname(moh->name)) {
 		if (reload) {
 			if (option_debug)
@@ -846,10 +847,10 @@
 			ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name);
 		}
 		free(moh);	
-		AST_LIST_UNLOCK(&mohclasses);
-		return -1;
-	}
-	AST_LIST_UNLOCK(&mohclasses);
+		AST_RWLIST_UNLOCK(&mohclasses);
+		return -1;
+	}
+	AST_RWLIST_UNLOCK(&mohclasses);
 
 	time(&moh->start);
 	moh->start -= respawn_time;
@@ -899,9 +900,9 @@
 		return -1;
 	}
 
-	AST_LIST_LOCK(&mohclasses);
-	AST_LIST_INSERT_HEAD(&mohclasses, moh, list);
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_WRLOCK(&mohclasses);
+	AST_RWLIST_INSERT_HEAD(&mohclasses, moh, list);
+	AST_RWLIST_UNLOCK(&mohclasses);
 	
 	return 0;
 }
@@ -939,9 +940,9 @@
 	else
 		class = "default";
 
-	AST_LIST_LOCK(&mohclasses);
+	AST_RWLIST_RDLOCK(&mohclasses);
 	mohclass = get_mohbyname(class);
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_UNLOCK(&mohclasses);
 
 	if (!mohclass) {
 		ast_log(LOG_WARNING, "No class: %s\n", class);
@@ -1060,8 +1061,8 @@
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "Destroying musiconhold processes\n");
 
-	AST_LIST_LOCK(&mohclasses);
-	while ((moh = AST_LIST_REMOVE_HEAD(&mohclasses, list))) {
+	AST_RWLIST_WRLOCK(&mohclasses);
+	while ((moh = AST_RWLIST_REMOVE_HEAD(&mohclasses, list))) {
 		if (moh->pid > 1) {
 			if (option_debug)
 				ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
@@ -1084,7 +1085,7 @@
 		}
 		ast_moh_free_class(&moh);
 	}
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_UNLOCK(&mohclasses);
 }
 
 static void moh_on_off(int on)
@@ -1119,8 +1120,8 @@
 	int i;
 	struct mohclass *class;
 
-	AST_LIST_LOCK(&mohclasses);
-	AST_LIST_TRAVERSE(&mohclasses, class, list) {
+	AST_RWLIST_RDLOCK(&mohclasses);
+	AST_RWLIST_TRAVERSE(&mohclasses, class, list) {
 		if (!class->total_files)
 			continue;
 
@@ -1128,7 +1129,7 @@
 		for (i = 0; i < class->total_files; i++)
 			ast_cli(fd, "\tFile: %s\n", class->filearray[i]);
 	}
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_UNLOCK(&mohclasses);
 
 	return 0;
 }
@@ -1137,8 +1138,8 @@
 {
 	struct mohclass *class;
 
-	AST_LIST_LOCK(&mohclasses);
-	AST_LIST_TRAVERSE(&mohclasses, class, list) {
+	AST_RWLIST_RDLOCK(&mohclasses);
+	AST_RWLIST_TRAVERSE(&mohclasses, class, list) {
 		ast_cli(fd, "Class: %s\n", class->name);
 		ast_cli(fd, "\tMode: %s\n", S_OR(class->mode, "<none>"));
 		ast_cli(fd, "\tDirectory: %s\n", S_OR(class->dir, "<none>"));
@@ -1147,7 +1148,7 @@
 		if (strcasecmp(class->mode, "files"))
 			ast_cli(fd, "\tFormat: %s\n", ast_getformatname(class->format));
 	}
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_UNLOCK(&mohclasses);
 
 	return 0;
 }
@@ -1173,12 +1174,12 @@
 	if (!load_moh_classes(reload)) 		/* Load classes from config */
 		return 0;			/* Return if nothing is found */
 
-	AST_LIST_LOCK(&mohclasses);
-	AST_LIST_TRAVERSE(&mohclasses, moh, list) {
+	AST_RWLIST_WRLOCK(&mohclasses);
+	AST_RWLIST_TRAVERSE(&mohclasses, moh, list) {
 		if (moh->total_files)
 			moh_scan_files(moh);
 	}
-	AST_LIST_UNLOCK(&mohclasses);
+	AST_RWLIST_UNLOCK(&mohclasses);
 
 	return 1;
 }



More information about the asterisk-commits mailing list