[asterisk-commits] file: branch file/bridging r78996 - /team/file/bridging/main/bridging.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Aug 10 10:24:19 CDT 2007
Author: file
Date: Fri Aug 10 10:24:18 2007
New Revision: 78996
URL: http://svn.digium.com/view/asterisk?view=rev&rev=78996
Log:
Change to using ast_debug for debug messages.
Modified:
team/file/bridging/main/bridging.c
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=78996&r1=78995&r2=78996
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Fri Aug 10 10:24:18 2007
@@ -118,8 +118,7 @@
/* It should never be possible for us to get called without at least one channel in our bridge but just in case... */
if (AST_LIST_EMPTY(&bridge->channels)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to execute thread for bridge %p, no channels are in it.\n", bridge);
+ ast_debug(1, "Unable to execute thread for bridge %p, no channels are in it.\n", bridge);
ast_mutex_unlock(&bridge->lock);
return NULL;
}
@@ -139,8 +138,7 @@
cs[i++] = bridge_channel->chan;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Rebuild of bridge array on %p went from %d to %d.\n", bridge, count, i);
+ ast_debug(1, "Rebuild of bridge array on %p went from %d to %d.\n", bridge, count, i);
count = i;
/* If no bridge channels are in this bridge any longer discontinue the thread */
@@ -199,8 +197,7 @@
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ending bridge thread for %p\n", bridge);
+ ast_debug(1, "Ending bridge thread for %p\n", bridge);
/* Indicate the bridge thread is no longer active */
bridge->thread = AST_PTHREADT_NULL;
@@ -217,9 +214,8 @@
AST_RWLIST_RDLOCK(&bridge_technologies);
AST_RWLIST_TRAVERSE(&bridge_technologies, current, list) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge technology %s has capabilities %d and we want %d\n", current->name, current->capabilities, capabilities);
- if (current->suspended)
+ ast_debug(1, "Bridge technology %s has capabilities %d and we want %d\n", current->name, current->capabilities, capabilities);
+ if (current->suspended)
continue;
if (!(current->capabilities & capabilities))
continue;
@@ -250,8 +246,7 @@
/* If no bridge technology was found we can't possible do bridging so fail creation of the bridge */
if (!bridge_technology) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to find a bridge technology to satisfy capabilities %d\n", capabilities);
+ ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %d\n", capabilities);
return NULL;
}
@@ -269,12 +264,9 @@
/* Pass off the bridge to the technology to manipulate if needed */
if (bridge->technology->create) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Giving bridge technology %s the bridge structure %p to setup\n", bridge->technology->name, bridge);
- if (bridge->technology->create(bridge)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge technology %s failed to setup bridge structure %p\n", bridge->technology->name, bridge);
- }
+ ast_debug(1, "Giving bridge technology %s the bridge structure %p to setup\n", bridge->technology->name, bridge);
+ if (bridge->technology->create(bridge))
+ ast_debug(1, "Bridge technology %s failed to setup bridge structure %p\n", bridge->technology->name, bridge);
}
return bridge;
@@ -304,8 +296,7 @@
/* Poke the bridge thread out of it's poll if in it */
pthread_kill(bridge->thread, SIGURG);
/* Give up our lock so that the bridge thread can acquire it */
- if (option_debug)
- ast_log(LOG_DEBUG, "Giving up bridge lock on %p and waiting for thread to exit\n", bridge);
+ ast_debug(1, "Giving up bridge lock on %p and waiting for thread to exit\n", bridge);
ast_mutex_unlock(&bridge->lock);
/* Now we basically wait for the thread to realize it should discontinue itself */
pthread_join(thread, NULL);
@@ -314,17 +305,13 @@
ast_mutex_unlock(&bridge->lock);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Proceeding with bridge destruction of %p\n", bridge);
+ ast_debug(1, "Proceeding with bridge destruction of %p\n", bridge);
/* Pass off the bridge to the technology to destroy if needed */
if (bridge->technology->destroy) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Giving bridge technology %s the bridge structure %p to destroy\n", bridge->technology->name, bridge);
- if (bridge->technology->destroy(bridge)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge technology %s failed to destroy bridge structure %p... trying our best\n", bridge->technology->name, bridge);
- }
+ ast_debug(1, "Giving bridge technology %s the bridge structure %p to destroy\n", bridge->technology->name, bridge);
+ if (bridge->technology->destroy(bridge))
+ ast_debug(1, "Bridge technology %s failed to destroy bridge structure %p... trying our best\n", bridge->technology->name, bridge);
}
/* Destroy the mutex that protects the bridge */
@@ -374,8 +361,7 @@
ast_log(LOG_WARNING, "Failed to set channel %s to write format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
return -1;
}
- if (option_debug)
- 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);
+ ast_debug(1, "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 state */
@@ -389,8 +375,7 @@
/* Of course if this is the first channel we actually have to create the bridge thread */
if ((bridge->thread == AST_PTHREADT_NULL) && (ast_pthread_create(&bridge->thread, NULL, bridge_thread, bridge))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to create bridge thread for %p\n", bridge);
+ ast_debug(1, "Failed to create bridge thread for %p\n", bridge);
return -1;
} else {
/* Poke the bridge out of it's poll if there */
@@ -399,51 +384,40 @@
/* If the bridge technology wants notification that this channel is joining the bridge, give it it */
if (bridge->technology->join) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Giving bridge technology %s notification that %p is joining bridge %p\n", bridge->technology->name, bridge_channel, bridge);
- if (bridge->technology->join(bridge, bridge_channel)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge technology %s failed to join %p to bridge %p\n", bridge->technology->name, bridge_channel, bridge);
- }
+ ast_debug(1, "Giving bridge technology %s notification that %p is joining bridge %p\n", bridge->technology->name, bridge_channel, bridge);
+ if (bridge->technology->join(bridge, bridge_channel))
+ ast_debug(1, "Bridge technology %s failed to join %p to bridge %p\n", bridge->technology->name, bridge_channel, bridge);
}
/* Go into a loop waiting for the bridge thread to make us do something */
for (;;) {
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_debug(1, "Bridge channel %p entering signalling wait state.\n", bridge_channel);
ast_cond_wait(&bridge_channel->cond, &bridge->lock);
}
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);
+ ast_debug(1, "Bridge channel %p entering signalling state.\n", bridge_channel);
if (bridge->technology->signal)
bridge->technology->signal(bridge, 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);
+ ast_debug(1, "Bridge channel %p entering end state.\n", bridge_channel);
break;
} 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);
+ ast_debug(1, "Bridge channel %p entering hangup state.\n", bridge_channel);
break;
} 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);
+ ast_debug(1, "Bridge channel %p entering depart state.\n", bridge_channel);
break;
}
}
/* If the bridge technology wants notification that this channel is leaving the bridge, give it it */
if (bridge->technology->leave) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Giving bridge technology %s notification that %p is leaving bridge %p\n", bridge->technology->name, bridge_channel, bridge);
- if (bridge->technology->leave(bridge, bridge_channel)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge technology %s failed to allow %p to leave bridge %p\n", bridge->technology->name, bridge_channel, bridge);
- }
+ ast_debug(1, "Giving bridge technology %s notification that %p is leaving bridge %p\n", bridge->technology->name, bridge_channel, bridge);
+ if (bridge->technology->leave(bridge, bridge_channel))
+ ast_debug(1, "Bridge technology %s failed to allow %p to leave bridge %p\n", bridge->technology->name, bridge_channel, bridge);
}
/* Remove ourselves from the bridge */
@@ -451,15 +425,13 @@
/* Restore original formats if need be */
if (bridge_channel->chan->readformat != formats[0]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge is returning %p to read format %s(%d)\n", bridge_channel, ast_getformatname(formats[0]), formats[0]);
+ ast_debug(1, "Bridge is returning %p to read format %s(%d)\n", bridge_channel, ast_getformatname(formats[0]), formats[0]);
if (ast_set_read_format(bridge_channel->chan, formats[0]))
ast_log(LOG_WARNING, "Failed to return channel %s to read format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(formats[0]), formats[0]);
}
if (bridge_channel->chan->writeformat != formats[1]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge is returning %p to write format %s(%d)\n", bridge_channel, ast_getformatname(formats[1]), formats[1]);
+ ast_debug(1, "Bridge is returning %p to write format %s(%d)\n", bridge_channel, ast_getformatname(formats[1]), formats[1]);
if (ast_set_write_format(bridge_channel->chan, formats[1]))
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]);
}
@@ -518,12 +490,10 @@
/* Depending on the phase hangup the 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_debug(1, "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 state on bridge channel %p we are NOT hanging it up -- control returning to another thread\n", bridge_channel);
+ ast_debug(1, "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);
@@ -597,8 +567,7 @@
/* Poke it just in case... */
pthread_kill(bridge->thread, SIGURG);
- if (option_debug)
- ast_log(LOG_DEBUG, "We are going to attempt to depart bridge channel %p from bridge %p in a second...\n", bridge_channel, bridge);
+ ast_debug(1, "We are going to attempt to depart bridge channel %p from bridge %p in a second...\n", bridge_channel, bridge);
/* Once we let go of this lock everything is going to go wild with activity... */
ast_mutex_unlock(&bridge->lock);
@@ -606,8 +575,7 @@
/* Easy as pie, wait for the bridge channel thread to end */
pthread_join(thread, NULL);
- if (option_debug)
- ast_log(LOG_DEBUG, "Success! Bridge channel %p now belongs to this thread\n", bridge_channel);
+ ast_debug(1, "Success! Bridge channel %p now belongs to this thread\n", bridge_channel);
return 0;
}
More information about the asterisk-commits
mailing list