summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/astobj2.h27
-rw-r--r--include/asterisk/autoconfig.h.in3
-rw-r--r--include/asterisk/format_cache.h5
-rw-r--r--include/asterisk/named_locks.h10
-rw-r--r--include/asterisk/sorcery.h20
5 files changed, 57 insertions, 8 deletions
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index 0472c1b37..28ae73e87 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -368,6 +368,13 @@ enum ao2_alloc_opts {
AO2_ALLOC_OPT_LOCK_NOLOCK = (2 << 0),
/*! The ao2 object locking option field mask. */
AO2_ALLOC_OPT_LOCK_MASK = (3 << 0),
+ /*!
+ * \internal The ao2 object uses a separate object for locking.
+ *
+ * \note This option is used internally by ao2_alloc_with_lockobj and
+ * should never be passed directly to ao2_alloc.
+ */
+ AO2_ALLOC_OPT_LOCK_OBJ = AO2_ALLOC_OPT_LOCK_MASK,
};
/*!
@@ -408,6 +415,26 @@ void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned in
/*! @} */
+/*!
+ * \since 14.1.0
+ * \brief Allocate and initialize an object with separate locking.
+ *
+ * \param data_size The sizeof() of the user-defined structure.
+ * \param destructor_fn The destructor function (can be NULL)
+ * \param lockobj A separate ao2 object that will provide locking.
+ * \param debug_msg An ao2 object debug tracing message.
+ * \return A pointer to user-data.
+ *
+ * \see \ref ao2_alloc for additional details.
+ *
+ * \note lockobj must be a valid AO2 object.
+ */
+#define ao2_alloc_with_lockobj(data_size, destructor_fn, lockobj, tag) \
+ __ao2_alloc_with_lockobj((data_size), (destructor_fn), (lockobj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+void *__ao2_alloc_with_lockobj(size_t data_size, ao2_destructor_fn destructor_fn, void *lockobj,
+ const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result;
+
/*! \brief
* Reference/unreference an object and return the old refcount.
*
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index bdd93bb64..f9a6b46e4 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -145,6 +145,9 @@
/* Define to 1 if you have the `closefrom' function. */
#undef HAVE_CLOSEFROM
+/* Define to 1 if you have the Codec 2 Audio Decoder/Encoder library. */
+#undef HAVE_CODEC2
+
/* Define to 1 if you have the Corosync library. */
#undef HAVE_COROSYNC
diff --git a/include/asterisk/format_cache.h b/include/asterisk/format_cache.h
index 3894ad21b..6099c59ea 100644
--- a/include/asterisk/format_cache.h
+++ b/include/asterisk/format_cache.h
@@ -209,6 +209,11 @@ extern struct ast_format *ast_format_siren7;
extern struct ast_format *ast_format_opus;
/*!
+ * \brief Built-in cached Codec 2 format.
+ */
+extern struct ast_format *ast_format_codec2;
+
+/*!
* \brief Built-in cached t140 format.
*/
extern struct ast_format *ast_format_t140;
diff --git a/include/asterisk/named_locks.h b/include/asterisk/named_locks.h
index 0fe07d992..1959841d0 100644
--- a/include/asterisk/named_locks.h
+++ b/include/asterisk/named_locks.h
@@ -48,7 +48,7 @@
* To use a named lock:
* Call ast_named_lock_get with the appropriate keyspace and key.
* Use the standard ao2 lock/unlock functions as needed.
- * Call ast_named_lock_put when you're finished with it.
+ * Call ao2_cleanup when you're finished with it.
*/
/*!
@@ -66,9 +66,6 @@ struct ast_named_lock;
struct ast_named_lock *__ast_named_lock_get(const char *filename, int lineno, const char *func,
enum ast_named_lock_type lock_type, const char *keyspace, const char *key);
-int __ast_named_lock_put(const char *filename, int lineno, const char *func,
- struct ast_named_lock *lock);
-
/*!
* \brief Geta named lock handle
* \since 13.9.0
@@ -92,11 +89,8 @@ int __ast_named_lock_put(const char *filename, int lineno, const char *func,
* \since 13.9.0
*
* \param lock The pointer to the ast_named_lock structure returned by ast_named_lock_get
- * \retval 0 Success
- * \retval -1 Failure
*/
-#define ast_named_lock_put(lock) \
- __ast_named_lock_put(__FILE__, __LINE__, __PRETTY_FUNCTION__, lock)
+#define ast_named_lock_put(lock) ao2_cleanup(lock)
/*!
* @}
diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h
index 23219ec41..896633816 100644
--- a/include/asterisk/sorcery.h
+++ b/include/asterisk/sorcery.h
@@ -988,10 +988,30 @@ int ast_sorcery_changeset_create(const struct ast_variable *original, const stru
*
* \retval non-NULL success
* \retval NULL failure
+ *
+ * \note The returned object does not support AO2 locking.
*/
void *ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor);
/*!
+ * \since 14.1.0
+ * \brief Allocate a generic sorcery capable object with locking.
+ *
+ * \details Sorcery objects may be replaced with new allocations during reloads.
+ * If locking is required on sorcery objects it must be shared between the old
+ * object and the new one. lockobj can be any AO2 object with locking enabled,
+ * but in most cases named locks should be used to provide stable locking.
+ *
+ * \param size Size of the object
+ * \param destructor Optional destructor function
+ * \param lockobj An AO2 object that will provide locking.
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+void *ast_sorcery_lockable_alloc(size_t size, ao2_destructor_fn destructor, void *lockobj);
+
+/*!
* \brief Allocate an object
*
* \param sorcery Pointer to a sorcery structure