minor formatting cleanup and removal of trailing whitespace.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17863 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Luigi Rizzo 20 years ago
parent 8e22245b09
commit 5d34c2bbe1

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

Loading…
Cancel
Save