[asterisk-commits] mnicholson: branch irroot/t38gateway-trunk r324363 - /team/irroot/t38gateway-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 21 12:26:36 CDT 2011


Author: mnicholson
Date: Tue Jun 21 12:26:33 2011
New Revision: 324363

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=324363
Log:
cleaned up a few functions

Modified:
    team/irroot/t38gateway-trunk/res/res_fax_spandsp.c

Modified: team/irroot/t38gateway-trunk/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-trunk/res/res_fax_spandsp.c?view=diff&rev=324363&r1=324362&r2=324363
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax_spandsp.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax_spandsp.c Tue Jun 21 12:26:33 2011
@@ -183,6 +183,7 @@
  */
 static int t38_tx_packet_handler(t38_core_state_t *t38_core_state, void *data, const uint8_t *buf, int len, int count)
 {
+	int res = -1;
 	struct ast_fax_session *s = data;
 	struct spandsp_pvt *p = s->tech_pvt;
 	struct ast_frame fax_frame = {
@@ -200,24 +201,23 @@
 	AST_FRAME_SET_BUFFER(f, buf, 0, len);
 
 	if (!(f = ast_frisolate(f))) {
-		return -1;
+		return res;
 	}
 
 	if (s->details->caps & AST_FAX_TECH_GATEWAY) {
 		ast_set_flag(f, AST_FAX_FRFLAG_GATEWAY);
 		if (p->ast_t38_state == T38_STATE_NEGOTIATED) {
-			return ast_write(s->chan, f);
+			res = ast_write(s->chan, f);
 		} else {
-			int res = ast_queue_frame(s->chan, f);
-			ast_frfree(f);
-			return res;
+			res = ast_queue_frame(s->chan, f);
 		}
+		ast_frfree(f);
 	} else {
 		/* no need to lock, this all runs in the same thread */
 		AST_LIST_INSERT_TAIL(&p->read_frames, f, frame_list);
 	}
 
-	return 0;
+	return res;
 }
 
 static int update_stats(struct spandsp_pvt *p, int completion_code)
@@ -608,6 +608,7 @@
  * \return -1 on failure or 0 on sucess*/
 static int spandsp_fax_gw_t30_gen(struct ast_channel *chan, void *data, int len, int samples)
 {
+	int res = -1;
 	struct ast_fax_session *s = data;
 	struct spandsp_pvt *p = s->tech_pvt;
 	uint8_t buffer[AST_FRIENDLY_OFFSET + samples * sizeof(uint16_t)];
@@ -621,19 +622,21 @@
 
 	AST_FRAME_SET_BUFFER(&t30_frame, buffer, AST_FRIENDLY_OFFSET, t30_frame.samples * sizeof(int16_t));
 
+	ast_format_set(&t30_frame.subclass.format, AST_FORMAT_SLINEAR, 0);
+	if (!(f = ast_frisolate(&t30_frame))) {
+		return res;
+	}
+
 	/* generate a T.30 packet */
-	ast_format_set(&t30_frame.subclass.format, AST_FORMAT_SLINEAR, 0);
-	f = ast_frisolate(&t30_frame);
 	if ((f->samples = t38_gateway_tx(&p->t38_gw_state, f->data.ptr, f->samples))) {
+		res = 0;
 		f->datalen = f->samples * sizeof(int16_t);
 		if (ast_write(chan, f) < 0) {
-			ast_frfree(f);
-			return -1;
+			res = -1;
 		}
-		ast_frfree(f);
-		return 0;
-	}
-	return -1;
+	}
+	ast_frfree(f);
+	return res;
 }
 
 /*! \brief simple routine to allocate data to generator




More information about the asterisk-commits mailing list