summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-06-14 19:39:12 +0000
committerRussell Bryant <russell@russellbryant.com>2007-06-14 19:39:12 +0000
commit055d82cbce5ad588f4d612c49f56cd76f4c8bab6 (patch)
tree4fd144260e58c9a66d331fc81b46473723452479 /main/channel.c
parent60b029aa8275ef7da70281b3791a2837ffba7930 (diff)
Add a massive set of changes for converting to use the ast_debug() macro.
(issue #9957, patches from mvanbaak, caio1982, critch, and dimas) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@69327 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c223
1 files changed, 80 insertions, 143 deletions
diff --git a/main/channel.c b/main/channel.c
index dc99dfda9..86e4a92b9 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -433,8 +433,7 @@ int ast_channel_register(const struct ast_channel_tech *tech)
chan->tech = tech;
AST_LIST_INSERT_HEAD(&backends, chan, list);
- if (option_debug)
- ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
+ ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->tech->type,
@@ -449,8 +448,7 @@ void ast_channel_unregister(const struct ast_channel_tech *tech)
{
struct chanlist *chan;
- if (option_debug)
- ast_log(LOG_DEBUG, "Unregistering channel type '%s'\n", tech->type);
+ ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
AST_RWLIST_WRLOCK(&channels);
@@ -827,8 +825,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name);
CRASH;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
+ ast_debug(1, "Dropping voice to exceptionally long queue on %s\n", chan->name);
ast_frfree(f);
ast_channel_unlock(chan);
return 0;
@@ -974,14 +971,12 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
/* this is slightly unsafe, as we _should_ hold the lock to access c->name */
done = c == NULL || ast_channel_trylock(c) == 0;
if (!done) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
+ ast_debug(1, "Avoiding %s for channel '%p'\n", msg, c);
if (retries == 9) {
/* We are about to fail due to a deadlock, so report this
* while we still have the list lock.
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n", c, retries);
+ ast_debug(1, "Failure, could not lock '%p' after %d retries!\n", c, retries);
/* As we have deadlocked, we will skip this channel and
* see if there is another match.
* NOTE: No point doing this for a full-name match,
@@ -1329,9 +1324,8 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s added to channel %s\n",
- spy->type, chan->name);
+ ast_debug(1, "Spy %s added to channel %s\n",
+ spy->type, chan->name);
return 0;
}
@@ -1366,8 +1360,7 @@ static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan)
}
/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
+ ast_debug(1, "Spy %s removed from channel %s\n", spy->type, chan->name);
ast_mutex_unlock(&spy->lock);
@@ -1461,8 +1454,7 @@ static void detach_spies(struct ast_channel *chan)
/*! \brief Softly hangup a channel, don't lock */
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
{
- if (option_debug)
- ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
/* Inform channel driver that we need to be hung up, if it cares */
chan->_softhangup |= cause;
ast_queue_frame(chan, &ast_null_frame);
@@ -1512,8 +1504,7 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
trans->path = NULL;
}
if (!trans->path) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
+ ast_debug(1, "Building translator from %s to SLINEAR for spies on channel %s\n",
ast_getformatname(f->subclass), chan->name);
if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n",
@@ -1552,30 +1543,26 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
if (dir == SPY_WRITE) {
ast_set_flag(spy, CHANSPY_TRIGGER_WRITE);
ast_clear_flag(spy, CHANSPY_TRIGGER_READ);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to write-trigger mode\n",
- spy->type, chan->name);
+ ast_debug(1, "Switching spy '%s' on '%s' to write-trigger mode\n",
+ spy->type, chan->name);
}
break;
case CHANSPY_TRIGGER_WRITE:
if (dir == SPY_READ) {
ast_set_flag(spy, CHANSPY_TRIGGER_READ);
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to read-trigger mode\n",
- spy->type, chan->name);
+ ast_debug(1, "Switching spy '%s' on '%s' to read-trigger mode\n",
+ spy->type, chan->name);
}
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Triggering queue flush for spy '%s' on '%s'\n",
- spy->type, chan->name);
+ ast_debug(1, "Triggering queue flush for spy '%s' on '%s'\n",
+ spy->type, chan->name);
ast_set_flag(spy, CHANSPY_TRIGGER_FLUSH);
ast_cond_signal(&spy->trigger);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
- spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
+ ast_debug(1, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
+ spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
while (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) {
struct ast_frame *drop = AST_LIST_REMOVE_HEAD(&queue->list, frame_list);
queue->samples -= drop->samples;
@@ -1675,13 +1662,11 @@ int ast_hangup(struct ast_channel *chan)
CRASH;
}
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Hanging up channel '%s'\n", chan->name);
if (chan->tech->hangup)
res = chan->tech->hangup(chan);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name);
+ ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
}
ast_channel_unlock(chan);
@@ -1774,8 +1759,7 @@ static int generator_force(void *data)
res = generate(chan, tmp, 0, 160);
chan->generatordata = tmp;
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ ast_debug(1, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
return 0;
@@ -1994,8 +1978,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data),
samples = 0;
data = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
+ ast_debug(1, "Scheduling timer at %d sample intervals\n", samples);
res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples);
c->timingfunc = func;
c->timingdata = data;
@@ -2219,13 +2202,11 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_FRAME_CONTROL:
if (f->subclass == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
+ ast_debug(1, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
f = &ast_null_frame;
} else if (prestate == AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
+ ast_debug(1, "Dropping duplicate answer!\n");
ast_frfree(f);
f = &ast_null_frame;
} else {
@@ -2398,8 +2379,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
int res;
if (chan->timingfunc) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n");
+ ast_debug(2, "Generator got voice, switching to phase locked mode\n");
ast_settimeout(chan, 0, NULL, NULL);
}
@@ -2407,15 +2387,13 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
res = chan->generator->generate(chan, tmp, f->datalen, f->samples);
chan->generatordata = tmp;
if (res) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ ast_debug(2, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
} else if (f->frametype == AST_FRAME_CNG) {
if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Generator got CNG, switching to timed mode\n");
+ ast_debug(2, "Generator got CNG, switching to timed mode\n");
ast_settimeout(chan, 160, generator_force, chan);
}
}
@@ -2450,8 +2428,7 @@ done:
int ast_internal_timing_enabled(struct ast_channel *chan)
{
int ret = ast_opt_internal_timing && chan->timingfd > -1;
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
+ ast_debug(5, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
return ret;
}
@@ -2504,8 +2481,7 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data,
break;
}
if (ts && ts->data[0]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
+ ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
ast_playtones_start(chan,0,ts->data, 1);
res = 0;
} else if (condition == AST_CONTROL_PROGRESS) {
@@ -2618,8 +2594,7 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
return 0;
@@ -2655,8 +2630,7 @@ int ast_prod(struct ast_channel *chan)
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
+ ast_debug(1, "Prodding channel '%s'\n", chan->name);
a.subclass = chan->rawwriteformat;
a.data = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
@@ -2931,9 +2905,8 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
/* writing */
*trans = ast_translator_build_path(*rawformat, *format);
ast_channel_unlock(chan);
- if (option_debug)
- ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name,
- direction ? "write" : "read", ast_getformatname(fmt));
+ ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
+ direction ? "write" : "read", ast_getformatname(fmt));
return 0;
}
@@ -3332,9 +3305,8 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
- clone->name, original->name);
+ ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
+ clone->name, original->name);
if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->masq->name, original->name);
@@ -3346,8 +3318,7 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
clone->masqr = original;
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clone, &ast_null_frame);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
+ ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
res = 0;
}
@@ -3386,21 +3357,18 @@ void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_
newvar = ast_var_assign(&varname[1], ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
- if (option_debug)
- ast_log(LOG_DEBUG, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
+ ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
}
break;
case 2:
newvar = ast_var_assign(ast_var_full_name(current), ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
- if (option_debug)
- ast_log(LOG_DEBUG, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
+ ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Not copying variable %s.\n", ast_var_name(current));
+ ast_debug(1, "Not copying variable %s.\n", ast_var_name(current));
break;
}
}
@@ -3448,9 +3416,8 @@ int ast_do_masquerade(struct ast_channel *original)
char masqn[100];
char zombn[100];
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
- clone->name, clone->_state, original->name, original->_state);
+ ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
+ clone->name, clone->_state, original->name, original->_state);
manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n",
clone->name, ast_state2str(clone->_state), original->name, ast_state2str(original->_state));
@@ -3463,8 +3430,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* We need the clone's lock, too */
ast_channel_lock(clone);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
+ ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
/* Having remembered the original read/write formats, we turn off any translation on either
one */
@@ -3665,8 +3631,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Copy the music class */
ast_string_field_set(original, musicclass, clone->musicclass);
- if (option_debug)
- ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+ ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
@@ -3686,8 +3651,7 @@ int ast_do_masquerade(struct ast_channel *original)
a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */
if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
+ ast_debug(1, "Destroying channel clone '%s'\n", clone->name);
ast_channel_unlock(clone);
manager_event(EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n"
@@ -3701,8 +3665,7 @@ int ast_do_masquerade(struct ast_channel *original)
);
ast_channel_free(clone);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
+ ast_debug(1, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &ast_null_frame);
ast_channel_unlock(clone);
@@ -3711,8 +3674,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state);
+ ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state);
return 0;
}
@@ -3893,8 +3855,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if (!f) {
*fo = NULL;
*rc = who;
- if (option_debug)
- ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
+ ast_debug(1, "Didn't get a frame from channel: %s\n",who->name);
break;
}
@@ -3916,8 +3877,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*fo = f;
*rc = who;
bridge_exit = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
break;
}
if (bridge_exit)
@@ -3939,10 +3899,9 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
f->frametype == AST_FRAME_DTMF_BEGIN)) {
*fo = f;
*rc = who;
- if (option_debug)
- ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n",
- f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
- who->name);
+ ast_debug(1, "Got DTMF %s on channel (%s)\n",
+ f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
+ who->name);
break;
}
/* Write immediately frames, not passed through jb */
@@ -4110,8 +4069,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
c1->_softhangup = 0;
c0->_bridge = c1;
c1->_bridge = c0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n");
+ ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
continue;
}
@@ -4122,13 +4080,12 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (who)
*rc = who;
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
- c0->name, c1->name,
- ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c0) ? "Yes" : "No",
- ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c1) ? "Yes" : "No");
+ ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
+ c0->name, c1->name,
+ ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
+ ast_check_hangup(c0) ? "Yes" : "No",
+ ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
+ ast_check_hangup(c1) ? "Yes" : "No");
break;
}
@@ -4151,8 +4108,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
+ ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
@@ -4221,8 +4177,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
+ ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
return res;
}
@@ -4694,8 +4649,7 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha
ast_activate_generator(chan, &silence_generator, state);
- if (option_debug)
- ast_log(LOG_DEBUG, "Started silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Started silence generator on '%s'\n", chan->name);
return state;
}
@@ -4707,8 +4661,7 @@ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_sil
ast_deactivate_generator(chan);
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopped silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
if (ast_set_write_format(chan, state->old_write_format) < 0)
ast_log(LOG_ERROR, "Could not return write format to its original state\n");
@@ -4743,12 +4696,10 @@ const char *channelreloadreason2txt(enum channelreloadreason reason)
int ast_channel_unlock(struct ast_channel *chan)
{
int res = 0;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name);
+ ast_debug(3, "::::==== Unlocking AST channel %s\n", chan->name);
if (!chan) {
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
+ ast_debug(1, "::::==== Unlocking non-existing channel \n");
return 0;
}
@@ -4758,21 +4709,17 @@ int ast_channel_unlock(struct ast_channel *chan)
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
+ ast_debug(3, ":::=== Still have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was unlocked\n", chan->name);
if (res == EINVAL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
+ ast_debug(3, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
}
}
if (res == EPERM) {
/* We had no lock, so okay any way*/
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked at all \n", chan->name);
+ ast_debug(4, "::::==== Channel %s was not locked at all \n", chan->name);
res = 0;
}
return res;
@@ -4784,8 +4731,7 @@ int ast_channel_lock(struct ast_channel *chan)
{
int res;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name);
+ ast_debug(4, "====:::: Locking AST channel %s\n", chan->name);
res = ast_mutex_lock(&chan->lock);
@@ -4793,20 +4739,16 @@ int ast_channel_lock(struct ast_channel *chan)
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ ast_debug(4, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ ast_debug(4, "::::==== Channel %s was locked\n", chan->name);
if (res == EDEADLK) {
/* We had no lock, so okey any way */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
+ ast_debug(4, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
}
if (res == EINVAL) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
+ ast_debug(4, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
}
}
return res;
@@ -4818,8 +4760,7 @@ int ast_channel_trylock(struct ast_channel *chan)
{
int res;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "====:::: Trying to lock AST channel %s\n", chan->name);
+ ast_debug(3, "====:::: Trying to lock AST channel %s\n", chan->name);
res = ast_mutex_trylock(&chan->lock);
@@ -4827,24 +4768,20 @@ int ast_channel_trylock(struct ast_channel *chan)
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ ast_debug(3, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was locked\n", chan->name);
if (res == EBUSY) {
/* We failed to lock */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
+ ast_debug(3, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
}
if (res == EDEADLK) {
/* We had no lock, so okey any way*/
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
}
- if (res == EINVAL && option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
+ if (res == EINVAL)
+ ast_debug(3, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
}
return res;
}