[asterisk-addons-commits] dcb: trunk r422 - /trunk/chan_mobile.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Sun Aug 12 02:13:46 CDT 2007


Author: dcb
Date: Sun Aug 12 02:13:45 2007
New Revision: 422

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=422
Log:
Changes to address audio quality and 1-way audio issues with some phones.

Modified:
    trunk/chan_mobile.c

Modified: trunk/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/chan_mobile.c?view=diff&rev=422&r1=421&r2=422
==============================================================================
--- trunk/chan_mobile.c (original)
+++ trunk/chan_mobile.c Sun Aug 12 02:13:45 2007
@@ -667,7 +667,7 @@
 	pvt->fr.subclass = AST_FORMAT_SLINEAR;
 	pvt->fr.data = pvt->sco_in_buf + AST_FRIENDLY_OFFSET;
 
-	if ((r = read(pvt->sco_socket, pvt->fr.data, 48)) == 48) {
+	if ((r = recv(pvt->sco_socket, pvt->fr.data, 48, MSG_DONTWAIT)) == 48) {
 		if (pvt->skip_frames == 0) {
 			f = ast_dsp_process(0, pvt->dsp, &pvt->fr);
 			if (f && (f->frametype == AST_FRAME_DTMF_END)) {
@@ -675,17 +675,19 @@
 				pvt->fr.subclass = f->subclass;
 				pvt->skip_frames = pvt->dtmf_skip;
 			}
-			return &pvt->fr;
 		} else {
 			pvt->skip_frames--;
 		}
+		return &pvt->fr;
 	} else if (r == -1) {
-		ast_debug(1, "mbl_read() read error %d.\n", errno);
-		close(pvt->sco_socket);
-		pvt->sco_socket = -1;
-		ast_channel_lock(ast);
-		ast->fds[0] = -1;
-		ast_channel_unlock(ast);
+		if (errno != EAGAIN) {
+			ast_log(LOG_ERROR, "mbl_read() read error %d.\n", errno);
+			close(pvt->sco_socket);
+			pvt->sco_socket = -1;
+			ast_channel_lock(ast);
+			ast->fds[0] = -1;
+			ast_channel_unlock(ast);
+		}
 	} else {
 		ast_debug(1, "mbl_read() read short frame. (%d)\n", r);
 	}
@@ -730,9 +732,12 @@
 
 	pfr = pvt->sco_out_buf;
 	for (i=0; i<num_frames; i++) {
-		if ((r = write(pvt->sco_socket, pfr, 48)) == -1) {
-			close(pvt->sco_socket);
-			pvt->sco_socket = -1;
+		if ((r = send(pvt->sco_socket, pfr, 48, MSG_DONTWAIT)) == -1) {
+			if (errno != EAGAIN) {
+				ast_debug(1, "write error on sco_socket %d.\n", errno);
+				close(pvt->sco_socket);
+				pvt->sco_socket = -1;
+			}
 		}
 		pfr += 48;
 	}
@@ -804,6 +809,7 @@
 	pvt->sco_out_ptr = pvt->sco_out_buf;
 	pvt->sco_out_len = 0;
 	pvt->sent_answer = 0;
+	pvt->skip_frames = 0;
 	
 	chn = ast_channel_alloc(1, state, cid_num, pvt->id, 0, 0, pvt->context, 0, "Mobile/%s-%04lx", pvt->id, ast_random() & 0xffff);
 	if (chn) {
@@ -813,7 +819,7 @@
 		chn->rawwriteformat = prefformat;
 		chn->writeformat = prefformat;
 		chn->readformat = prefformat;
-		chn->readq.first = NULL;
+		AST_LIST_HEAD_INIT_NOLOCK(&chn->readq);
 		chn->tech_pvt = pvt;
 		if (state == AST_STATE_RING)
 			chn->rings = 1;




More information about the asterisk-addons-commits mailing list