[asterisk-commits] file: branch file/bridging r78175 - in /team/file/bridging: include/asterisk/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 6 10:45:34 CDT 2007
Author: file
Date: Mon Aug 6 10:45:33 2007
New Revision: 78175
URL: http://svn.digium.com/view/asterisk?view=rev&rev=78175
Log:
Phase suddenly becomes state!
Modified:
team/file/bridging/include/asterisk/bridging.h
team/file/bridging/main/bridging.c
Modified: team/file/bridging/include/asterisk/bridging.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/bridging.h?view=diff&rev=78175&r1=78174&r2=78175
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Mon Aug 6 10:45:33 2007
@@ -47,13 +47,13 @@
AST_BRIDGE_NOTIFY_REBUILD = (1 << 0), /*! Someone wants us to rebuild the bridge a bit */
};
-/*! \brief Phase information about a bridged channel */
-enum ast_bridge_channel_phase {
- AST_BRIDGE_CHANNEL_PHASE_WAIT = 0, /*! Bridged channel is waiting for a signal */
- AST_BRIDGE_CHANNEL_PHASE_SIGNAL = 1, /*! Bridge wants us to do something in our thread */
- AST_BRIDGE_CHANNEL_PHASE_END = 2, /*! Bridged channel ended itself */
- AST_BRIDGE_CHANNEL_PHASE_HANGUP = 3, /*! Bridge requested that this channel be hungup, unless otherwise instructed */
- AST_BRIDGE_CHANNEL_PHASE_DEPART = 4, /*! Depart from the bridge */
+/*! \brief State information about a bridged channel */
+enum ast_bridge_channel_state {
+ AST_BRIDGE_CHANNEL_STATE_WAIT = 0, /*! Waiting for a signal */
+ AST_BRIDGE_CHANNEL_STATE_SIGNAL, /*! Bridge wants us to do something in our thread */
+ AST_BRIDGE_CHANNEL_STATE_END, /*! Bridged channel ended itself */
+ AST_BRIDGE_CHANNEL_STATE_HANGUP, /*! Bridge requested that this channel be hungup, unless otherwise instructed */
+ AST_BRIDGE_CHANNEL_STATE_DEPART, /*! Depart from the bridge */
};
/*! \brief Flags used for bridge features */
@@ -80,7 +80,7 @@
};
struct ast_bridge_channel {
- enum ast_bridge_channel_phase phase; /*! Current bridged channel phase */
+ enum ast_bridge_channel_state state; /*! Current bridged channel state */
struct ast_channel *chan; /*! Asterisk channel participating in this bridge */
struct ast_bridge *bridge; /*! Bridge this channel is in */
ast_cond_t cond; /*! Condition, used if we want to wake up a thread waiting on the bridged channel */
@@ -127,9 +127,9 @@
/*! \brief Join a channel to a bridge
* \param bridge Bridge to join
* \param chan Channel to join
- * \return Returns phase that channel exited bridge on
+ * \return Returns state that channel exited bridge on
*/
-enum ast_bridge_channel_phase ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan);
+enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan);
/*! \brief Impart a channel on a bridge
* \param bridge Bridge to impart on
@@ -145,12 +145,12 @@
*/
int ast_bridge_depart(struct ast_bridge *bridge, struct ast_channel *chan);
-/*! \brief Change the phase of a bridge channel
+/*! \brief Change the state of a bridge channel
* \param bridge_channel Bridge channel
- * \param new_phase Phase to change to
+ * \param new_state State to change to
* \return Returns 0 on success, -1 on failure
*/
-int ast_bridge_change_phase(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_phase new_phase);
+int ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
/*! \brief Merge two bridges together
* \param bridge0 First bridge
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=78175&r1=78174&r2=78175
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Mon Aug 6 10:45:33 2007
@@ -135,7 +135,7 @@
/* Now we have to add each channel */
AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, list) {
- if (bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_WAIT || bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_SIGNAL)
+ if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT || bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_SIGNAL)
cs[i++] = bridge_channel->chan;
}
@@ -176,14 +176,14 @@
/* Try to read in a frame, if this fails it means they hungup */
if (!(frame = ast_read(winner)) || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
- /* Switch the bridged channel phase to end and signal it's thread */
- ast_bridge_change_phase(bridge_channel, AST_BRIDGE_CHANNEL_PHASE_END);
+ /* Switch the bridged channel state to end and signal it's thread */
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
/* If the bridge is set to dissolve upon anyone hanging up, due so */
if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_DISSOLVE)) {
struct ast_bridge_channel *bridge_channel2 = NULL;
AST_LIST_TRAVERSE(&bridge->channels, bridge_channel2, list) {
if (bridge_channel2 != bridge_channel)
- ast_bridge_change_phase(bridge_channel2, AST_BRIDGE_CHANNEL_PHASE_HANGUP);
+ ast_bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
}
}
/* Have ourselves rebuild next time */
@@ -292,7 +292,7 @@
/* Drop every bridged channel */
AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, list) {
- ast_bridge_change_phase(bridge_channel, AST_BRIDGE_CHANNEL_PHASE_END);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
}
/* If the thread is still running we have to nudge it to kill itself */
@@ -337,7 +337,7 @@
}
/*! \brief Join a channel to a bridge and handle anything the bridge may want us to do */
-static enum ast_bridge_channel_phase bridge_channel_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+static enum ast_bridge_channel_state bridge_channel_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
int formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
@@ -378,8 +378,8 @@
ast_log(LOG_DEBUG, "Bridge %p put channel %s into write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
}
- /* Before we actually become part of this bridge make sure we are in the signalling wait phase */
- bridge_channel->phase = AST_BRIDGE_CHANNEL_PHASE_WAIT;
+ /* Before we actually become part of this bridge make sure we are in the signalling wait state */
+ bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
/* Make the bridged channel part of the bridge */
AST_LIST_INSERT_TAIL(&bridge->channels, bridge_channel, list);
@@ -409,29 +409,29 @@
/* Go into a loop waiting for the bridge thread to make us do something */
for (;;) {
- if (bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_WAIT) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge channel %p entering signalling wait phase.\n", bridge_channel);
+ if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bridge channel %p entering signalling wait state.\n", bridge_channel);
ast_cond_wait(&bridge_channel->cond, &bridge->lock);
}
- if (bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_SIGNAL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge channel %p entering signalling phase.\n", bridge_channel);
+ if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_SIGNAL) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bridge channel %p entering signalling state.\n", bridge_channel);
if (bridge->technology->signal)
bridge->technology->signal(bridge, bridge_channel);
- /* Switch phase back to wait */
- bridge_channel->phase = AST_BRIDGE_CHANNEL_PHASE_WAIT;
- } else if (bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_END) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge channel %p entering end phase.\n", bridge_channel);
+ /* Switch state back to wait */
+ bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ } else if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_END) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bridge channel %p entering end state.\n", bridge_channel);
break;
- } else if (bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_HANGUP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge channel %p entering hangup phase.\n", bridge_channel);
+ } else if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_HANGUP) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bridge channel %p entering hangup state.\n", bridge_channel);
break;
- } else if (bridge_channel->phase == AST_BRIDGE_CHANNEL_PHASE_DEPART) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge channel %p entering depart phase.\n", bridge_channel);
+ } else if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_DEPART) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bridge channel %p entering depart state.\n", bridge_channel);
break;
}
}
@@ -464,7 +464,7 @@
ast_log(LOG_WARNING, "Failed to return channel %s to write format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(formats[1]), formats[1]);
}
- return bridge_channel->phase;
+ return bridge_channel->state;
}
/*! \brief Join a channel to a bridge
@@ -472,10 +472,10 @@
* \param chan Channel to join
* \return Returns phase that channel exited bridge on
*/
-enum ast_bridge_channel_phase ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan)
+enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan)
{
struct ast_bridge_channel bridge_channel;
- enum ast_bridge_channel_phase phase;
+ enum ast_bridge_channel_state state;
/* Wipe out the bridge channel structure just in case */
memset(&bridge_channel, 0, sizeof(bridge_channel));
@@ -491,13 +491,13 @@
ast_mutex_lock(&bridge->lock);
/* Off to the bridge we go... */
- phase = bridge_channel_join(bridge, &bridge_channel);
+ state = bridge_channel_join(bridge, &bridge_channel);
/* All done... we are out of here! */
ast_mutex_unlock(&bridge->lock);
ast_cond_destroy(&bridge_channel.cond);
- return phase;
+ return state;
}
/*! \brief Thread responsible for imparted bridged channels */
@@ -505,11 +505,11 @@
{
struct ast_bridge_channel *bridge_channel = data;
struct ast_bridge *bridge = bridge_channel->bridge;
- enum ast_bridge_channel_phase phase = -1;
+ enum ast_bridge_channel_state state = -1;
ast_mutex_lock(&bridge->lock);
- phase = bridge_channel_join(bridge, bridge_channel);
+ state = bridge_channel_join(bridge, bridge_channel);
ast_mutex_unlock(&bridge->lock);
@@ -517,13 +517,13 @@
ast_cond_destroy(&bridge_channel->cond);
/* Depending on the phase hangup the channel */
- if (phase != AST_BRIDGE_CHANNEL_PHASE_DEPART) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Due to phase %d on bridge channel %p we are hanging it up\n", phase, bridge_channel);
+ if (state != AST_BRIDGE_CHANNEL_STATE_DEPART) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Due to state %d on bridge channel %p we are hanging it up\n", state, bridge_channel);
ast_hangup(bridge_channel->chan);
} else {
if (option_debug)
- ast_log(LOG_DEBUG, "Due to depart phase on bridge channel %p we are NOT hanging it up -- control returning to another thread\n", bridge_channel);
+ ast_log(LOG_DEBUG, "Due to depart state on bridge channel %p we are NOT hanging it up -- control returning to another thread\n", bridge_channel);
}
free(bridge_channel);
@@ -589,7 +589,7 @@
thread = bridge_channel->thread;
/* Change the phase to depart for the channel, this will cause it's thread to exit once everything is woken up */
- ast_bridge_change_phase(bridge_channel, AST_BRIDGE_CHANNEL_PHASE_DEPART);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
/* Queue a rebuild on the bridge itself */
ast_set_flag(&bridge->notify_flags, AST_BRIDGE_NOTIFY_REBUILD);
@@ -612,15 +612,15 @@
return 0;
}
-/*! \brief Change the phase of a bridge channel
+/*! \brief Change the state of a bridge channel
* \param bridge_channel Bridge channel
- * \param new_phase Phase to change to
+ * \param new_state State to change to
* \return Returns 0 on success, -1 on failure
*/
-int ast_bridge_change_phase(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_phase new_phase)
-{
- /* Change the phase on the bridge channel and signal it's thread to wakeup so it realizes the change */
- bridge_channel->phase = new_phase;
+int ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
+{
+ /* Change the state on the bridge channel and signal it's thread to wakeup so it realizes the change */
+ bridge_channel->state = new_state;
return ast_cond_signal(&bridge_channel->cond);
}
More information about the asterisk-commits
mailing list