mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@41278 65c4cc65-6c06-0410-ace0-fbb531ad65f3
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2005, Anthony Minessale II
|
|
*
|
|
* Anthony Minessale <anthmct@yahoo.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
/*! \file
|
|
* \brief A machine to gather up arbitrary frames and convert them
|
|
* to raw slinear on demand.
|
|
*/
|
|
|
|
#ifndef _ASTERISK_SLINFACTORY_H
|
|
#define _ASTERISK_SLINFACTORY_H
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct ast_slinfactory {
|
|
AST_LIST_HEAD_NOLOCK(, ast_frame) queue;
|
|
struct ast_trans_pvt *trans;
|
|
short hold[1280];
|
|
short *offset;
|
|
size_t holdlen; /*!< in samples */
|
|
unsigned int size; /*!< in samples */
|
|
unsigned int format;
|
|
};
|
|
|
|
void ast_slinfactory_init(struct ast_slinfactory *sf);
|
|
void ast_slinfactory_destroy(struct ast_slinfactory *sf);
|
|
int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f);
|
|
int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples);
|
|
unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf);
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif /* _ASTERISK_SLINFACTORY_H */
|