[asterisk-commits] bebuild: branch certified-13.1 r429871 - in /certified/branches/13.1: ./ incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 19 15:11:24 CST 2014


Author: bebuild
Date: Fri Dec 19 15:11:17 2014
New Revision: 429871

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=429871
Log:
media: Fix crash when determining sample count of a frame during shutdown.

When shutting down Asterisk the codecs are cleaned up. As a result anything
attempting to get a codec based on ID or details will find that no codec
exists. This currently occurs when determining the sample count of a frame.
This code did not take this situation into account.

This change fixes this by getting the codec directly from the format and
eliminates the lookup. This is both faster and also provides a guarantee
that the codec will exist and will be valid.

ASTERISK-24604 #close
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/4260/
........

Merged revisions 429497 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    certified/branches/13.1/   (props changed)
    certified/branches/13.1/include/asterisk/format.h
    certified/branches/13.1/main/codec.c
    certified/branches/13.1/main/format.c

Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
--- branch-13-merged (original)
+++ branch-13-merged Fri Dec 19 15:11:17 2014
@@ -1,1 +1,1 @@
-/branches/13:429175,429196,429409,429433,429477,429540,429571,429739,429761,429829
+/branches/13:429175,429196,429409,429433,429477,429497,429540,429571,429739,429761,429829

Modified: certified/branches/13.1/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/include/asterisk/format.h?view=diff&rev=429871&r1=429870&r2=429871
==============================================================================
--- certified/branches/13.1/include/asterisk/format.h (original)
+++ certified/branches/13.1/include/asterisk/format.h Fri Dec 19 15:11:17 2014
@@ -276,6 +276,17 @@
 const char *ast_format_get_name(const struct ast_format *format);
 
 /*!
+ * \brief Get the codec associated with a format
+ *
+ * \param format The media format
+ *
+ * \return The codec
+ *
+ * \note The reference count of the returned codec is increased by 1 and must be decremented
+ */
+struct ast_codec *ast_format_get_codec(const struct ast_format *format);
+
+/*!
  * \brief Get the codec identifier associated with a format
  *
  * \param format The media format

Modified: certified/branches/13.1/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/main/codec.c?view=diff&rev=429871&r1=429870&r2=429871
==============================================================================
--- certified/branches/13.1/main/codec.c (original)
+++ certified/branches/13.1/main/codec.c Fri Dec 19 15:11:17 2014
@@ -355,10 +355,7 @@
 		return 0;
 	}
 
-	/* BUGBUG - why not just get the codec pointer off the format?
-	This is a bit roundabout
-	*/
-	codec = ast_codec_get_by_id(ast_format_get_codec_id(frame->subclass.format));
+	codec = ast_format_get_codec(frame->subclass.format);
 
 	if (codec->samples_count) {
 		samples = codec->samples_count(frame);

Modified: certified/branches/13.1/main/format.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/main/format.c?view=diff&rev=429871&r1=429870&r2=429871
==============================================================================
--- certified/branches/13.1/main/format.c (original)
+++ certified/branches/13.1/main/format.c Fri Dec 19 15:11:17 2014
@@ -323,6 +323,11 @@
 	format->interface->format_generate_sdp_fmtp(format, payload, str);
 }
 
+struct ast_codec *ast_format_get_codec(const struct ast_format *format)
+{
+	return ao2_bump(format->codec);
+}
+
 unsigned int ast_format_get_codec_id(const struct ast_format *format)
 {
 	return format->codec->id;




More information about the asterisk-commits mailing list