[svn-commits] rmudgett: branch group/media_formats-reviewed-trunk r418610 - /team/group/med...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 14 10:50:42 CDT 2014


Author: rmudgett
Date: Mon Jul 14 10:50:36 2014
New Revision: 418610

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418610
Log:
chan_dahdi.c: Restore some sanity checks on frames that dahdi_write() cannot handle.

* Restored some sanity checks in dahdi_write() that were removed earlier
in the formats work.  I know I've seen the incompatible format message in
v12.

* Use ao2_cleanup() on a global pointer in the __unload_module() routine
for safety.

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

Modified:
    team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c

Modified: team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c?view=diff&rev=418610&r1=418609&r2=418610
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c Mon Jul 14 10:50:36 2014
@@ -8781,6 +8781,12 @@
 		return -1;
 	}
 
+	/* Write a frame of (presumably voice) data */
+	if (frame->frametype != AST_FRAME_VOICE) {
+		if (frame->frametype != AST_FRAME_IMAGE)
+			ast_log(LOG_WARNING, "Don't know what to do with frame type '%u'\n", frame->frametype);
+		return 0;
+	}
 	if (p->dialing) {
 		ast_debug(5, "Dropping frame since I'm still dialing on %s...\n",ast_channel_name(ast));
 		return 0;
@@ -8806,7 +8812,8 @@
 				ast_log(LOG_WARNING, "Unable to set linear mode on channel %d\n", p->channel);
 		}
 		res = my_dahdi_write(p, (unsigned char *)frame->data.ptr, frame->datalen, idx, 1);
-	} else {
+	} else if (ast_format_cmp(frame->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL
+		|| ast_format_cmp(frame->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
 		/* x-law already */
 		if (p->subs[idx].linear) {
 			p->subs[idx].linear = 0;
@@ -8815,6 +8822,10 @@
 				ast_log(LOG_WARNING, "Unable to set companded mode on channel %d\n", p->channel);
 		}
 		res = my_dahdi_write(p, (unsigned char *)frame->data.ptr, frame->datalen, idx, 0);
+	} else {
+		ast_log(LOG_WARNING, "Cannot handle frames in %s format\n",
+			ast_format_get_name(frame->subclass.format));
+		return -1;
 	}
 	if (res < 0) {
 		ast_log(LOG_WARNING, "write failed: %s\n", strerror(errno));
@@ -10772,8 +10783,8 @@
 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
 	if (pvt->mwisend_fsk) {
 #endif
-		pvt->cidlen = ast_callerid_vmwi_generate(pvt->cidspill, has_voicemail(pvt), CID_MWI_TYPE_MDMF_FULL,
-							 AST_LAW(pvt), pvt->cid_name, pvt->cid_num, 0);
+		pvt->cidlen = ast_callerid_vmwi_generate(pvt->cidspill, has_voicemail(pvt),
+			CID_MWI_TYPE_MDMF_FULL, AST_LAW(pvt), pvt->cid_name, pvt->cid_num, 0);
 		pvt->cidpos = 0;
 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
 	}
@@ -17300,7 +17311,7 @@
 
 	dahdi_native_unload();
 
-	ao2_ref(dahdi_tech.capabilities, -1);
+	ao2_cleanup(dahdi_tech.capabilities);
 	dahdi_tech.capabilities = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(dahdichannel_type);
 	return 0;




More information about the svn-commits mailing list