[asterisk-commits] file: branch group/media_formats r406168 - in /team/group/media_formats: incl...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 22 09:58:23 CST 2014
Author: file
Date: Wed Jan 22 09:58:16 2014
New Revision: 406168
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406168
Log:
Add a destroy callback to the format interface and improve ast_format_joint performance.
Modified:
team/group/media_formats/include/asterisk/format_ng.h
team/group/media_formats/main/format_ng.c
Modified: team/group/media_formats/include/asterisk/format_ng.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_ng.h?view=diff&rev=406168&r1=406167&r2=406168
==============================================================================
--- team/group/media_formats/include/asterisk/format_ng.h (original)
+++ team/group/media_formats/include/asterisk/format_ng.h Wed Jan 22 09:58:16 2014
@@ -41,6 +41,11 @@
/*! \brief Optional format interface to extend format operations */
struct ast_format_interface {
+ /*!
+ * \brief Callback for when the format is destroyed, used to release attribute resources
+ */
+ void (*const format_destroy)(struct ast_format *format);
+
/*!
* \brief Determine if format 1 is a subset of format 2.
*
Modified: team/group/media_formats/main/format_ng.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format_ng.c?view=diff&rev=406168&r1=406167&r2=406168
==============================================================================
--- team/group/media_formats/main/format_ng.c (original)
+++ team/group/media_formats/main/format_ng.c Wed Jan 22 09:58:16 2014
@@ -41,6 +41,11 @@
{
struct ast_format *format = obj;
+ if (format->interface) {
+ format->interface->format_destroy(format);
+ ao2_ref(format->interface, -1);
+ }
+
ao2_cleanup(format->codec);
}
@@ -77,10 +82,11 @@
return NULL;
}
- /* If no attribute data exists these are the same format, and thus we don't need to
- * create a new one - we can just return one of them with reference count bumped!
+ /* If the two formats are the same structure OR if the codec is the same and no attributes
+ * exist we can immediately return a format with reference count bumped up, since they are
+ * the same.
*/
- if (!format1->attribute_data && !format2->attribute_data) {
+ if ((format1 == format2) || (!format1->attribute_data && !format2->attribute_data)) {
return ao2_bump((struct ast_format*)format1);
}
More information about the asterisk-commits
mailing list