mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-21 12:54:56 +00:00
remove some duplicated code (issue #6098)
Also, touch up some formatting git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7691 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
23
channel.c
23
channel.c
@@ -808,16 +808,15 @@ struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Wait, look for hangups and condition arg */
|
/*! \brief Wait, look for hangups and condition arg */
|
||||||
int ast_safe_sleep_conditional( struct ast_channel *chan, int ms,
|
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data)
|
||||||
int (*cond)(void*), void *data )
|
|
||||||
{
|
{
|
||||||
struct ast_frame *f;
|
struct ast_frame *f;
|
||||||
|
|
||||||
while(ms > 0) {
|
while (ms > 0) {
|
||||||
if( cond && ((*cond)(data) == 0 ) )
|
if (cond && ((*cond)(data) == 0))
|
||||||
return 0;
|
return 0;
|
||||||
ms = ast_waitfor(chan, ms);
|
ms = ast_waitfor(chan, ms);
|
||||||
if (ms <0)
|
if (ms < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (ms > 0) {
|
if (ms > 0) {
|
||||||
f = ast_read(chan);
|
f = ast_read(chan);
|
||||||
@@ -832,19 +831,7 @@ int ast_safe_sleep_conditional( struct ast_channel *chan, int ms,
|
|||||||
/*! \brief Wait, look for hangups */
|
/*! \brief Wait, look for hangups */
|
||||||
int ast_safe_sleep(struct ast_channel *chan, int ms)
|
int ast_safe_sleep(struct ast_channel *chan, int ms)
|
||||||
{
|
{
|
||||||
struct ast_frame *f;
|
return ast_safe_sleep_conditional(chan, ms, NULL, NULL);
|
||||||
while(ms > 0) {
|
|
||||||
ms = ast_waitfor(chan, ms);
|
|
||||||
if (ms <0)
|
|
||||||
return -1;
|
|
||||||
if (ms > 0) {
|
|
||||||
f = ast_read(chan);
|
|
||||||
if (!f)
|
|
||||||
return -1;
|
|
||||||
ast_frfree(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_cid(struct ast_callerid *cid)
|
static void free_cid(struct ast_callerid *cid)
|
||||||
|
Reference in New Issue
Block a user