aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_milliwatt.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-29 20:50:36 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-29 20:50:36 +0000
commit53f8d43e2945038fe3059fd6c1c00dd4ec117505 (patch)
tree0f3fc04bcb07ac328d54ffb2fed0333dfffb44de /apps/app_milliwatt.c
parent562decf81af443d24afd3f1fc3d133b8b2b7cee3 (diff)
Merge team/russell/frame_caching
There are some situations in Asterisk where ast_frame and/or iax_frame structures are rapidly allocatted and freed (at least 50 times per second for one call). This code significantly improves the performance of ast_frame_header_new(), ast_frdup(), ast_frfree(), iax_frame_new(), and iax_frame_free() by keeping a thread-local cache of these structures and using frames from the cache whenever possible instead of calling malloc/free every time. This commit also converts the ast_frame and iax_frame structures to use the linked list macros. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41278 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_milliwatt.c')
-rw-r--r--apps/app_milliwatt.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c
index 08a96f96b..8b0456014 100644
--- a/apps/app_milliwatt.c
+++ b/apps/app_milliwatt.c
@@ -66,10 +66,16 @@ static void milliwatt_release(struct ast_channel *chan, void *data)
static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int samples)
{
- struct ast_frame wf;
unsigned char buf[AST_FRIENDLY_OFFSET + 640];
const int maxsamples = sizeof (buf) / sizeof (buf[0]);
int i, *indexp = (int *) data;
+ struct ast_frame wf = {
+ .frametype = AST_FRAME_VOICE,
+ .subclass = AST_FORMAT_ULAW,
+ .offset = AST_FRIENDLY_OFFSET,
+ .data = buf + AST_FRIENDLY_OFFSET,
+ .src = __FUNCTION__,
+ };
/* Instead of len, use samples, because channel.c generator_force
* generate(chan, tmp, 0, 160) ignores len. In any case, len is
@@ -82,17 +88,8 @@ static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int
samples = maxsamples;
}
len = samples * sizeof (buf[0]);
- wf.frametype = AST_FRAME_VOICE;
- wf.subclass = AST_FORMAT_ULAW;
- wf.offset = AST_FRIENDLY_OFFSET;
- wf.mallocd = 0;
- wf.data = buf + AST_FRIENDLY_OFFSET;
wf.datalen = len;
wf.samples = samples;
- wf.src = "app_milliwatt";
- wf.delivery.tv_sec = 0;
- wf.delivery.tv_usec = 0;
- wf.prev = wf.next = NULL;
/* create a buffer containing the digital milliwatt pattern */
for(i = 0; i < len; i++)
{