[svn-commits] irroot: branch irroot/distrotech-customers-trunk r338894 - /team/irroot/distr...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Oct 1 02:01:32 CDT 2011


Author: irroot
Date: Sat Oct  1 02:01:26 2011
New Revision: 338894

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=338894
Log:
Move chan_local fixup from local_write to local_indicate

Modified:
    team/irroot/distrotech-customers-trunk/channels/chan_local.c

Modified: team/irroot/distrotech-customers-trunk/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/channels/chan_local.c?view=diff&rev=338894&r1=338893&r2=338894
==============================================================================
--- team/irroot/distrotech-customers-trunk/channels/chan_local.c (original)
+++ team/irroot/distrotech-customers-trunk/channels/chan_local.c Sat Oct  1 02:01:26 2011
@@ -588,10 +588,8 @@
 static int local_write(struct ast_channel *ast, struct ast_frame *f)
 {
 	struct local_pvt *p = ast->tech_pvt;
-	struct ast_channel *bridge;
 	int res = -1;
 	int isoutbound;
-	int lockcheck = 10;
 
 	if (!p) {
 		return -1;
@@ -604,28 +602,6 @@
 
 	if (isoutbound && f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
 		check_bridge(p);
-	} else if (f && (f->frametype == AST_FRAME_VOICE)) {
-		/* fixup audio formats nativeformat has changed we must adjust
-		 * ast is p->owner and is locked here*/
-		ao2_unlock(p);
-		bridge = ast_bridged_channel(ast);
-		ao2_lock(p);
-		if (p->chan && bridge && (bridge != p->chan) &&
-		    !ast_format_cap_identical(bridge->nativeformats, ast->nativeformats)) {
-			while (lockcheck && ast_channel_trylock(p->chan)) {
-				lockcheck--;
-				usleep(1000);
-			}
-			if (lockcheck) {
-				ast_format_cap_copy(ast->nativeformats, bridge->nativeformats);
-				ast_set_read_format(ast, &ast->readformat);
-				ast_set_write_format(ast, &ast->writeformat);
-				ast_format_cap_copy(p->chan->nativeformats, bridge->nativeformats);
-				ast_set_read_format(p->chan, &p->chan->readformat);
-				ast_set_write_format(p->chan, &p->chan->writeformat);
-				ast_channel_unlock(p->chan);
-			}
-		}
 	}
 
 	if (!ast_test_flag(p, LOCAL_ALREADY_MASQED)) {
@@ -676,9 +652,10 @@
 static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	struct local_pvt *p = ast->tech_pvt;
+	struct ast_channel *bridge;
 	int res = 0;
 	struct ast_frame f = { AST_FRAME_CONTROL, };
-	int isoutbound;
+	int isoutbound = IS_OUTBOUND(ast, p);
 
 	if (!p) {
 		return -1;
@@ -702,7 +679,6 @@
 		 * happens to be in this control frame. The same applies for redirecting information, which
 		 * is why it is handled here as well.*/
 		ao2_lock(p);
-		isoutbound = IS_OUTBOUND(ast, p);
 		if (isoutbound) {
 			this_channel = p->chan;
 			the_other_channel = p->owner;
@@ -725,10 +701,33 @@
 			res = local_queue_frame(p, isoutbound, &f, ast, 1);
 		}
 		ao2_unlock(p);
+	} else if (!isoutbound && (condition == AST_CONTROL_SRCUPDATE)) {
+		bridge = ast_bridged_channel(ast);
+		ao2_lock(p);
+		/* fixup audio formats nativeformat might have changed we must adjust.
+		 * ast is p->owner and is locked here*/
+		if (p->chan && bridge && (bridge != p->chan) &&
+		    !ast_format_cap_identical(bridge->nativeformats, ast->nativeformats)) {
+			if (!ast_channel_trylock(p->chan)) {
+				ast_format_cap_copy(ast->nativeformats, bridge->nativeformats);
+				ast_set_read_format(ast, &ast->readformat);
+				ast_set_write_format(ast, &ast->writeformat);
+				ast_format_cap_copy(p->chan->nativeformats, bridge->nativeformats);
+				ast_set_read_format(p->chan, &p->chan->readformat);
+				ast_set_write_format(p->chan, &p->chan->writeformat);
+				ast_channel_unlock(p->chan);
+			} else {
+				ast_verb(3, "Tried to get lock on %s to set audio format but failed\n", p->chan->name);
+			}
+		}
+		f.subclass.integer = condition;
+		f.data.ptr = (void*)data;
+		f.datalen = datalen;
+		res = local_queue_frame(p, isoutbound, &f, ast, 1);
+		ao2_unlock(p);
 	} else {
 		/* Queue up a frame representing the indication as a control frame */
 		ao2_lock(p);
-		isoutbound = IS_OUTBOUND(ast, p);
 		f.subclass.integer = condition;
 		f.data.ptr = (void*)data;
 		f.datalen = datalen;




More information about the svn-commits mailing list