[asterisk-commits] file: branch file/mf-attributes r417756 - in /team/file/mf-attributes: includ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 2 07:27:35 CDT 2014
Author: file
Date: Wed Jul 2 07:27:32 2014
New Revision: 417756
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417756
Log:
The direct format interface pointer is not an AO2 object, and use the cloned format interface when cloning as it is more likely to exist.
Modified:
team/file/mf-attributes/include/asterisk/format.h
team/file/mf-attributes/main/format.c
Modified: team/file/mf-attributes/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/include/asterisk/format.h?view=diff&rev=417756&r1=417755&r2=417756
==============================================================================
--- team/file/mf-attributes/include/asterisk/format.h (original)
+++ team/file/mf-attributes/include/asterisk/format.h Wed Jul 2 07:27:32 2014
@@ -236,7 +236,7 @@
* \retval 0 success
* \retval -1 failure
*/
-int __ast_format_interface_register(const char *codec, struct ast_format_interface *interface, struct ast_module *mod);
+int __ast_format_interface_register(const char *codec, const struct ast_format_interface *interface, struct ast_module *mod);
/*!
* \brief Register a format interface for use with the provided codec
Modified: team/file/mf-attributes/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/main/format.c?view=diff&rev=417756&r1=417755&r2=417756
==============================================================================
--- team/file/mf-attributes/main/format.c (original)
+++ team/file/mf-attributes/main/format.c Wed Jul 2 07:27:32 2014
@@ -49,13 +49,13 @@
/*! \brief Attribute specific data, implementation specific */
void *attribute_data;
/*! \brief Pointer to the optional format interface */
- struct ast_format_interface *interface;
+ const struct ast_format_interface *interface;
};
/*! \brief Structure used when registering a format interface */
struct format_interface {
/*! \brief Pointer to the format interface itself */
- struct ast_format_interface *interface;
+ const struct ast_format_interface *interface;
/*! \brief Name of the codec the interface is for */
char codec[0];
};
@@ -122,15 +122,7 @@
return 0;
}
-/*! \brief Destructor for format interface */
-static void format_interface_destroy(void *obj)
-{
- struct format_interface *format_interface = obj;
-
- ao2_cleanup(format_interface->interface);
-}
-
-int __ast_format_interface_register(const char *codec, struct ast_format_interface *interface, struct ast_module *mod)
+int __ast_format_interface_register(const char *codec, const struct ast_format_interface *interface, struct ast_module *mod)
{
SCOPED_AO2WRLOCK(lock, interfaces);
struct format_interface *format_interface;
@@ -142,7 +134,7 @@
return -1;
}
- format_interface = ao2_alloc(sizeof(*format_interface) + strlen(codec) + 1, format_interface_destroy);
+ format_interface = ao2_alloc(sizeof(*format_interface) + strlen(codec) + 1, NULL);
if (!format_interface) {
return -1;
}
@@ -174,7 +166,6 @@
if (format->interface) {
format->interface->format_destroy(format);
- ao2_ref(format->interface, -1);
}
ao2_cleanup(format->codec);
@@ -194,7 +185,7 @@
format_interface = ao2_find(interfaces, codec->name, OBJ_SEARCH_KEY);
if (format_interface) {
- format->interface = ao2_bump(format_interface->interface);
+ format->interface = format_interface->interface;
ao2_ref(format_interface, -1);
}
@@ -209,7 +200,7 @@
return NULL;
}
- if (format->interface && format->interface->format_clone(format, cloned)) {
+ if (cloned->interface && cloned->interface->format_clone(format, cloned)) {
ao2_ref(cloned, -1);
return NULL;
}
@@ -224,7 +215,7 @@
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
{
- struct ast_format_interface *interface;
+ const struct ast_format_interface *interface;
if (format1 == NULL || format2 == NULL) {
return AST_FORMAT_CMP_NOT_EQUAL;
@@ -249,7 +240,7 @@
struct ast_format *ast_format_joint(const struct ast_format *format1, const struct ast_format *format2)
{
- struct ast_format_interface *interface;
+ const struct ast_format_interface *interface;
if (format1->codec != format2->codec) {
return NULL;
@@ -271,16 +262,14 @@
struct ast_format *ast_format_attribute_set(const struct ast_format *format, const char *name, const char *value)
{
- RAII_VAR(struct ast_format_interface *, interface, format->interface, ao2_cleanup);
+ const struct ast_format_interface *interface = format->interface;
if (!interface) {
struct format_interface *format_interface = ao2_find(interfaces, format->codec->name, OBJ_SEARCH_KEY);
if (format_interface) {
- interface = ao2_bump(format_interface->interface);
+ interface = format_interface->interface;
ao2_ref(format_interface, -1);
}
- } else {
- ao2_ref(interface, +1);
}
if (!interface || !interface->format_attribute_set) {
@@ -292,16 +281,14 @@
struct ast_format *ast_format_sdp_parse(const struct ast_format *format, const char *attributes)
{
- RAII_VAR(struct ast_format_interface *, interface, format->interface, ao2_cleanup);
+ const struct ast_format_interface *interface = format->interface;
if (!interface) {
struct format_interface *format_interface = ao2_find(interfaces, format->codec->name, OBJ_SEARCH_KEY);
if (format_interface) {
- interface = ao2_bump(format_interface->interface);
+ interface = format_interface->interface;
ao2_ref(format_interface, -1);
}
- } else {
- ao2_ref(interface, +1);
}
if (!interface || !interface->format_sdp_parse) {
More information about the asterisk-commits
mailing list