From ce46416cb31f2571fc2de3a1962357718732b655 Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Thu, 14 Dec 2000 13:50:41 +0000
Subject: [PATCH] Version 0.1.5 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@222 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 CHANGES               |  3 +++
 channels/chan_iax.c   |  2 +-
 channels/chan_phone.c | 32 ++++++++++++++++++++------------
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/CHANGES b/CHANGES
index 1c3effcc34..2fdacbca5b 100755
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+* Asterisk 0.1.5
+ -- Fix a small mistake in IAX
+ -- Fix the QuickNet driver to work with newer cards
 * Asterisk 0.1.4
  -- Update VoFR some more
  -- Fix the QuickNet driver to work with LineJack
diff --git a/channels/chan_iax.c b/channels/chan_iax.c
index 272228e86a..010dbffa07 100755
--- a/channels/chan_iax.c
+++ b/channels/chan_iax.c
@@ -1893,7 +1893,7 @@ static struct ast_channel *iax_request(char *type, int format, void *data)
 	char *st;
 	struct ast_channel *c;
 	strncpy(s, (char *)data, sizeof(s));
-	strtok(s, ":");
+	strtok(s, "/");
 	strtok(s, "@");
 	st = strtok(NULL, "@");
 	if (!st)
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 6b59574242..3bdfdfd26e 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -284,7 +284,8 @@ static struct ast_frame  *phone_read(struct ast_channel *ast)
 
 	phonee.bytes = ioctl(p->fd, PHONE_EXCEPTION);
 	if (phonee.bits.dtmf_ready)  {
-		ast_log(LOG_DEBUG, "phone_read(): DTMF\n");
+		if (option_debug)
+			ast_log(LOG_DEBUG, "phone_read(): DTMF\n");
 	
 		/* We've got a digit -- Just handle this nicely and easily */
 		digit =  ioctl(p->fd, PHONE_GET_DTMF_ASCII);
@@ -293,10 +294,12 @@ static struct ast_frame  *phone_read(struct ast_channel *ast)
 		return &p->fr;
 	}
 	if (phonee.bits.hookstate) {
-		ast_log(LOG_DEBUG, "Hookstate changed\n");
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Hookstate changed\n");
 		res = ioctl(p->fd, PHONE_HOOKSTATE);
 		/* See if we've gone on hook, if so, notify by returning NULL */
-		ast_log(LOG_DEBUG, "New hookstate: %d\n", res);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "New hookstate: %d\n", res);
 		if (!res && (p->mode != MODE_FXO))
 			return NULL;
 		else {
@@ -396,6 +399,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
 	char *pos;
 	int sofar;
 	int expected;
+	int codecset = 0;
 	char tmpbuf[4];
 	/* Write a frame of (presumably voice) data */
 	if (frame->frametype != AST_FRAME_VOICE) {
@@ -429,6 +433,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
 			p->lastinput = AST_FORMAT_G723_1;
 			/* Reset output buffer */
 			p->obuflen = 0;
+			codecset = 1;
 		}
 		if (frame->datalen > 24) {
 			ast_log(LOG_WARNING, "Frame size too large for G.723.1 (%d bytes)\n", frame->datalen);
@@ -449,20 +454,23 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
 			}
 			p->lastformat = AST_FORMAT_SLINEAR;
 			p->lastinput = AST_FORMAT_SLINEAR;
+			codecset = 1;
 			/* Reset output buffer */
 			p->obuflen = 0;
 		}
 		maxfr = 480;
 	}
-	ioctl(p->fd, PHONE_REC_DEPTH, 3);
-	ioctl(p->fd, PHONE_PLAY_DEPTH, 3);
-	if (ioctl(p->fd, PHONE_PLAY_START)) {
-		ast_log(LOG_WARNING, "Failed to start playback\n");
-		return -1;
-	}
-	if (ioctl(p->fd, PHONE_REC_START)) {
-		ast_log(LOG_WARNING, "Failed to start recording\n");
-		return -1;
+	if (codecset) {
+		ioctl(p->fd, PHONE_REC_DEPTH, 3);
+		ioctl(p->fd, PHONE_PLAY_DEPTH, 3);
+		if (ioctl(p->fd, PHONE_PLAY_START)) {
+			ast_log(LOG_WARNING, "Failed to start playback\n");
+			return -1;
+		}
+		if (ioctl(p->fd, PHONE_REC_START)) {
+			ast_log(LOG_WARNING, "Failed to start recording\n");
+			return -1;
+		}
 	}
 	/* If we get here, we have a voice frame of Appropriate data */
 	sofar = 0;
-- 
GitLab