aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_meetme.c3
-rw-r--r--channel.c27
-rw-r--r--channels/chan_agent.c10
-rw-r--r--channels/chan_features.c3
-rw-r--r--channels/chan_h323.c5
-rw-r--r--channels/chan_mgcp.c3
-rw-r--r--channels/chan_sip.c7
-rw-r--r--frame.c16
-rw-r--r--include/asterisk/frame.h4
-rw-r--r--rtp.c32
-rw-r--r--udptl.c5
11 files changed, 51 insertions, 64 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 205b5ac4a..7fd41c26f 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -206,7 +206,6 @@ enum volume_action {
};
static int admin_exec(struct ast_channel *chan, void *data);
-static struct ast_frame null_frame = { AST_FRAME_NULL, };
static void *recordthread(void *args);
@@ -1574,7 +1573,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
if (conf->transpath[index]) {
conf->transframe[index] = ast_translate(conf->transpath[index], conf->origframe, 0);
if (!conf->transframe[index])
- conf->transframe[index] = &null_frame;
+ conf->transframe[index] = &ast_null_frame;
}
}
}
diff --git a/channel.c b/channel.c
index ee80b7d4a..38319c489 100644
--- a/channel.c
+++ b/channel.c
@@ -1760,17 +1760,13 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
void *data;
int res;
#endif
- static struct ast_frame null_frame = {
- AST_FRAME_NULL,
- };
-
ast_mutex_lock(&chan->lock);
if (chan->masq) {
if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
f = NULL;
} else
- f = &null_frame;
+ f = &ast_null_frame;
ast_mutex_unlock(&chan->lock);
return f;
}
@@ -1838,8 +1834,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->timingdata = NULL;
ast_mutex_unlock(&chan->lock);
}
- f = &null_frame;
- return f;
+ return &ast_null_frame;
} else
ast_log(LOG_NOTICE, "No/unknown event '%d' on timer for '%s'?\n", blah, chan->name);
} else
@@ -1851,8 +1846,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->generatordata = NULL; /* reset to let ast_write get through */
chan->generator->generate(chan, tmp, -1, -1);
chan->generatordata = tmp;
- f = &null_frame;
- return f;
+ return &ast_null_frame;
}
/* Check for pending read queue */
@@ -1872,7 +1866,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
f = chan->tech->exception(chan);
else {
ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name);
- f = &null_frame;
+ f = &ast_null_frame;
}
/* Clear the exception flag */
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
@@ -1898,7 +1892,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (f->subclass == AST_CONTROL_ANSWER) {
if (prestate == AST_STATE_UP) {
ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
- f = &null_frame;
+ f = &ast_null_frame;
}
/* Answer the CDR */
ast_setstate(chan, AST_STATE_UP);
@@ -1912,7 +1906,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->dtmfq[strlen(chan->dtmfq)] = f->subclass;
else
ast_log(LOG_WARNING, "Dropping deferred DTMF digits on %s\n", chan->name);
- f = &null_frame;
+ f = &ast_null_frame;
}
break;
case AST_FRAME_DTMF_BEGIN:
@@ -1924,14 +1918,14 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_FRAME_VOICE:
if (dropaudio) {
ast_frfree(f);
- f = &null_frame;
+ f = &ast_null_frame;
} else if (!(f->subclass & chan->nativeformats)) {
/* This frame can't be from the current native formats -- drop it on the
floor */
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats));
ast_frfree(f);
- f = &null_frame;
+ f = &ast_null_frame;
} else {
if (chan->spies)
queue_frame_to_spies(chan, f, SPY_READ);
@@ -1962,7 +1956,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (chan->readtrans) {
if (!(f = ast_translate(chan->readtrans, f, 1)))
- f = &null_frame;
+ f = &ast_null_frame;
}
/* Run any generator sitting on the channel */
@@ -3121,10 +3115,9 @@ int ast_do_masquerade(struct ast_channel *original)
);
ast_channel_free(clone);
} else {
- struct ast_frame null_frame = { AST_FRAME_NULL, };
ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE);
- ast_queue_frame(clone, &null_frame);
+ ast_queue_frame(clone, &ast_null_frame);
ast_mutex_unlock(&clone->lock);
}
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 3299aa02e..e99a6f483 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -438,7 +438,6 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
{
struct agent_pvt *p = ast->tech_pvt;
struct ast_frame *f = NULL;
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
const char *status;
ast_mutex_lock(&p->lock);
@@ -448,7 +447,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
p->chan->fdno = (ast->fdno == AST_AGENT_FD) ? AST_TIMING_FD : ast->fdno;
f = ast_read(p->chan);
} else
- f = &null_frame;
+ f = &ast_null_frame;
if (!f) {
/* If there's a channel, hang it up (if it's on a callback) make it NULL */
if (p->chan) {
@@ -486,7 +485,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name);
/* Don't pass answer along */
ast_frfree(f);
- f = &null_frame;
+ f = &ast_null_frame;
} else {
p->acknowledged = 1;
/* Use the builtin answer frame for the
@@ -513,7 +512,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
/* don't pass voice until the call is acknowledged */
if (!p->acknowledged) {
ast_frfree(f);
- f = &null_frame;
+ f = &ast_null_frame;
}
break;
}
@@ -899,7 +898,6 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct
static struct ast_channel *agent_new(struct agent_pvt *p, int state)
{
struct ast_channel *tmp;
- struct ast_frame null_frame = { AST_FRAME_NULL };
#if 0
if (!p->chan) {
ast_log(LOG_WARNING, "No channel? :(\n");
@@ -950,7 +948,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
if( ast_mutex_trylock(&p->app_lock) )
{
if (p->chan) {
- ast_queue_frame(p->chan, &null_frame);
+ ast_queue_frame(p->chan, &ast_null_frame);
ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */
ast_mutex_lock(&p->app_lock);
ast_mutex_lock(&p->lock);
diff --git a/channels/chan_features.c b/channels/chan_features.c
index 7eef2e990..5f6ff2ca6 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -241,12 +241,11 @@ static int features_answer(struct ast_channel *ast)
static struct ast_frame *features_read(struct ast_channel *ast)
{
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
struct feature_pvt *p = ast->tech_pvt;
struct ast_frame *f;
int x;
- f = &null_frame;
+ f = &ast_null_frame;
ast_mutex_lock(&p->lock);
x = indexof(p, ast, 0);
if (!x && p->subchan) {
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 43d7a2414..a4a9459b1 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -543,7 +543,6 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
{
/* Retrieve audio/etc from channel. Assumes pvt->lock is already held. */
struct ast_frame *f;
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
/* Only apply it for the first packet, we just need the correct ip/port */
if (pvt->options.nat) {
@@ -554,7 +553,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
f = ast_rtp_read(pvt->rtp);
/* Don't send RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && !(pvt->options.dtmfmode & H323_DTMF_RFC2833)) {
- return &null_frame;
+ return &ast_null_frame;
}
if (pvt->owner) {
/* We already hold the channel lock */
@@ -563,7 +562,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
/* Try to avoid deadlock */
if (ast_mutex_trylock(&pvt->owner->lock)) {
ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
- return &null_frame;
+ return &ast_null_frame;
}
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
pvt->owner->nativeformats = f->subclass;
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 845cfa9a1..65f614580 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -1219,12 +1219,11 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
{
/* Retrieve audio/etc from channel. Assumes sub->lock is already held. */
struct ast_frame *f;
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
f = ast_rtp_read(sub->rtp);
/* Don't send RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && !(sub->parent->dtmfmode & MGCP_DTMF_RFC2833))
- return &null_frame;
+ return &ast_null_frame;
if (sub->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index d0a8ed24b..3a1b36b1d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -3051,11 +3051,10 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
{
/* Retrieve audio/etc from channel. Assumes p->lock is already held. */
struct ast_frame *f;
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
if (!p->rtp) {
/* We have no RTP allocated for this channel */
- return &null_frame;
+ return &ast_null_frame;
}
switch(ast->fdno) {
@@ -3072,11 +3071,11 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
f = ast_rtcp_read(p->vrtp); /* RTCP Control Channel for video */
break;
default:
- f = &null_frame;
+ f = &ast_null_frame;
}
/* Don't forward RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && (ast_test_flag(p, SIP_DTMF) != SIP_DTMF_RFC2833))
- return &null_frame;
+ return &ast_null_frame;
if (p->owner) {
/* We already hold the channel lock */
diff --git a/frame.c b/frame.c
index 8c86a67f4..d640e0772 100644
--- a/frame.c
+++ b/frame.c
@@ -56,13 +56,6 @@ AST_MUTEX_DEFINE_STATIC(framelock);
#define TYPE_DONTSEND 0x3
#define TYPE_MASK 0x3
-struct ast_format_list {
- int visible; /*!< Can we see this entry */
- int bits; /*!< bitmask value */
- char *name; /*!< short name */
- char *desc; /*!< Description */
-};
-
struct ast_smoother {
int size;
int format;
@@ -79,7 +72,12 @@ struct ast_smoother {
};
/*! \brief Definition of supported media formats (codecs) */
-static struct ast_format_list AST_FORMAT_LIST[] = {
+static struct ast_format_list {
+ int visible; /*!< Can we see this entry */
+ int bits; /*!< bitmask value */
+ char *name; /*!< short name */
+ char *desc; /*!< Description */
+} AST_FORMAT_LIST[] = {
{ 1, AST_FORMAT_G723_1 , "g723" , "G.723.1"}, /*!< codec_g723_1.c */
{ 1, AST_FORMAT_GSM, "gsm" , "GSM"}, /*!< codec_gsm.c */
{ 1, AST_FORMAT_ULAW, "ulaw", "G.711 u-law" }, /*!< codec_ulaw.c */
@@ -108,6 +106,8 @@ static struct ast_format_list AST_FORMAT_LIST[] = {
{ 0, AST_FORMAT_MAX_VIDEO, "maxvideo", "Maximum video format" },
};
+struct ast_frame ast_null_frame = { AST_FRAME_NULL, };
+
void ast_smoother_reset(struct ast_smoother *s, int size)
{
memset(s, 0, sizeof(struct ast_smoother));
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index afdec0ae2..4835e1646 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -111,6 +111,10 @@ struct ast_frame {
struct ast_frame *next;
};
+/*! Queueing a null frame is fairly common, so we declare a global null frame object
+ for this purpose instead of having to declare one on the stack */
+extern struct ast_frame ast_null_frame;
+
#define AST_FRIENDLY_OFFSET 64 /*! It's polite for a a new frame to
have this number of bytes for additional
headers. */
diff --git a/rtp.c b/rtp.c
index e931c624e..e161529f6 100644
--- a/rtp.c
+++ b/rtp.c
@@ -174,7 +174,6 @@ void ast_rtp_setnat(struct ast_rtp *rtp, int nat)
static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
{
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
char iabuf[INET_ADDRSTRLEN];
if (ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) {
@@ -182,7 +181,7 @@ static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
rtp->resp = 0;
rtp->dtmfduration = 0;
- return &null_frame;
+ return &ast_null_frame;
}
if (option_debug)
ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
@@ -364,7 +363,6 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
{
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
socklen_t len;
int hdrlen = 8;
int res;
@@ -373,7 +371,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
char iabuf[INET_ADDRSTRLEN];
if (!rtp || !rtp->rtcp)
- return &null_frame;
+ return &ast_null_frame;
len = sizeof(sin);
@@ -385,12 +383,12 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
if (errno == EBADF)
CRASH;
- return &null_frame;
+ return &ast_null_frame;
}
if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short\n");
- return &null_frame;
+ return &ast_null_frame;
}
if (rtp->nat) {
@@ -404,7 +402,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
}
if (option_debug)
ast_log(LOG_DEBUG, "Got RTCP report of %d bytes\n", res);
- return &null_frame;
+ return &ast_null_frame;
}
static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark)
@@ -434,7 +432,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
char iabuf[INET_ADDRSTRLEN];
unsigned int timestamp;
unsigned int *rtpheader;
- static struct ast_frame *f, null_frame = { AST_FRAME_NULL, };
+ static struct ast_frame *f;
struct rtpPayloadType rtpPT;
len = sizeof(sin);
@@ -450,17 +448,17 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
if (errno == EBADF)
CRASH;
- return &null_frame;
+ return &ast_null_frame;
}
if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short\n");
- return &null_frame;
+ return &ast_null_frame;
}
/* Ignore if the other side hasn't been given an address
yet. */
if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
- return &null_frame;
+ return &ast_null_frame;
if (rtp->nat) {
/* Send to whoever sent to us */
@@ -480,7 +478,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
/* Check RTP version */
version = (seqno & 0xC0000000) >> 30;
if (version != 2)
- return &null_frame;
+ return &ast_null_frame;
payloadtype = (seqno & 0x7f0000) >> 16;
padding = seqno & (1 << 29);
@@ -502,7 +500,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short (%d, expecting %d)\n", res, hdrlen);
- return &null_frame;
+ return &ast_null_frame;
}
if(rtp_debug_test_addr(&sin))
@@ -537,7 +535,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (f)
return f;
else
- return &null_frame;
+ return &ast_null_frame;
} else if (rtpPT.code == AST_RTP_CISCO_DTMF) {
/* It's really special -- process it the Cisco way */
if (rtp->lasteventseqn <= seqno || rtp->resp == 0 || (rtp->lasteventseqn >= 65530 && seqno <= 6)) {
@@ -548,17 +546,17 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (f)
return f;
else
- return &null_frame;
+ return &ast_null_frame;
} else if (rtpPT.code == AST_RTP_CN) {
/* Comfort Noise */
f = process_rfc3389(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
if (f)
return f;
else
- return &null_frame;
+ return &ast_null_frame;
} else {
ast_log(LOG_NOTICE, "Unknown RTP codec %d received\n", payloadtype);
- return &null_frame;
+ return &ast_null_frame;
}
}
rtp->f.subclass = rtpPT.code;
diff --git a/udptl.c b/udptl.c
index 528ff4ace..d19bb89e2 100644
--- a/udptl.c
+++ b/udptl.c
@@ -645,7 +645,6 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
uint16_t seqno = 0;
char iabuf[INET_ADDRSTRLEN];
uint16_t *udptlheader;
- static struct ast_frame null_frame = { AST_FRAME_NULL, };
len = sizeof(sin);
@@ -662,12 +661,12 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
ast_log(LOG_WARNING, "UDPTL read error: %s\n", strerror(errno));
if (errno == EBADF)
CRASH;
- return &null_frame;
+ return &ast_null_frame;
}
/* Ignore if the other side hasn't been given an address yet. */
if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port)
- return &null_frame;
+ return &ast_null_frame;
if (udptl->nat) {
/* Send to whoever sent to us */