mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 19:28:53 +00:00
Merged revisions 49457,49460-49461 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49457 | kpfleming | 2007-01-04 12:05:47 -0600 (Thu, 04 Jan 2007) | 2 lines make building of codec_gsm against the system GSM library actually work ........ r49460 | kpfleming | 2007-01-04 12:16:40 -0600 (Thu, 04 Jan 2007) | 2 lines don't define this type either if LOW_MEMORY is enabled ........ r49461 | kpfleming | 2007-01-04 12:17:01 -0600 (Thu, 04 Jan 2007) | 2 lines don't do frame header caching in the core if LOW_MEMORY is defined ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49463 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -55,11 +55,11 @@ static void frame_cache_cleanup(void *data);
|
|||||||
|
|
||||||
/*! \brief A per-thread cache of iax_frame structures */
|
/*! \brief A per-thread cache of iax_frame structures */
|
||||||
AST_THREADSTORAGE_CUSTOM(frame_cache, NULL, frame_cache_cleanup);
|
AST_THREADSTORAGE_CUSTOM(frame_cache, NULL, frame_cache_cleanup);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*! \brief This is just so iax_frames, a list head struct for holding a list of
|
/*! \brief This is just so iax_frames, a list head struct for holding a list of
|
||||||
* iax_frame structures, is defined. */
|
* iax_frame structures, is defined. */
|
||||||
AST_LIST_HEAD_NOLOCK(iax_frames, iax_frame);
|
AST_LIST_HEAD_NOLOCK(iax_frames, iax_frame);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void internaloutput(const char *str)
|
static void internaloutput(const char *str)
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,7 @@ all: _all
|
|||||||
|
|
||||||
include $(ASTTOPDIR)/Makefile.moddir_rules
|
include $(ASTTOPDIR)/Makefile.moddir_rules
|
||||||
|
|
||||||
ifneq ($(GSM_INTERNAL),)
|
ifneq ($(GSM_INTERNAL),no)
|
||||||
GSM_INCLUDE:=-Igsm/inc
|
GSM_INCLUDE:=-Igsm/inc
|
||||||
$(if $(filter codec_gsm,$(EMBEDDED_MODS)),modules.link,codec_gsm.so): gsm/lib/libgsm.a
|
$(if $(filter codec_gsm,$(EMBEDDED_MODS)),modules.link,codec_gsm.so): gsm/lib/libgsm.a
|
||||||
endif
|
endif
|
||||||
|
17
main/frame.c
17
main/frame.c
@@ -49,6 +49,7 @@ static int headers;
|
|||||||
static AST_LIST_HEAD_STATIC(headerlist, ast_frame);
|
static AST_LIST_HEAD_STATIC(headerlist, ast_frame);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
static void frame_cache_cleanup(void *data);
|
static void frame_cache_cleanup(void *data);
|
||||||
|
|
||||||
/*! \brief A per-thread cache of frame headers */
|
/*! \brief A per-thread cache of frame headers */
|
||||||
@@ -73,6 +74,7 @@ struct ast_frame_cache {
|
|||||||
struct ast_frames list;
|
struct ast_frames list;
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SMOOTHER_SIZE 8000
|
#define SMOOTHER_SIZE 8000
|
||||||
|
|
||||||
@@ -288,6 +290,8 @@ void ast_smoother_free(struct ast_smoother *s)
|
|||||||
static struct ast_frame *ast_frame_header_new(void)
|
static struct ast_frame *ast_frame_header_new(void)
|
||||||
{
|
{
|
||||||
struct ast_frame *f;
|
struct ast_frame *f;
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
struct ast_frame_cache *frames;
|
struct ast_frame_cache *frames;
|
||||||
|
|
||||||
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
|
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
|
||||||
@@ -300,6 +304,7 @@ static struct ast_frame *ast_frame_header_new(void)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!(f = ast_calloc_cache(1, sizeof(*f))))
|
if (!(f = ast_calloc_cache(1, sizeof(*f))))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -315,6 +320,7 @@ static struct ast_frame *ast_frame_header_new(void)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
static void frame_cache_cleanup(void *data)
|
static void frame_cache_cleanup(void *data)
|
||||||
{
|
{
|
||||||
struct ast_frame_cache *frames = data;
|
struct ast_frame_cache *frames = data;
|
||||||
@@ -325,12 +331,14 @@ static void frame_cache_cleanup(void *data)
|
|||||||
|
|
||||||
free(frames);
|
free(frames);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void ast_frame_free(struct ast_frame *fr, int cache)
|
void ast_frame_free(struct ast_frame *fr, int cache)
|
||||||
{
|
{
|
||||||
if (!fr->mallocd)
|
if (!fr->mallocd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
if (cache && fr->mallocd == AST_MALLOCD_HDR) {
|
if (cache && fr->mallocd == AST_MALLOCD_HDR) {
|
||||||
/* Cool, only the header is malloc'd, let's just cache those for now
|
/* Cool, only the header is malloc'd, let's just cache those for now
|
||||||
* to keep things simple... */
|
* to keep things simple... */
|
||||||
@@ -343,6 +351,7 @@ void ast_frame_free(struct ast_frame *fr, int cache)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fr->mallocd & AST_MALLOCD_DATA) {
|
if (fr->mallocd & AST_MALLOCD_DATA) {
|
||||||
if (fr->data)
|
if (fr->data)
|
||||||
@@ -426,11 +435,14 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
|
|||||||
|
|
||||||
struct ast_frame *ast_frdup(const struct ast_frame *f)
|
struct ast_frame *ast_frdup(const struct ast_frame *f)
|
||||||
{
|
{
|
||||||
struct ast_frame_cache *frames;
|
|
||||||
struct ast_frame *out = NULL;
|
struct ast_frame *out = NULL;
|
||||||
int len, srclen = 0;
|
int len, srclen = 0;
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
|
struct ast_frame_cache *frames;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Start with standard stuff */
|
/* Start with standard stuff */
|
||||||
len = sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
|
len = sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
|
||||||
/* If we have a source, add space for it */
|
/* If we have a source, add space for it */
|
||||||
@@ -443,6 +455,7 @@ struct ast_frame *ast_frdup(const struct ast_frame *f)
|
|||||||
if (srclen > 0)
|
if (srclen > 0)
|
||||||
len += srclen + 1;
|
len += srclen + 1;
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
|
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
|
AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
|
||||||
if (out->mallocd_hdr_len >= len) {
|
if (out->mallocd_hdr_len >= len) {
|
||||||
@@ -457,6 +470,8 @@ struct ast_frame *ast_frdup(const struct ast_frame *f)
|
|||||||
}
|
}
|
||||||
AST_LIST_TRAVERSE_SAFE_END
|
AST_LIST_TRAVERSE_SAFE_END
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
if (!(buf = ast_calloc_cache(1, len)))
|
if (!(buf = ast_calloc_cache(1, len)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user