diff options
author | Mark Michelson <mmichelson@digium.com> | 2013-10-03 14:58:16 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2013-10-03 14:58:16 +0000 |
commit | ee21eee7e067573ad83bd0df492036094b4dbaca (patch) | |
tree | 024e25a92079bc7e5348bd55cc29eff2f3c38dec /res | |
parent | c977f73e136eca1f2aaccd0ea0fe45c350906374 (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 'res')
-rw-r--r-- | res/ari/resource_bridges.c | 2 | ||||
-rw-r--r-- | res/parking/parking_applications.c | 2 | ||||
-rw-r--r-- | res/res_agi.c | 2 | ||||
-rw-r--r-- | res/res_clioriginate.c | 4 | ||||
-rw-r--r-- | res/res_pjsip/pjsip_configuration.c | 2 | ||||
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 6 | ||||
-rw-r--r-- | res/res_pjsip_session.c | 4 | ||||
-rw-r--r-- | res/res_stasis.c | 2 |
8 files changed, 12 insertions, 12 deletions
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c index ef7767f71..77d5660ca 100644 --- a/res/ari/resource_bridges.c +++ b/res/ari/resource_bridges.c @@ -276,7 +276,7 @@ static struct ast_channel *prepare_bridge_media_channel(const char *type) RAII_VAR(struct ast_format_cap *, cap, NULL, ast_format_cap_destroy); struct ast_format format; - cap = ast_format_cap_alloc_nolock(); + cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); if (!cap) { return NULL; } diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c index 7bd892266..2d481e421 100644 --- a/res/parking/parking_applications.c +++ b/res/parking/parking_applications.c @@ -687,7 +687,7 @@ static void announce_to_dial(char *dial_string, char *announce_string, int parki struct ast_channel *dchan; struct outgoing_helper oh = { 0, }; int outstate; - struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock(); + struct ast_format_cap *cap_slin = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); char buf[13]; char *dial_tech; char *cur_announce; diff --git a/res/res_agi.c b/res/res_agi.c index 84dcbebe9..e69a24cc1 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -3025,7 +3025,7 @@ static int handle_speechcreate(struct ast_channel *chan, AGI *agi, int argc, con return RESULT_SUCCESS; } - if (!(cap = ast_format_cap_alloc_nolock())) { + if (!(cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) { return RESULT_FAILURE; } ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0)); diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c index 42030d798..0d639c77d 100644 --- a/res/res_clioriginate.c +++ b/res/res_clioriginate.c @@ -70,7 +70,7 @@ static char *orig_app(int fd, const char *chan, const char *app, const char *app return CLI_SHOWUSAGE; } - if (!(cap = ast_format_cap_alloc_nolock())) { + if (!(cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) { return CLI_FAILURE; } ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0)); @@ -115,7 +115,7 @@ static char *orig_exten(int fd, const char *chan, const char *data) exten = "s"; if (ast_strlen_zero(context)) context = "default"; - if (!(cap = ast_format_cap_alloc_nolock())) { + if (!(cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) { return CLI_FAILURE; } ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0)); diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index c0a6acc4a..151ab1016 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -832,7 +832,7 @@ void *ast_sip_endpoint_alloc(const char *name) ao2_cleanup(endpoint); return NULL; } - if (!(endpoint->media.codecs = ast_format_cap_alloc_nolock())) { + if (!(endpoint->media.codecs = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) { ao2_cleanup(endpoint); return NULL; } diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 57c673e0c..a2dda373f 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -205,8 +205,8 @@ static int set_caps(struct ast_sip_session *session, struct ast_sip_session_medi int direct_media_enabled = !ast_sockaddr_isnull(&session_media->direct_media_addr) && !ast_format_cap_is_empty(session->direct_media_cap); - if (!(caps = ast_format_cap_alloc_nolock()) || - !(peer = ast_format_cap_alloc_nolock())) { + if (!(caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK)) || + !(peer = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) { ast_log(LOG_ERROR, "Failed to allocate %s capabilities\n", session_media->stream_type); return -1; } @@ -910,7 +910,7 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as /* Add ICE attributes and candidates */ add_ice_to_stream(session, session_media, pool, media); - if (!(caps = ast_format_cap_alloc_nolock())) { + if (!(caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) { ast_log(LOG_ERROR, "Failed to allocate %s capabilities\n", session_media->stream_type); return -1; } diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 9cb85dcf0..07ccd0ce2 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -1123,7 +1123,7 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, ao2_ref(endpoint, +1); session->endpoint = endpoint; session->inv_session = inv_session; - session->req_caps = ast_format_cap_alloc_nolock(); + session->req_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); if (endpoint->dtmf == AST_SIP_DTMF_INBAND) { dsp_features |= DSP_FEATURE_DIGIT_DETECT; @@ -1151,7 +1151,7 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, iter->session_begin(session); } } - session->direct_media_cap = ast_format_cap_alloc_nolock(); + session->direct_media_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); AST_LIST_HEAD_INIT_NOLOCK(&session->delayed_requests); ast_party_id_init(&session->id); ao2_ref(session, +1); diff --git a/res/res_stasis.c b/res/res_stasis.c index ab2bf5c86..197022e72 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -321,7 +321,7 @@ static struct ast_channel *prepare_bridge_moh_channel(void) RAII_VAR(struct ast_format_cap *, cap, NULL, ast_format_cap_destroy); struct ast_format format; - cap = ast_format_cap_alloc_nolock(); + cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); if (!cap) { return NULL; } |