dect
/
asterisk
Archived
13
0
Fork 0

minor formatting cleanup and removal of trailing whitespace.

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@17863 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
rizzo 2006-04-06 15:40:12 +00:00
parent 2200466f93
commit 5d1a483bbb
1 changed files with 129 additions and 165 deletions

View File

@ -298,22 +298,15 @@ static struct ast_cli_entry cli_show_channeltype =
/*! \brief Checks to see if a channel is needing hang up */
int ast_check_hangup(struct ast_channel *chan)
{
time_t myt;
/* if soft hangup flag, return true */
if (chan->_softhangup)
if (chan->_softhangup) /* yes if soft hangup flag set */
return 1;
/* if no technology private data, return true */
if (!chan->tech_pvt)
if (!chan->tech_pvt) /* yes if no technology private data */
return 1;
/* if no hangup scheduled, just return here */
if (!chan->whentohangup)
if (!chan->whentohangup) /* no if no hangup scheduled */
return 0;
time(&myt); /* get current time */
/* return, if not yet */
if (chan->whentohangup > myt)
if (chan->whentohangup > time(NULL)) /* no if hangup time has not come yet. */
return 0;
chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */
return 1;
}
@ -366,15 +359,8 @@ int ast_shutting_down(void)
/*! \brief Set when to hangup channel */
void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset)
{
time_t myt;
struct ast_frame fr = { AST_FRAME_NULL, };
time(&myt);
if (offset)
chan->whentohangup = myt + offset;
else
chan->whentohangup = 0;
ast_queue_frame(chan, &fr);
chan->whentohangup = offset ? time(NULL) + offset : 0;
ast_queue_frame(chan, &ast_null_frame);
return;
}
@ -384,12 +370,9 @@ int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset)
time_t whentohangup;
if (chan->whentohangup == 0) {
if (offset == 0)
return (0);
else
return (-1);
return (offset == 0) ? 0 : -1;
} else {
if (offset == 0)
if (offset == 0) /* XXX why is this special ? */
return (1);
else {
whentohangup = offset + time (NULL);
@ -486,9 +469,10 @@ const char *ast_cause2str(int cause)
{
int x;
for (x=0; x < sizeof(causes) / sizeof(causes[0]); x++)
for (x=0; x < sizeof(causes) / sizeof(causes[0]); x++) {
if (causes[x].cause == cause)
return causes[x].desc;
}
return "Unknown";
}
@ -598,16 +582,14 @@ struct ast_channel *ast_channel_alloc(int needqueue)
int flags;
struct varshead *headp;
/* If shutting down, don't allocate any new channels */
if (shutting_down) {
ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n");
return NULL;
}
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
if (!(tmp = ast_calloc(1, sizeof(*tmp))))
return NULL;
}
if (!(tmp->sched = sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
@ -647,8 +629,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
flags = fcntl(tmp->alertpipe[1], F_GETFL);
fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK);
}
} else
/* Make sure we've got it done right if they don't */
} else /* Make sure we've got it done right if they don't */
tmp->alertpipe[0] = tmp->alertpipe[1] = -1;
/* Always watch the alertpipe */
@ -1150,17 +1131,15 @@ 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)
{
int res = 0;
struct ast_frame f = { AST_FRAME_NULL };
if (option_debug)
ast_log(LOG_DEBUG, "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, &f);
ast_queue_frame(chan, &ast_null_frame);
/* Interrupt any poll call or such */
if (ast_test_flag(chan, AST_FLAG_BLOCKING))
pthread_kill(chan->blocker, SIGURG);
return res;
return 0;
}
/*! \brief Softly hangup a channel, lock */
@ -3736,10 +3715,7 @@ int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int durat
d.freq1 = freq1;
d.freq2 = freq2;
d.duration = duration;
if (vol < 1)
d.vol = 8192;
else
d.vol = vol;
d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
if (ast_activate_generator(chan, &tonepair, &d))
return -1;
return 0;
@ -3752,15 +3728,14 @@ void ast_tonepair_stop(struct ast_channel *chan)
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
{
struct ast_frame *f;
int res;
if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
return res;
/* Give us some wiggle room */
while (chan->generatordata && (ast_waitfor(chan, 100) >= 0)) {
f = ast_read(chan);
while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
struct ast_frame *f = ast_read(chan);
if (f)
ast_frfree(f);
else
@ -4032,19 +4007,6 @@ static void silence_generator_release(struct ast_channel *chan, void *data)
static int silence_generator_generate(struct ast_channel *chan, void *data, int len, int samples)
{
if (samples == 160) {
short buf[160] = { 0, };
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
.subclass = AST_FORMAT_SLINEAR,
.data = buf,
.samples = 160,
.datalen = sizeof(buf),
};
if (ast_write(chan, &frame))
return -1;
} else {
short buf[samples];
int x;
struct ast_frame frame = {
@ -4060,7 +4022,6 @@ static int silence_generator_generate(struct ast_channel *chan, void *data, int
if (ast_write(chan, &frame))
return -1;
}
return 0;
}
@ -4117,16 +4078,19 @@ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_sil
/*! \ brief Convert channel reloadreason (ENUM) to text string for manager event */
const char *channelreloadreason2txt(enum channelreloadreason reason) {
const char *channelreloadreason2txt(enum channelreloadreason reason)
{
switch (reason) {
case CHANNEL_MODULE_LOAD: return "LOAD (Channel module load)";
break;
case CHANNEL_MODULE_RELOAD: return "RELOAD (Channel module reload)";
break;
case CHANNEL_CLI_RELOAD: return "CLIRELOAD (Channel module reload by CLI command)";
break;
default: return "MANAGERRELOAD (Channel module reload by manager)";
break;
case CHANNEL_MODULE_LOAD:
return "LOAD (Channel module load)";
case CHANNEL_MODULE_RELOAD:
return "RELOAD (Channel module reload)";
case CHANNEL_CLI_RELOAD:
return "CLIRELOAD (Channel module reload by CLI command)";
default:
return "MANAGERRELOAD (Channel module reload by manager)";
}
};