summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2013-10-03 14:58:16 +0000
committerMark Michelson <mmichelson@digium.com>2013-10-03 14:58:16 +0000
commitee21eee7e067573ad83bd0df492036094b4dbaca (patch)
tree024e25a92079bc7e5348bd55cc29eff2f3c38dec /channels/chan_iax2.c
parentc977f73e136eca1f2aaccd0ea0fe45c350906374 (diff)
Cache string values of formats on ast_format_cap() to save processing.
Channel snapshots have string representations of the channel's native formats. Prior to this change, the format strings were re-created on ever channel snapshot creation. Since channel native formats rarely change, this was very wasteful. Now, string representations of formats may optionally be stored on the ast_format_cap for cases where string representations may be requested frequently. When formats are altered, the string cache is marked as invalid. When strings are requested, the cache validity is checked. If the cache is valid, then the cached strings are copied. If the cache is invalid, then the string cache is rebuilt and copied, and the cache is marked as being valid again. Review: https://reviewboard.asterisk.org/r/2879 ........ Merged revisions 400356 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400363 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 551c2046d..77fd44277 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1717,7 +1717,7 @@ static iax2_format iax2_codec_choose(struct ast_codec_pref *pref, iax2_format fo
struct ast_format_cap *cap;
struct ast_format tmpfmt;
iax2_format format = 0;
- if ((cap = ast_format_cap_alloc_nolock())) {
+ if ((cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
ast_format_clear(&tmpfmt);
ast_format_cap_from_old_bitfield(cap, formats);
ast_codec_choose(pref, cap, find_best, &tmpfmt);
@@ -1730,7 +1730,7 @@ static iax2_format iax2_codec_choose(struct ast_codec_pref *pref, iax2_format fo
static iax2_format iax2_best_codec(iax2_format formats)
{
- struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
struct ast_format tmpfmt;
if (!cap) {
return 0;
@@ -1755,7 +1755,7 @@ const char *iax2_getformatname(iax2_format format)
static char *iax2_getformatname_multiple(char *codec_buf, size_t len, iax2_format format)
{
- struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap) {
return "(Nothing)";
@@ -1770,7 +1770,7 @@ static char *iax2_getformatname_multiple(char *codec_buf, size_t len, iax2_forma
static int iax2_parse_allow_disallow(struct ast_codec_pref *pref, iax2_format *formats, const char *list, int allowing)
{
int res;
- struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap) {
return 1;
}
@@ -1786,7 +1786,7 @@ static int iax2_parse_allow_disallow(struct ast_codec_pref *pref, iax2_format *f
static int iax2_data_add_codecs(struct ast_data *root, const char *node_name, iax2_format formats)
{
int res;
- struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap) {
return -1;
}
@@ -14624,7 +14624,7 @@ static int load_module(void)
int x = 0;
struct iax2_registry *reg = NULL;
- if (!(iax2_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(iax2_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add_all(iax2_tech.capabilities);