[asterisk-commits] sruffell: branch sruffell/asterisk-1.4-transcoder r157002 - /team/sruffell/as...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 14 16:21:01 CST 2008


Author: sruffell
Date: Fri Nov 14 16:21:00 2008
New Revision: 157002

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157002
Log:
Do not give frames of length 0 to the hardware.

Modified:
    team/sruffell/asterisk-1.4-transcoder/codecs/codec_dahdi.c

Modified: team/sruffell/asterisk-1.4-transcoder/codecs/codec_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/sruffell/asterisk-1.4-transcoder/codecs/codec_dahdi.c?view=diff&rev=157002&r1=157001&r2=157002
==============================================================================
--- team/sruffell/asterisk-1.4-transcoder/codecs/codec_dahdi.c (original)
+++ team/sruffell/asterisk-1.4-transcoder/codecs/codec_dahdi.c Fri Nov 14 16:21:00 2008
@@ -168,25 +168,32 @@
 
 	if (f->subclass) {
 		int write_size;
-		/* If we received a frame in signed linear format, and the
-		 * hardware doesn't support signed linear format, we need to
-		 * convert it before sending it to the hardware. */
-		if (SLINTOULAW == ztp->soft_slin) {
+		if (!f->datalen) {
+			/* If the datalen is 0, we'll just ignore the frame. */
+			res = 0;
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "codec_zap: " \
+				 "dropping frame of size 0\n");
+		} else if (SLINTOULAW == ztp->soft_slin) {
+			/* If we received a frame in signed linear format, and the
+			 * hardware doesn't support signed linear format, we need to
+			 * convert it before sending it to the hardware. */
 			lintoulaw(pvt, f);
 			write_size = sizeof(ztp->ulaw_buffer);
 			res = write(ztp->fd, ztp->ulaw_buffer, sizeof(ztp->ulaw_buffer)); 
 		} else {
 			write_size = f->datalen;
 			res = write(ztp->fd, f->data, f->datalen); 
-		}
-		if (-1 == res) {
-			ast_log(LOG_ERROR, "Failed to write to transcoder: %s\n", strerror(errno));
-		}
-		if (write_size != res) {
-			ast_log(LOG_ERROR, "Requested write of %d bytes, but only wrote %d bytes.\n", f->datalen, res);
-		}
-		res = -1;
-		pvt->samples += f->samples;
+
+			if (-1 == res) {
+				ast_log(LOG_ERROR, "Failed to write to transcoder: %s\n", strerror(errno));
+			}
+			if (write_size != res) {
+				ast_log(LOG_ERROR, "Requested write of %d bytes, but only wrote %d bytes.\n", f->datalen, res);
+			}
+			res = -1;
+			pvt->samples += f->samples;
+		}
 	} else {
 		/* Fake a return frame for calculation purposes */
 		ztp->fake = 2;




More information about the asterisk-commits mailing list