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



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400356 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2013-10-02 22:34:05 +00:00
parent e8dd0da34b
commit 23cea9e44b
51 changed files with 230 additions and 196 deletions

View File

@@ -1018,7 +1018,7 @@ int ast_local_init(void)
return -1;
}
if (!(local_tech.capabilities = ast_format_cap_alloc())) {
if (!(local_tech.capabilities = ast_format_cap_alloc(0))) {
return -1;
}
ast_format_cap_add_all(local_tech.capabilities);