[asterisk-commits] file: branch file/bridging r90673 - in /team/file/bridging: apps/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 3 15:40:06 CST 2007
Author: file
Date: Mon Dec 3 15:40:05 2007
New Revision: 90673
URL: http://svn.digium.com/view/asterisk?view=rev&rev=90673
Log:
Change it so that channels are added to the bridge in the thread that either joins them or creates the async thread. This way the swap operation can happen even if the async thread has not yet been started.
Modified:
team/file/bridging/apps/app_bridgetest.c
team/file/bridging/main/bridging.c
Modified: team/file/bridging/apps/app_bridgetest.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/apps/app_bridgetest.c?view=diff&rev=90673&r1=90672&r2=90673
==============================================================================
--- team/file/bridging/apps/app_bridgetest.c (original)
+++ team/file/bridging/apps/app_bridgetest.c Mon Dec 3 15:40:05 2007
@@ -94,8 +94,6 @@
/* Put the dialed channel into the bridge via async */
ast_bridge_impart(bridge, ast_dial_answered(dial), NULL, NULL);
- ast_safe_sleep(chan, 1000);
-
ast_bridge_join(bridge, chan, ast_dial_answered(dial), NULL);
ast_bridge_destroy(bridge);
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=90673&r1=90672&r2=90673
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Mon Dec 3 15:40:05 2007
@@ -600,8 +600,8 @@
{
int formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
- /* Add ourselves in to the channels in the bridge */
- AST_LIST_INSERT_TAIL(&bridge->channels, bridge_channel, list);
+ /* Unsuspend the channel being added to the bridge */
+ bridge_channel->suspended = 0;
/* Notify the bridge thread that a new bridged channel is part of the bridge, this will cause it to rebuild the bridge array */
bridge->rebuild = 1;
@@ -701,12 +701,16 @@
bridge_channel.chan = chan;
bridge_channel.bridge = bridge;
bridge_channel.features = features;
+ bridge_channel.suspended = 1;
/* Now setup our synchronization components */
bridge_channel.thread = pthread_self();
ast_cond_init(&bridge_channel.cond, NULL);
ast_mutex_lock(&bridge->lock);
+
+ /* Add channel to the bridge now, but suspended */
+ AST_LIST_INSERT_TAIL(&bridge->channels, &bridge_channel, list);
/* Increment channel count since we are joining */
ast_atomic_fetchadd_int(&bridge->num, +1);
@@ -814,12 +818,16 @@
bridge_channel->chan = chan;
bridge_channel->bridge = bridge;
bridge_channel->features = features;
+ bridge_channel->suspended = 1;
/* Setup synchronization for our thread */
ast_cond_init(&bridge_channel->cond, NULL);
/* Lock the bridge as we are potentially going to muck with it now */
ast_mutex_lock(&bridge->lock);
+
+ /* Add channel to the bridge now, but suspended */
+ AST_LIST_INSERT_TAIL(&bridge->channels, bridge_channel, list);
/* Before we actually hand over this channel to the other thread increment the bridge channel number so the bridge can't go away */
ast_atomic_fetchadd_int(&bridge->num, +1);
More information about the asterisk-commits
mailing list