summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/chan_mobile.c2
-rw-r--r--addons/chan_ooh323.c10
-rw-r--r--apps/app_confbridge.c6
-rw-r--r--apps/app_meetme.c4
-rw-r--r--apps/app_originate.c2
-rw-r--r--bridges/bridge_holding.c2
-rw-r--r--bridges/bridge_native_rtp.c10
-rw-r--r--bridges/bridge_simple.c2
-rw-r--r--bridges/bridge_softmix.c2
-rw-r--r--channels/chan_alsa.c2
-rw-r--r--channels/chan_bridge_media.c4
-rw-r--r--channels/chan_console.c2
-rw-r--r--channels/chan_dahdi.c2
-rw-r--r--channels/chan_gtalk.c14
-rw-r--r--channels/chan_h323.c6
-rw-r--r--channels/chan_iax2.c12
-rw-r--r--channels/chan_jingle.c14
-rw-r--r--channels/chan_mgcp.c10
-rw-r--r--channels/chan_misdn.c4
-rw-r--r--channels/chan_motif.c10
-rw-r--r--channels/chan_multicast_rtp.c2
-rw-r--r--channels/chan_nbs.c2
-rw-r--r--channels/chan_oss.c2
-rw-r--r--channels/chan_phone.c6
-rw-r--r--channels/chan_pjsip.c2
-rw-r--r--channels/chan_sip.c32
-rw-r--r--channels/chan_skinny.c14
-rw-r--r--channels/chan_unistim.c6
-rw-r--r--channels/dahdi/bridge_native_dahdi.c2
-rw-r--r--include/asterisk/format_cap.h35
-rw-r--r--main/bridge_basic.c4
-rw-r--r--main/ccss.c2
-rw-r--r--main/channel.c10
-rw-r--r--main/core_local.c2
-rw-r--r--main/dial.c2
-rw-r--r--main/file.c4
-rw-r--r--main/format_cap.c111
-rw-r--r--main/manager.c2
-rw-r--r--main/media_index.c2
-rw-r--r--main/rtp_engine.c8
-rw-r--r--pbx/pbx_spool.c2
-rw-r--r--res/ari/resource_bridges.c2
-rw-r--r--res/parking/parking_applications.c2
-rw-r--r--res/res_agi.c2
-rw-r--r--res/res_clioriginate.c4
-rw-r--r--res/res_pjsip/pjsip_configuration.c2
-rw-r--r--res/res_pjsip_sdp_rtp.c6
-rw-r--r--res/res_pjsip_session.c4
-rw-r--r--res/res_stasis.c2
-rw-r--r--tests/test_config.c6
-rw-r--r--tests/test_format_api.c24
51 files changed, 230 insertions, 196 deletions
diff --git a/addons/chan_mobile.c b/addons/chan_mobile.c
index f5d5b4e1a..2cf7c7dbd 100644
--- a/addons/chan_mobile.c
+++ b/addons/chan_mobile.c
@@ -4705,7 +4705,7 @@ static int load_module(void)
int dev_id, s;
- if (!(mbl_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(mbl_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_set(&prefformat, DEVICE_FRAME_FORMAT, 0);
diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c
index 303b06857..f374a216b 100644
--- a/addons/chan_ooh323.c
+++ b/addons/chan_ooh323.c
@@ -521,7 +521,7 @@ static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken)
ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
return NULL;
}
- if (!(pvt->cap = ast_format_cap_alloc_nolock())) {
+ if (!(pvt->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
ast_free(pvt);
ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
return NULL;
@@ -2304,7 +2304,7 @@ static struct ooh323_user *build_user(const char *name, struct ast_variable *v)
user = ast_calloc(1,sizeof(struct ooh323_user));
if (user) {
memset(user, 0, sizeof(struct ooh323_user));
- if (!(user->cap = ast_format_cap_alloc())) {
+ if (!(user->cap = ast_format_cap_alloc(0))) {
ast_free(user);
return NULL;
}
@@ -2452,7 +2452,7 @@ static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v,
peer = ast_calloc(1, sizeof(*peer));
if (peer) {
memset(peer, 0, sizeof(struct ooh323_peer));
- if (!(peer->cap = ast_format_cap_alloc())) {
+ if (!(peer->cap = ast_format_cap_alloc(0))) {
ast_free(peer);
return NULL;
}
@@ -3677,10 +3677,10 @@ static int load_module(void)
.onModeChanged = onModeChanged,
.onMediaChanged = (cb_OnMediaChanged) setup_rtp_remote,
};
- if (!(gCap = ast_format_cap_alloc())) {
+ if (!(gCap = ast_format_cap_alloc(0))) {
return 1;
}
- if (!(ooh323_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(ooh323_tech.capabilities = ast_format_cap_alloc(0))) {
return 1;
}
ast_format_cap_add(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index d9db7ab5b..47cfa0b8b 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -662,7 +662,7 @@ static int conf_start_record(struct confbridge_conference *conference)
return -1;
}
- cap = ast_format_cap_alloc_nolock();
+ cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap) {
return -1;
}
@@ -1327,7 +1327,7 @@ static int alloc_playback_chan(struct confbridge_conference *conference)
struct ast_format_cap *cap;
struct ast_format format;
- cap = ast_format_cap_alloc_nolock();
+ cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap) {
return -1;
}
@@ -3094,7 +3094,7 @@ static void unregister_channel_tech(struct ast_channel_tech *tech)
*/
static int register_channel_tech(struct ast_channel_tech *tech)
{
- tech->capabilities = ast_format_cap_alloc();
+ tech->capabilities = ast_format_cap_alloc(0);
if (!tech->capabilities) {
return -1;
}
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index cd6a4f72c..ffd55e70d 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -1611,7 +1611,7 @@ static struct ast_conference *build_conf(const char *confno, const char *pin,
struct ast_conference *cnf;
struct dahdi_confinfo dahdic = { 0, };
int confno_int = 0;
- 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);
struct ast_format tmp_fmt;
AST_LIST_LOCK(&confs);
@@ -3216,7 +3216,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
int setusercount = 0;
int confsilence = 0, totalsilence = 0;
char *mailbox, *context;
- 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);
struct ast_format tmpfmt;
if (!cap_slin) {
diff --git a/apps/app_originate.c b/apps/app_originate.c
index 8eb8ba329..f924921d4 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -113,7 +113,7 @@ static int originate_exec(struct ast_channel *chan, const char *data)
unsigned int timeout = 30;
static const char default_exten[] = "s";
struct ast_format tmpfmt;
- 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);
ast_autoservice_start(chan);
if (!cap_slin) {
diff --git a/bridges/bridge_holding.c b/bridges/bridge_holding.c
index 9d0ba721a..5eeb4708d 100644
--- a/bridges/bridge_holding.c
+++ b/bridges/bridge_holding.c
@@ -433,7 +433,7 @@ static int unload_module(void)
static int load_module(void)
{
- if (!(holding_bridge.format_capabilities = ast_format_cap_alloc())) {
+ if (!(holding_bridge.format_capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index c8bf880b6..7775d41ec 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -124,8 +124,8 @@ static int native_rtp_bridge_start(struct ast_bridge *bridge, struct ast_channel
RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, tinstance0, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, tinstance1, NULL, ao2_cleanup);
- RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
- RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
+ RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
+ RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
if (c0 == c1) {
return 0;
@@ -279,8 +279,8 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
RAII_VAR(struct ast_rtp_instance *, instance1, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, vinstance0, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup);
- RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
- RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
+ RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
+ RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
int read_ptime0, read_ptime1, write_ptime0, write_ptime1;
/* We require two channels before even considering native bridging */
@@ -448,7 +448,7 @@ static int unload_module(void)
static int load_module(void)
{
- if (!(native_rtp_bridge.format_capabilities = ast_format_cap_alloc())) {
+ if (!(native_rtp_bridge.format_capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
diff --git a/bridges/bridge_simple.c b/bridges/bridge_simple.c
index 78ac7a4ae..4a03dbe10 100644
--- a/bridges/bridge_simple.c
+++ b/bridges/bridge_simple.c
@@ -82,7 +82,7 @@ static int unload_module(void)
static int load_module(void)
{
- if (!(simple_bridge.format_capabilities = ast_format_cap_alloc())) {
+ if (!(simple_bridge.format_capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index c6cde396d..b7cce866c 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -1137,7 +1137,7 @@ static int unload_module(void)
static int load_module(void)
{
struct ast_format tmp;
- if (!(softmix_bridge.format_capabilities = ast_format_cap_alloc())) {
+ if (!(softmix_bridge.format_capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add(softmix_bridge.format_capabilities, ast_format_set(&tmp, AST_FORMAT_SLINEAR, 0));
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index f1720ba8c..60bbacbb8 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -960,7 +960,7 @@ static int load_module(void)
struct ast_flags config_flags = { 0 };
struct ast_format tmpfmt;
- if (!(alsa_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(alsa_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add(alsa_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
diff --git a/channels/chan_bridge_media.c b/channels/chan_bridge_media.c
index 663578033..7aaca6671 100644
--- a/channels/chan_bridge_media.c
+++ b/channels/chan_bridge_media.c
@@ -182,12 +182,12 @@ static int unload_module(void)
static int load_module(void)
{
- announce_tech.capabilities = ast_format_cap_alloc();
+ announce_tech.capabilities = ast_format_cap_alloc(0);
if (!announce_tech.capabilities) {
return AST_MODULE_LOAD_DECLINE;
}
- record_tech.capabilities = ast_format_cap_alloc();
+ record_tech.capabilities = ast_format_cap_alloc(0);
if (!record_tech.capabilities) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/channels/chan_console.c b/channels/chan_console.c
index 76571d209..922c53b42 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -1497,7 +1497,7 @@ static int load_module(void)
struct ast_format tmpfmt;
PaError res;
- if (!(console_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(console_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add(console_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0));
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 65a9758f2..e52969b5d 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -18550,7 +18550,7 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
- if (!(dahdi_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(dahdi_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add(dahdi_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index a44ca57f4..d6a094941 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -436,7 +436,7 @@ static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, in
iks_insert_attrib(dcodecs, "xmlns", GOOGLE_AUDIO_NS);
iks_insert_attrib(dcodecs, "xml:lang", "en");
- if (!(alreadysent = ast_format_cap_alloc_nolock())) {
+ if (!(alreadysent = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
return 0;
}
for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
@@ -1063,9 +1063,9 @@ static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
return NULL;
}
- tmp->cap = ast_format_cap_alloc_nolock();
- tmp->jointcap = ast_format_cap_alloc_nolock();
- tmp->peercap = ast_format_cap_alloc_nolock();
+ tmp->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ tmp->jointcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ tmp->peercap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!tmp->jointcap || !tmp->peercap || !tmp->cap) {
tmp->cap = ast_format_cap_destroy(tmp->cap);
tmp->jointcap = ast_format_cap_destroy(tmp->jointcap);
@@ -2256,7 +2256,7 @@ static int gtalk_load_config(void)
member = ast_calloc(1, sizeof(*member));
ASTOBJ_INIT(member);
ASTOBJ_WRLOCK(member);
- member->cap = ast_format_cap_alloc_nolock();
+ member->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!strcasecmp(cat, "guest")) {
ast_copy_string(member->name, "guest", sizeof(member->name));
ast_copy_string(member->user, "guest", sizeof(member->user));
@@ -2336,10 +2336,10 @@ static int load_module(void)
char *jabber_loaded = ast_module_helper("", "res_jabber.so", 0, 0, 0, 0);
struct ast_format tmpfmt;
- if (!(gtalk_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(gtalk_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
- if (!(global_capability = ast_format_cap_alloc())) {
+ if (!(global_capability = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index dd23b7f59..22dba3c18 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -1313,7 +1313,7 @@ static struct oh323_alias *realtime_alias(const char *alias)
static int h323_parse_allow_disallow(struct ast_codec_pref *pref, h323_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;
}
@@ -2093,7 +2093,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
/* Don't try to lock the channel if nothing changed */
if (nativeformats_changed || pvt->options.progress_audio || (rtp_change != NEED_NONE)) {
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
- struct ast_format_cap *pvt_native = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *pvt_native = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
ast_format_cap_from_old_bitfield(pvt_native, pvt->nativeformats);
/* Re-build translation path only if native format(s) has been changed */
@@ -3336,7 +3336,7 @@ static enum ast_module_load_result load_module(void)
{
int res;
- if (!(oh323_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(oh323_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add_all_by_type(oh323_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
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);
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index a8cab6238..56c15b193 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -322,7 +322,7 @@ static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
iks *iq, *jingle, *dcodecs, *payload_red, *payload_audio, *payload_cn;
int x;
struct ast_format pref_codec;
- struct ast_format_cap *alreadysent = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *alreadysent = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (p->initiator || !alreadysent)
return 1;
@@ -798,9 +798,9 @@ static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from,
return NULL;
}
- tmp->cap = ast_format_cap_alloc_nolock();
- tmp->jointcap = ast_format_cap_alloc_nolock();
- tmp->peercap = ast_format_cap_alloc_nolock();
+ tmp->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ tmp->jointcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ tmp->peercap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!tmp->cap || !tmp->jointcap || !tmp->peercap) {
tmp->cap = ast_format_cap_destroy(tmp->cap);
tmp->jointcap = ast_format_cap_destroy(tmp->jointcap);
@@ -1897,7 +1897,7 @@ static int jingle_load_config(void)
member = ast_calloc(1, sizeof(*member));
ASTOBJ_INIT(member);
ASTOBJ_WRLOCK(member);
- member->cap = ast_format_cap_alloc_nolock();
+ member->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!strcasecmp(cat, "guest")) {
ast_copy_string(member->name, "guest", sizeof(member->name));
ast_copy_string(member->user, "guest", sizeof(member->user));
@@ -1981,12 +1981,12 @@ static int load_module(void)
char *jabber_loaded = ast_module_helper("", "res_jabber.so", 0, 0, 0, 0);
- if (!(jingle_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(jingle_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add_all_by_type(jingle_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
- if (!(global_capability = ast_format_cap_alloc())) {
+ if (!(global_capability = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add(global_capability, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 7c9120088..a659a2aab 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -2039,7 +2039,7 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
}
/* Now gather all of the codecs that were asked for: */
- if (!(peercap = ast_format_cap_alloc_nolock())) {
+ if (!(peercap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
return -1;
}
ast_rtp_codecs_payload_formats(ast_rtp_instance_get_codecs(sub->rtp), peercap, &peerNonCodecCapability);
@@ -4172,7 +4172,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_mutex_init(&e->lock);
ast_mutex_init(&e->rqnt_queue_lock);
ast_mutex_init(&e->cmd_queue_lock);
- e->cap = ast_format_cap_alloc_nolock();
+ e->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
ast_copy_string(e->name, v->value, sizeof(e->name));
e->needaudit = 1;
}
@@ -4288,7 +4288,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_mutex_init(&e->lock);
ast_mutex_init(&e->rqnt_queue_lock);
ast_mutex_init(&e->cmd_queue_lock);
- e->cap = ast_format_cap_alloc_nolock();
+ e->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
ast_copy_string(e->name, v->value, sizeof(e->name));
e->needaudit = 1;
}
@@ -4829,10 +4829,10 @@ static int load_module(void)
{
struct ast_format tmpfmt;
- if (!(global_capability = ast_format_cap_alloc())) {
+ if (!(global_capability = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
- if (!(mgcp_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(mgcp_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add(global_capability, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 29274e743..38197c638 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -10193,7 +10193,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
ch->addr = bc->addr;
{
- 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 RESPONSE_ERR;
@@ -11298,7 +11298,7 @@ static int load_module(void)
};
- if (!(misdn_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(misdn_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_set(&prefformat, AST_FORMAT_ALAW, 0);
diff --git a/channels/chan_motif.c b/channels/chan_motif.c
index e13c66c6f..1e7ee3cce 100644
--- a/channels/chan_motif.c
+++ b/channels/chan_motif.c
@@ -519,7 +519,7 @@ static void *jingle_endpoint_alloc(const char *cat)
ast_string_field_set(endpoint, name, cat);
- endpoint->cap = ast_format_cap_alloc_nolock();
+ endpoint->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
endpoint->transport = JINGLE_TRANSPORT_ICE_UDP;
return endpoint;
@@ -741,9 +741,9 @@ static struct jingle_session *jingle_alloc(struct jingle_endpoint *endpoint, con
session->connection = endpoint->connection;
session->transport = endpoint->transport;
- if (!(session->cap = ast_format_cap_alloc_nolock()) ||
- !(session->jointcap = ast_format_cap_alloc_nolock()) ||
- !(session->peercap = ast_format_cap_alloc_nolock()) ||
+ if (!(session->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK)) ||
+ !(session->jointcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK)) ||
+ !(session->peercap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK)) ||
!session->callid) {
ao2_ref(session, -1);
return NULL;
@@ -2707,7 +2707,7 @@ static int custom_transport_handler(const struct aco_option *opt, struct ast_var
*/
static int load_module(void)
{
- if (!(jingle_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(jingle_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/channels/chan_multicast_rtp.c b/channels/chan_multicast_rtp.c
index 462982969..1b9e4d31f 100644
--- a/channels/chan_multicast_rtp.c
+++ b/channels/chan_multicast_rtp.c
@@ -176,7 +176,7 @@ failure:
/*! \brief Function called when our module is loaded */
static int load_module(void)
{
- if (!(multicast_rtp_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(multicast_rtp_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add_all(multicast_rtp_tech.capabilities);
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index e6384872e..1d8c59d4e 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -281,7 +281,7 @@ static int unload_module(void)
static int load_module(void)
{
ast_format_set(&prefformat, AST_FORMAT_SLINEAR, 0);
- if (!(nbs_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(nbs_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add(nbs_tech.capabilities, &prefformat);
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index f8e67e59e..5ae18f362 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1479,7 +1479,7 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
- if (!(oss_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(oss_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add(oss_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 71a498a85..c1a24b8b1 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -1376,7 +1376,7 @@ static int load_module(void)
struct ast_flags config_flags = { 0 };
struct ast_format tmpfmt;
- if (!(phone_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(phone_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0));
@@ -1384,11 +1384,11 @@ static int load_module(void)
ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0));
- if (!(prefcap = ast_format_cap_alloc())) {
+ if (!(prefcap = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_copy(prefcap, phone_tech.capabilities);
- if (!(phone_tech_fxs.capabilities = ast_format_cap_alloc())) {
+ if (!(phone_tech_fxs.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index e505751c3..6ceece4fc 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2065,7 +2065,7 @@ static int chan_pjsip_incoming_ack(struct ast_sip_session *session, struct pjsip
*/
static int load_module(void)
{
- if (!(chan_pjsip_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(chan_pjsip_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 497fb6e61..00a2a16cb 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -8814,11 +8814,11 @@ struct sip_pvt *sip_alloc(ast_string_field callid, struct ast_sockaddr *addr,
sip_pvt_callid_set(p, logger_callid);
}
- p->caps = ast_format_cap_alloc_nolock();
- p->jointcaps = ast_format_cap_alloc_nolock();
- p->peercaps = ast_format_cap_alloc_nolock();
- p->redircaps = ast_format_cap_alloc_nolock();
- p->prefcaps = ast_format_cap_alloc_nolock();
+ p->caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ p->jointcaps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ p->peercaps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ p->redircaps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ p->prefcaps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!p->caps|| !p->jointcaps || !p->peercaps || !p->redircaps) {
p->caps = ast_format_cap_destroy(p->caps);
@@ -10052,15 +10052,15 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
int udptlportno = -1; /*!< UDPTL image destination port number */
/* Peer capability is the capability in the SDP, non codec is RFC2833 DTMF (101) */
- struct ast_format_cap *peercapability = ast_format_cap_alloc_nolock();
- struct ast_format_cap *vpeercapability = ast_format_cap_alloc_nolock();
- struct ast_format_cap *tpeercapability = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *peercapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ struct ast_format_cap *vpeercapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ struct ast_format_cap *tpeercapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
int peernoncodeccapability = 0, vpeernoncodeccapability = 0, tpeernoncodeccapability = 0;
struct ast_rtp_codecs newaudiortp = { 0, }, newvideortp = { 0, }, newtextrtp = { 0, };
- struct ast_format_cap *newjointcapability = ast_format_cap_alloc_nolock(); /* Negotiated capability */
- struct ast_format_cap *newpeercapability = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *newjointcapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); /* Negotiated capability */
+ struct ast_format_cap *newpeercapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
int newnoncodeccapability;
const char *codecs;
@@ -13136,8 +13136,8 @@ static char *crypto_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int
*/
static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
{
- struct ast_format_cap *alreadysent = ast_format_cap_alloc_nolock();
- struct ast_format_cap *tmpcap = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *alreadysent = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ struct ast_format_cap *tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
int res = AST_SUCCESS;
int doing_directmedia = FALSE;
struct ast_sockaddr addr = { {0,} };
@@ -30358,7 +30358,7 @@ static struct sip_peer *temp_peer(const char *name)
return NULL;
}
- if (!(peer->caps = ast_format_cap_alloc_nolock())) {
+ if (!(peer->caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
ao2_t_ref(peer, -1, "failed to allocate format capabilities, drop peer");
return NULL;
}
@@ -30467,7 +30467,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if (!(peer->endpoint = ast_endpoint_create("SIP", name))) {
return NULL;
}
- if (!(peer->caps = ast_format_cap_alloc_nolock())) {
+ if (!(peer->caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
ao2_t_ref(peer, -1, "failed to allocate format capabilities, drop peer");
return NULL;
}
@@ -34351,7 +34351,7 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
- if (!(sip_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(sip_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
@@ -34373,7 +34373,7 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
- if (!(sip_cfg.caps = ast_format_cap_alloc())) {
+ if (!(sip_cfg.caps = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add_all_by_type(sip_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 496de1866..a65862ff3 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -1677,8 +1677,8 @@ static struct skinny_line *skinny_line_alloc(void)
return NULL;
}
- l->cap = ast_format_cap_alloc_nolock();
- l->confcap = ast_format_cap_alloc_nolock();
+ l->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ l->confcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!l->cap || !l->confcap) {
l->cap = ast_format_cap_destroy(l->cap);
l->confcap = ast_format_cap_destroy(l->confcap);
@@ -1704,8 +1704,8 @@ static struct skinny_device *skinny_device_alloc(const char *dname)
return NULL;
}
- d->cap = ast_format_cap_alloc_nolock();
- d->confcap = ast_format_cap_alloc_nolock();
+ d->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ d->confcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
d->endpoint = ast_endpoint_create("Skinny", dname);
if (!d->cap || !d->confcap || !d->endpoint) {
d->cap = ast_format_cap_destroy(d->cap);
@@ -6643,7 +6643,7 @@ static int handle_capabilities_res_message(struct skinny_req *req, struct skinny
struct skinny_device *d = s->device;
struct skinny_line *l;
uint32_t count = 0;
- struct ast_format_cap *codecs = ast_format_cap_alloc();
+ struct ast_format_cap *codecs = ast_format_cap_alloc(0);
int i;
if (!codecs) {
@@ -8635,10 +8635,10 @@ static int load_module(void)
{
int res = 0;
struct ast_format tmpfmt;
- if (!(default_cap = ast_format_cap_alloc())) {
+ if (!(default_cap = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
- if (!(skinny_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(skinny_tech.capabilities = ast_format_cap_alloc(0))) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 523867988..547cd7c2f 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -1836,7 +1836,7 @@ static struct unistim_line *unistim_line_alloc(void)
return NULL;
}
- if (!(l->cap = ast_format_cap_alloc_nolock())) {
+ if (!(l->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
ast_free(l);
return NULL;
}
@@ -6853,10 +6853,10 @@ int load_module(void)
{
int res;
struct ast_format tmpfmt;
- if (!(global_cap = ast_format_cap_alloc())) {
+ if (!(global_cap = ast_format_cap_alloc(0))) {
goto buff_failed;
}
- if (!(unistim_tech.capabilities = ast_format_cap_alloc())) {
+ if (!(unistim_tech.capabilities = ast_format_cap_alloc(0))) {
goto buff_failed;
}
diff --git a/channels/dahdi/bridge_native_dahdi.c b/channels/dahdi/bridge_native_dahdi.c
index 13e1a84dd..7505eca3e 100644
--- a/channels/dahdi/bridge_native_dahdi.c
+++ b/channels/dahdi/bridge_native_dahdi.c
@@ -911,7 +911,7 @@ int dahdi_native_load(struct ast_module *mod, const struct ast_channel_tech *tec
dahdi_tech = tech;
- native_bridge.format_capabilities = ast_format_cap_alloc();
+ native_bridge.format_capabilities = ast_format_cap_alloc(0);
if (!native_bridge.format_capabilities) {
return -1;
}
diff --git a/include/asterisk/format_cap.h b/include/asterisk/format_cap.h
index b34f1d3ca..aa4eb3bfd 100644
--- a/include/asterisk/format_cap.h
+++ b/include/asterisk/format_cap.h
@@ -29,32 +29,27 @@
/*! Capabilities are represented by an opaque structure statically defined in format_capability.c */
struct ast_format_cap;
-/*!
- * \brief Allocate a new ast_format_cap structure.
- *
- * \note Allocation of this object assumes locking
- * is already occuring and that the point of contention
- * is above this capabilities structure. For example,
- * a tech_pvt object referencing a capabilities structure
- * can use this function as long as it always holds the
- * tech_pvt lock while accessing its capabilities.
- *
- * \retval ast_format_cap object on success.
- * \retval NULL on failure.
- */
-struct ast_format_cap *ast_format_cap_alloc_nolock(void);
+enum ast_format_cap_flags {
+ /*!
+ * The ast_format_cap will be allocated with no lock.
+ * Useful if there is a separate lock used to protect the structure
+ */
+ AST_FORMAT_CAP_FLAG_NOLOCK = (1 << 0),
+ /*!
+ * String representations of the formats are cached on the structure.
+ * Useful if string representation is frequently requested of the structure.
+ */
+ AST_FORMAT_CAP_FLAG_CACHE_STRINGS = (1 << 1),
+};
/*!
- * \brief Allocate a new ast_format_cap structure with locking
- *
- * \note If no other form of locking is taking place, use this function.
- * This function makes most sense for globally accessible capabilities structures
- * that have no other means of locking.
+ * \brief Allocate a new ast_format_cap structure
*
+ * \param flags Modifiers of struct behavior.
* \retval ast_format_cap object on success.
* \retval NULL on failure.
*/
-struct ast_format_cap *ast_format_cap_alloc(void);
+struct ast_format_cap *ast_format_cap_alloc(enum ast_format_cap_flags flags);
/*!
* \brief Destroy an ast_format_cap structure.
diff --git a/main/bridge_basic.c b/main/bridge_basic.c
index 942a3ce25..76dfb2893 100644
--- a/main/bridge_basic.c
+++ b/main/bridge_basic.c
@@ -2218,7 +2218,7 @@ static void recall_callback(struct ast_dial *dial)
static int recalling_enter(struct attended_transfer_properties *props)
{
- RAII_VAR(struct ast_format_cap *, cap, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
+ RAII_VAR(struct ast_format_cap *, cap, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
struct ast_format fmt;
if (!cap) {
@@ -2346,7 +2346,7 @@ static int attach_framehook(struct attended_transfer_properties *props, struct a
static int retransfer_enter(struct attended_transfer_properties *props)
{
- RAII_VAR(struct ast_format_cap *, cap, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
+ RAII_VAR(struct ast_format_cap *, cap, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
struct ast_format fmt;
char destination[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2];
int cause;
diff --git a/main/ccss.c b/main/ccss.c
index 3068c6ffa..fadc6e36f 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -2815,7 +2815,7 @@ static void *generic_recall(void *data)
const char *callback_sub = ast_get_cc_callback_sub(agent->cc_params);
unsigned int recall_timer = ast_get_cc_recall_timer(agent->cc_params) * 1000;
struct ast_format tmp_fmt;
- struct ast_format_cap *tmp_cap = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *tmp_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!tmp_cap) {
return NULL;
diff --git a/main/channel.c b/main/channel.c
index 36528f5df..e6025c062 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -879,7 +879,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_stage_snapshot(tmp);
- if (!(nativeformats = ast_format_cap_alloc())) {
+ if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_CACHE_STRINGS))) {
ao2_ref(tmp, -1);
/* format capabilities structure allocation failure */
return NULL;
@@ -5401,7 +5401,7 @@ static int set_format(struct ast_channel *chan,
int ast_set_read_format(struct ast_channel *chan, struct ast_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);
int res;
if (!cap) {
@@ -5422,7 +5422,7 @@ int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
{
- 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 tmp_format;
int res;
@@ -5454,7 +5454,7 @@ int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap
int ast_set_write_format(struct ast_channel *chan, struct ast_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);
int res;
if (!cap) {
@@ -5475,7 +5475,7 @@ int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
{
- 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 tmp_format;
int res;
diff --git a/main/core_local.c b/main/core_local.c
index d4ec06d9f..4a047032c 100644
--- a/main/core_local.c
+++ b/main/core_local.c
@@ -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);
diff --git a/main/dial.c b/main/dial.c
index 6d796e2b9..8cc6f9c89 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -273,7 +273,7 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
} else if (chan) {
cap_request = ast_channel_nativeformats(chan);
} else {
- cap_all_audio = ast_format_cap_alloc_nolock();
+ cap_all_audio = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
ast_format_cap_add_all_by_type(cap_all_audio, AST_FORMAT_TYPE_AUDIO);
cap_request = cap_all_audio;
}
diff --git a/main/file.c b/main/file.c
index b24cdeeb3..ffdbf1821 100644
--- a/main/file.c
+++ b/main/file.c
@@ -749,7 +749,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
buflen = strlen(preflang) + strlen(filename) + 4;
buf = ast_alloca(buflen);
- if (!(file_fmt_cap = ast_format_cap_alloc_nolock())) {
+ if (!(file_fmt_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
return NULL;
}
if (!fileexists_core(filename, NULL, preflang, buf, buflen, file_fmt_cap) ||
@@ -797,7 +797,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
return NULL;
}
- if (!(tmp_cap = ast_format_cap_alloc_nolock())) {
+ if (!(tmp_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
return NULL;
}
/* Video is supported, so see what video formats exist for this file */
diff --git a/main/format_cap.c b/main/format_cap.c
index 5fc110812..96c2fa3aa 100644
--- a/main/format_cap.c
+++ b/main/format_cap.c
@@ -38,13 +38,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
#include "asterisk/astobj2.h"
#include "asterisk/utils.h"
+#define FORMAT_STR_BUFSIZE 256
struct ast_format_cap {
/* The capabilities structure is just an ao2 container of ast_formats */
struct ao2_container *formats;
struct ao2_iterator it;
/*! TRUE if the formats container created without a lock. */
- int nolock;
+ struct ast_flags flags;
+ unsigned int string_cache_valid;
+ char format_strs[0];
};
/*! format exists within capabilities structure if it is identical to
@@ -67,17 +70,27 @@ static int hash_cb(const void *obj, const int flags)
return format->id;
}
-static struct ast_format_cap *cap_alloc_helper(int nolock)
+struct ast_format_cap *ast_format_cap_alloc(enum ast_format_cap_flags flags)
{
- struct ast_format_cap *cap = ast_calloc(1, sizeof(*cap));
+ struct ast_format_cap *cap;
+ unsigned int alloc_size;
+
+ alloc_size = sizeof(*cap);
+ if (flags & AST_FORMAT_CAP_FLAG_CACHE_STRINGS) {
+ alloc_size += FORMAT_STR_BUFSIZE;
+ }
+ cap = ast_calloc(1, alloc_size);
if (!cap) {
return NULL;
}
- cap->nolock = nolock;
+
+ ast_set_flag(&cap->flags, flags);
cap->formats = ao2_container_alloc_options(
- nolock ? AO2_ALLOC_OPT_LOCK_NOLOCK : AO2_ALLOC_OPT_LOCK_MUTEX,
- 283, hash_cb, cmp_cb);
+ (flags & AST_FORMAT_CAP_FLAG_NOLOCK) ?
+ AO2_ALLOC_OPT_LOCK_NOLOCK :
+ AO2_ALLOC_OPT_LOCK_MUTEX,
+ 11, hash_cb, cmp_cb);
if (!cap->formats) {
ast_free(cap);
return NULL;
@@ -86,16 +99,6 @@ static struct ast_format_cap *cap_alloc_helper(int nolock)
return cap;
}
-struct ast_format_cap *ast_format_cap_alloc_nolock(void)
-{
- return cap_alloc_helper(1);
-}
-
-struct ast_format_cap *ast_format_cap_alloc(void)
-{
- return cap_alloc_helper(0);
-}
-
void *ast_format_cap_destroy(struct ast_format_cap *cap)
{
if (!cap) {
@@ -106,7 +109,7 @@ void *ast_format_cap_destroy(struct ast_format_cap *cap)
return NULL;
}
-void ast_format_cap_add(struct ast_format_cap *cap, const struct ast_format *format)
+static void format_cap_add(struct ast_format_cap *cap, const struct ast_format *format)
{
struct ast_format *fnew;
@@ -118,9 +121,16 @@ void ast_format_cap_add(struct ast_format_cap *cap, const struct ast_format *for
}
ast_format_copy(fnew, format);
ao2_link(cap->formats, fnew);
+
ao2_ref(fnew, -1);
}
+void ast_format_cap_add(struct ast_format_cap *cap, const struct ast_format *format)
+{
+ format_cap_add(cap, format);
+ cap->string_cache_valid = 0;
+}
+
void ast_format_cap_add_all_by_type(struct ast_format_cap *cap, enum ast_format_type type)
{
int x;
@@ -129,9 +139,10 @@ void ast_format_cap_add_all_by_type(struct ast_format_cap *cap, enum ast_format_
for (x = 0; x < f_len; x++) {
if (AST_FORMAT_GET_TYPE(f_list[x].format.id) == type) {
- ast_format_cap_add(cap, &f_list[x].format);
+ format_cap_add(cap, &f_list[x].format);
}
}
+ cap->string_cache_valid = 0;
ast_format_list_destroy(f_list);
}
@@ -142,8 +153,9 @@ void ast_format_cap_add_all(struct ast_format_cap *cap)
const struct ast_format_list *f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
- ast_format_cap_add(cap, &f_list[x].format);
+ format_cap_add(cap, &f_list[x].format);
}
+ cap->string_cache_valid = 0;
ast_format_list_destroy(f_list);
}
@@ -153,7 +165,7 @@ static int append_cb(void *obj, void *arg, int flag)
struct ast_format *format = (struct ast_format *) obj;
if (!ast_format_cap_iscompatible(result, format)) {
- ast_format_cap_add(result, format);
+ format_cap_add(result, format);
}
return 0;
@@ -162,6 +174,7 @@ static int append_cb(void *obj, void *arg, int flag)
void ast_format_cap_append(struct ast_format_cap *dst, const struct ast_format_cap *src)
{
ao2_callback(src->formats, OBJ_NODATA, append_cb, dst);
+ dst->string_cache_valid = 0;
}
static int copy_cb(void *obj, void *arg, int flag)
@@ -169,28 +182,32 @@ static int copy_cb(void *obj, void *arg, int flag)
struct ast_format_cap *result = (struct ast_format_cap *) arg;
struct ast_format *format = (struct ast_format *) obj;
- ast_format_cap_add(result, format);
+ format_cap_add(result, format);
return 0;
}
+static void format_cap_remove_all(struct ast_format_cap *cap)
+{
+ ao2_callback(cap->formats, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, NULL, NULL);
+}
+
void ast_format_cap_copy(struct ast_format_cap *dst, const struct ast_format_cap *src)
{
- ast_format_cap_remove_all(dst);
+ format_cap_remove_all(dst);
ao2_callback(src->formats, OBJ_NODATA, copy_cb, dst);
+ dst->string_cache_valid = 0;
}
struct ast_format_cap *ast_format_cap_dup(const struct ast_format_cap *cap)
{
struct ast_format_cap *dst;
- if (cap->nolock) {
- dst = ast_format_cap_alloc_nolock();
- } else {
- dst = ast_format_cap_alloc();
- }
+
+ dst = ast_format_cap_alloc(ast_test_flag(&cap->flags, AST_FLAGS_ALL));
if (!dst) {
return NULL;
}
ao2_callback(cap->formats, OBJ_NODATA, copy_cb, dst);
+ dst->string_cache_valid = 0;
return dst;
}
@@ -217,6 +234,7 @@ int ast_format_cap_remove(struct ast_format_cap *cap, struct ast_format *format)
fremove = ao2_callback(cap->formats, OBJ_POINTER | OBJ_UNLINK, find_exact_cb, format);
if (fremove) {
ao2_ref(fremove, -1);
+ cap->string_cache_valid = 0;
return 0;
}
@@ -259,6 +277,7 @@ int ast_format_cap_remove_byid(struct ast_format_cap *cap, enum ast_format_id id
/* match_found will be set if at least one item was removed */
if (data.match_found) {
+ cap->string_cache_valid = 0;
return 0;
}
@@ -278,17 +297,20 @@ void ast_format_cap_remove_bytype(struct ast_format_cap *cap, enum ast_format_ty
OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
multiple_by_type_cb,
&type);
+ cap->string_cache_valid = 0;
}
void ast_format_cap_remove_all(struct ast_format_cap *cap)
{
- ao2_callback(cap->formats, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, NULL, NULL);
+ format_cap_remove_all(cap);
+ cap->string_cache_valid = 0;
}
void ast_format_cap_set(struct ast_format_cap *cap, struct ast_format *format)
{
- ast_format_cap_remove_all(cap);
- ast_format_cap_add(cap, format);
+ format_cap_remove_all(cap);
+ format_cap_add(cap, format);
+ cap->string_cache_valid = 0;
}
int ast_format_cap_get_compatible_format(const struct ast_format_cap *cap, const struct ast_format *format, struct ast_format *result)
@@ -434,7 +456,7 @@ int ast_format_cap_identical(const struct ast_format_cap *cap1, const struct ast
struct ast_format_cap *ast_format_cap_joint(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
{
struct ao2_iterator it;
- struct ast_format_cap *result = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *result = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
struct ast_format *tmp;
struct find_joint_data data = {
.joint_found = 0,
@@ -472,7 +494,7 @@ static int joint_copy_helper(const struct ast_format_cap *cap1, const struct ast
.joint_found = 0,
};
if (!append) {
- ast_format_cap_remove_all(result);
+ format_cap_remove_all(result);
}
it = ao2_iterator_init(cap1->formats, 0);
while ((tmp = ao2_iterator_next(&it))) {
@@ -485,6 +507,8 @@ static int joint_copy_helper(const struct ast_format_cap *cap1, const struct ast
}
ao2_iterator_destroy(&it);
+ result->string_cache_valid = 0;
+
return ao2_container_count(result->formats) ? 1 : 0;
}
@@ -501,7 +525,7 @@ int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct as
struct ast_format_cap *ast_format_cap_get_type(const struct ast_format_cap *cap, enum ast_format_type ftype)
{
struct ao2_iterator it;
- struct ast_format_cap *result = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *result = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
struct ast_format *tmp;
if (!result) {
@@ -575,7 +599,7 @@ int ast_format_cap_iter_next(struct ast_format_cap *cap, struct ast_format *form
return 0;
}
-char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap)
+static char *getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap)
{
int x;
unsigned len;
@@ -611,6 +635,20 @@ char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *
return buf;
}
+char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap)
+{
+ if (ast_test_flag(&cap->flags, AST_FORMAT_CAP_FLAG_CACHE_STRINGS)) {
+ if (!cap->string_cache_valid) {
+ getformatname_multiple(cap->format_strs, FORMAT_STR_BUFSIZE, cap);
+ cap->string_cache_valid = 1;
+ }
+ ast_copy_string(buf, cap->format_strs, size);
+ return buf;
+ }
+
+ return getformatname_multiple(buf, size, cap);
+}
+
uint64_t ast_format_cap_to_old_bitfield(const struct ast_format_cap *cap)
{
uint64_t res = 0;
@@ -632,11 +670,12 @@ void ast_format_cap_from_old_bitfield(struct ast_format_cap *dst, uint64_t src)
int x;
struct ast_format tmp_format = { 0, };
- ast_format_cap_remove_all(dst);
+ format_cap_remove_all(dst);
for (x = 0; x < 64; x++) {
tmp = (1ULL << x);
if (tmp & src) {
- ast_format_cap_add(dst, ast_format_from_old_bitfield(&tmp_format, tmp));
+ format_cap_add(dst, ast_format_from_old_bitfield(&tmp_format, tmp));
}
}
+ dst->string_cache_valid = 0;
}
diff --git a/main/manager.c b/main/manager.c
index f06b7dbca..f3e883407 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -4683,7 +4683,7 @@ static int action_originate(struct mansession *s, const struct message *m)
int reason = 0;
char tmp[256];
char tmp2[256];
- 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 tmp_fmt;
pthread_t th;
int bridge_early = 0;
diff --git a/main/media_index.c b/main/media_index.c
index 605cee927..64fbbbddb 100644
--- a/main/media_index.c
+++ b/main/media_index.c
@@ -67,7 +67,7 @@ static struct media_variant *media_variant_alloc(const char *variant_str)
return NULL;
}
- variant->formats = ast_format_cap_alloc();
+ variant->formats = ast_format_cap_alloc(0);
if (!variant->formats) {
return NULL;
}
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index c7e359795..54e1e45e3 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1081,8 +1081,8 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc
struct ast_rtp_glue *glue0, *glue1;
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
- struct ast_format_cap *cap0 = ast_format_cap_alloc_nolock();
- struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *cap0 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ struct ast_format_cap *cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
/* Lock both channels so we can look for the glue that binds them together */
ast_channel_lock_both(c0, c1);
@@ -1167,8 +1167,8 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1
struct ast_rtp_glue *glue0, *glue1;
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
- struct ast_format_cap *cap0 = ast_format_cap_alloc_nolock();
- struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
+ struct ast_format_cap *cap0 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ struct ast_format_cap *cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
/* If there is no second channel just immediately bail out, we are of no use in that scenario */
if (!c1 || !cap1 || !cap0) {
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 79ef7166f..31d883c94 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -144,7 +144,7 @@ static struct outgoing *new_outgoing(const char *fn)
return NULL;
}
- o->capabilities = ast_format_cap_alloc_nolock();
+ o->capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!o->capabilities) {
free_outgoing(o);
return NULL;
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;
}
diff --git a/tests/test_config.c b/tests/test_config.c
index 6b1a8e420..f9e9a6f48 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -671,7 +671,7 @@ static void *test_item_alloc(const char *cat)
ao2_ref(item, -1);
return NULL;
}
- if (!(item->codeccapopt = ast_format_cap_alloc())) {
+ if (!(item->codeccapopt = ast_format_cap_alloc(0))) {
ao2_ref(item, -1);
return NULL;
}
@@ -855,10 +855,10 @@ AST_TEST_DEFINE(config_options_test)
ast_sockaddr_parse(&acl_allow, "1.2.3.4", PARSE_PORT_FORBID);
ast_sockaddr_parse(&acl_fail, "1.1.1.1", PARSE_PORT_FORBID);
- defaults.codeccapopt = ast_format_cap_alloc();
+ defaults.codeccapopt = ast_format_cap_alloc(0);
ast_parse_allow_disallow(&defaults.codecprefopt, defaults.codeccapopt, CODEC_DEFAULT, 1);
- configs.codeccapopt = ast_format_cap_alloc();
+ configs.codeccapopt = ast_format_cap_alloc(0);
ast_parse_allow_disallow(&configs.codecprefopt, configs.codeccapopt, CODEC_CONFIG, 1);
ast_string_field_init(&defaults, 128);
diff --git a/tests/test_format_api.c b/tests/test_format_api.c
index c429e0895..6cc349570 100644
--- a/tests/test_format_api.c
+++ b/tests/test_format_api.c
@@ -622,8 +622,8 @@ AST_TEST_DEFINE(container_test1_nolock)
break;
}
- cap1 = ast_format_cap_alloc_nolock();
- cap2 = ast_format_cap_alloc_nolock();
+ cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ cap2 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap1 || !cap2) {
ast_test_status_update(test, "cap alloc failed.\n");
@@ -654,8 +654,8 @@ AST_TEST_DEFINE(container_test1_withlock)
break;
}
- cap1 = ast_format_cap_alloc();
- cap2 = ast_format_cap_alloc();
+ cap1 = ast_format_cap_alloc(0);
+ cap2 = ast_format_cap_alloc(0);
if (!cap1 || !cap2) {
ast_test_status_update(test, "cap alloc failed.\n");
@@ -710,7 +710,7 @@ AST_TEST_DEFINE(container_test2_no_locking)
break;
}
- cap = ast_format_cap_alloc_nolock();
+ cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
if (!cap) {
ast_test_status_update(test, "alloc failed\n");
return AST_TEST_FAIL;
@@ -737,7 +737,7 @@ AST_TEST_DEFINE(container_test2_with_locking)
break;
}
- cap = ast_format_cap_alloc();
+ cap = ast_format_cap_alloc(0);
if (!cap) {
ast_test_status_update(test, "alloc failed\n");
return AST_TEST_FAIL;
@@ -756,13 +756,13 @@ static int container_test3_helper(int nolocking, struct ast_test *test)
for (x = 0; x < 2000; x++) {
if (nolocking) {
- cap1 = ast_format_cap_alloc_nolock();
- cap2 = ast_format_cap_alloc_nolock();
- joint = ast_format_cap_alloc_nolock();
+ cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ cap2 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+ joint = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
} else {
- cap1 = ast_format_cap_alloc();
- cap2 = ast_format_cap_alloc();
- joint = ast_format_cap_alloc();
+ cap1 = ast_format_cap_alloc(0);
+ cap2 = ast_format_cap_alloc(0);
+ joint = ast_format_cap_alloc(0);
}
if (!cap1 || !cap2 || !joint) {
ast_test_status_update(test, "cap alloc fail\n");