From a34c3d3484e781d26f55f2629e0a92de70e24f0e Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Sun, 12 Dec 1999 08:49:19 +0000
Subject: [PATCH] Version 0.1.1 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@135 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 codecs/codec_g723_1.c |  8 +++++++-
 codecs/codec_gsm.c    | 12 +++++++-----
 formats/Makefile      |  7 ++-----
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/codecs/codec_g723_1.c b/codecs/codec_g723_1.c
index d33ba87833..89d2be7604 100755
--- a/codecs/codec_g723_1.c
+++ b/codecs/codec_g723_1.c
@@ -7,7 +7,7 @@
  * it is covered with patents, and in spite of statements to the contrary,
  * the "technology" is extremely expensive to license.
  * 
- * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+ * Copyright (C) 1999, Mark Spencer
  *
  * Mark Spencer <markster@linux-support.net>
  *
@@ -99,6 +99,8 @@ static struct ast_translator_pvt *g723tolin_new()
 		Init_Decod(&tmp->dec);
 	    Init_Dec_Cng(&tmp->dec);
 		tmp->tail = 0;
+		localusecnt++;
+		ast_update_use_count();
 	}
 	return (struct ast_translator_pvt *)tmp;
 }
@@ -144,6 +146,8 @@ static struct ast_translator_pvt *lintog723_new()
    	   		Init_Vad(&tmp->cod);
         	Init_Cod_Cng(&tmp->cod);
     	 }
+		localusecnt++;
+		ast_update_use_count();
 		tmp->tail = 0;
 	}
 	return (struct ast_translator_pvt *)tmp;
@@ -291,6 +295,8 @@ static struct ast_frame *lintog723_frameout(struct ast_translator_pvt *pvt)
 static void g723_destroy(struct ast_translator_pvt *pvt)
 {
 	free(pvt);
+	localusecnt--;
+	ast_update_use_count();
 }
 
 static struct ast_translator g723tolin =
diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c
index 05ef8d657c..169371230b 100755
--- a/codecs/codec_gsm.c
+++ b/codecs/codec_gsm.c
@@ -6,7 +6,7 @@
  * The GSM code is from TOAST.  Copyright information for that package is available
  * in  the GSM directory.
  * 
- * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+ * Copyright (C) 1999, Mark Spencer
  *
  * Mark Spencer <markster@linux-support.net>
  *
@@ -65,6 +65,7 @@ static struct ast_translator_pvt *gsm_new()
 			tmp = NULL;
 		}
 		tmp->tail = 0;
+		localusecnt++;
 	}
 	return tmp;
 }
@@ -90,8 +91,8 @@ static struct ast_frame *gsmtolin_sample()
 	f.frametype = AST_FRAME_VOICE;
 	f.subclass = AST_FORMAT_GSM;
 	f.datalen = sizeof(gsm_slin_ex);
-	/* All frames are 30 ms long */
-	f.timelen = 30;
+	/* All frames are 20 ms long */
+	f.timelen = 20;
 	f.mallocd = 0;
 	f.offset = 0;
 	f.src = __PRETTY_FUNCTION__;
@@ -156,7 +157,7 @@ static int lintogsm_framein(struct ast_translator_pvt *tmp, struct ast_frame *f)
 	   is too old, then we should overwrite it entirely, otherwise we can
 	   get artifacts of earlier talk that do not belong */
 	if (tmp->tail + f->datalen < sizeof(tmp->buf) / 2) {
-		memcpy(tmp->buf + tmp->tail, f->data, f->datalen);
+		memcpy((tmp->buf + tmp->tail), f->data, f->datalen);
 		tmp->tail += f->datalen/2;
 	} else {
 		ast_log(LOG_WARNING, "Out of buffer space\n");
@@ -184,7 +185,7 @@ static struct ast_frame *lintogsm_frameout(struct ast_translator_pvt *tmp)
 	tmp->tail -= 160;
 	/* Move the data at the end of the buffer to the front */
 	if (tmp->tail)
-		memmove(tmp->buf, tmp->buf + 160 * 2, tmp->tail * 2);
+		memmove(tmp->buf, tmp->buf + 160, tmp->tail * 2);
 #if 0
 	/* Save a sample frame */
 	{ static int samplefr = 0;
@@ -203,6 +204,7 @@ static struct ast_frame *lintogsm_frameout(struct ast_translator_pvt *tmp)
 static void gsm_destroy_stuff(struct ast_translator_pvt *pvt)
 {
 	free(pvt);
+	localusecnt--;
 }
 
 static struct ast_translator gsmtolin =
diff --git a/formats/Makefile b/formats/Makefile
index e9872c6139..f981e8de20 100755
--- a/formats/Makefile
+++ b/formats/Makefile
@@ -3,7 +3,7 @@
 # 
 # Makefile for file format modules
 #
-# Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+# Copyright (C) 1999, Mark Spencer
 #
 # Mark Spencer <markster@linux-support.net>
 #
@@ -11,7 +11,7 @@
 # the GNU General Public License
 #
 
-FORMAT_LIBS=format_g723.so format_wav.so format_mp3.so # format_wav_gsm.so
+FORMAT_LIBS=format_g723.so format_wav.so format_mp3.so format_wav_gsm.so format_gsm.so
 
 GSMLIB=../codecs/gsm/lib/libgsm.a
 
@@ -28,8 +28,5 @@ clean:
 format_wav.so : format_wav.o
 	$(CC) -shared -Xlinker -x -o $@ $< -laudiofile
 
-format_wav_gsm.so : format_wav_gsm.o
-	$(CC) -shared -Xlinker -x -o $@ $< $(LIBGSM)
-
 install: all
 	for x in $(FORMAT_LIBS); do $(INSTALL) -m 755 $$x $(MODULES_DIR) ; done
-- 
GitLab