From 8b14e5f4931dea5116900b19dea20d0a03d1e287 Mon Sep 17 00:00:00 2001
From: Tilghman Lesher <tilghman@meg.abyt.es>
Date: Thu, 9 Oct 2008 21:47:02 +0000
Subject: [PATCH] Reverting format addition for now

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@148071 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_minivm.c     |  5 +--
 apps/app_voicemail.c  | 20 +++--------
 channels/chan_agent.c |  7 ++--
 formats/format_wav.c  | 83 +++++++------------------------------------
 main/file.c           |  2 --
 res/res_monitor.c     |  2 +-
 6 files changed, 20 insertions(+), 99 deletions(-)

diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index b900f2f1bc..c151068df3 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -917,11 +917,8 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
 
 	ast_debug(3, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name);
 
-	if (!strcmp(format, "wav49")) {
+	if (!strcmp(format, "wav49"))
 		format = "WAV";
-	} else if (!strcmp(format, "wav16")) {
-		format = "Wav";
-	}
 
 
 	/* If we have a gain option, process it now with sox */
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 87b10b1662..9f2c335e8d 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1755,11 +1755,8 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i
 		tempcopy = 1;
 	}
 
-	if (!strcmp(fmt, "wav49")) {
+	if (!strcmp(fmt, "wav49"))
 		fmt = "WAV";
-	} else if (!strcmp(fmt, "wav16")) {
-		fmt = "Wav";
-	}
 	ast_debug(3, "Storing file '%s', format '%s'\n", fn, fmt);
 
 	/* Make a temporary file instead of piping directly to sendmail, in case the mail
@@ -2756,11 +2753,8 @@ static int retrieve_file(char *dir, int msgnum)
 		c = strchr(fmt, '|');
 		if (c)
 			*c = '\0';
-		if (!strcasecmp(fmt, "wav49")) {
+		if (!strcasecmp(fmt, "wav49"))
 			strcpy(fmt, "WAV");
-		} else if (!strcasecmp(fmt, "wav16")) {
-			strcpy(fmt, "Wav");
-		}
 		snprintf(msgnums, sizeof(msgnums),"%d", msgnum);
 		if (msgnum > -1)
 			make_file(fn, sizeof(fn), dir, msgnum);
@@ -3173,11 +3167,8 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms
 		c = strchr(fmt, '|');
 		if (c)
 			*c = '\0';
-		if (!strcasecmp(fmt, "wav49")) {
+		if (!strcasecmp(fmt, "wav49"))
 			strcpy(fmt, "WAV");
-		} else if (!strcasecmp(fmt, "wav16")) {
-			strcpy(fmt, "Wav");
-		}
 		snprintf(msgnums, sizeof(msgnums),"%d", msgnum);
 		if (msgnum > -1)
 			make_file(fn, sizeof(fn), dir, msgnum);
@@ -3998,11 +3989,8 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *c
 		ast_log(AST_LOG_WARNING, "E-mail address missing for mailbox [%s].  E-mail will not be sent.\n", vmu->mailbox);
 		return(0);
 	}
-	if (!strcmp(format, "wav49")) {
+	if (!strcmp(format, "wav49"))
 		format = "WAV";
-	} else if (!strcmp(format, "wav16")) {
-		format = "Wav";
-	}
 	ast_debug(3, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
 	/* Make a temporary file instead of piping directly to sendmail, in case the mail
 	   command hangs */
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 3a810d97e6..f84c0f0119 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1201,13 +1201,10 @@ static int read_agent_config(int reload)
 			recordagentcalls = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "recordformat")) {
 			ast_copy_string(recordformat, v->value, sizeof(recordformat));
-			if (!strcasecmp(v->value, "wav49")) {
+			if (!strcasecmp(v->value, "wav49"))
 				strcpy(recordformatext, "WAV");
-			} else if (!strcasecmp(v->value, "wav16")) {
-				strcpy(recordformatext, "Wav");
-			} else {
+			else
 				ast_copy_string(recordformatext, v->value, sizeof(recordformatext));
-			}
 		} else if (!strcasecmp(v->name, "urlprefix")) {
 			ast_copy_string(urlprefix, v->value, sizeof(urlprefix));
 			if (urlprefix[strlen(urlprefix) - 1] != '/')
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 6bee6b4b4f..5cf39ce993 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -39,7 +39,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #define	WAV_BUF_SIZE	320
 
 struct wav_desc {	/* format-specific parameters */
-	int which;
 	int bytes;
 	int lasttimeout;
 	int maxlen;
@@ -71,7 +70,7 @@ struct wav_desc {	/* format-specific parameters */
 #endif
 
 
-static int check_header(FILE *f, int which)
+static int check_header(FILE *f)
 {
 	int type, size, formtype;
 	int fmt, hsize;
@@ -136,10 +135,7 @@ static int check_header(FILE *f, int which)
 		ast_log(LOG_WARNING, "Read failed (freq)\n");
 		return -1;
 	}
-	if (ltohl(freq) != DEFAULT_SAMPLE_RATE && which == 8000) {
-		ast_log(LOG_WARNING, "Unexpected freqency %d\n", ltohl(freq));
-		return -1;
-	} else if (ltohl(freq) != 16000 && which == 16000) {
+	if (ltohl(freq) != DEFAULT_SAMPLE_RATE) {
 		ast_log(LOG_WARNING, "Unexpected freqency %d\n", ltohl(freq));
 		return -1;
 	}
@@ -243,7 +239,7 @@ static int update_header(FILE *f)
 	return 0;
 }
 
-static int write_header(FILE *f, int which)
+static int write_header(FILE *f)
 {
 	unsigned int hz=htoll(8000);
 	unsigned int bhz = htoll(16000);
@@ -253,11 +249,6 @@ static int write_header(FILE *f, int which)
 	unsigned short bysam = htols(2);
 	unsigned short bisam = htols(16);
 	unsigned int size = htoll(0);
-	if (which == 16000) {
-		hz = htoll(16000);
-		bhz = htoll(32000);
-	}
-
 	/* Write a wav header, ignoring sizes which will be filled in later */
 	fseek(f,0,SEEK_SET);
 	if (fwrite("RIFF", 1, 4, f) != 4) {
@@ -317,37 +308,22 @@ static int wav_open(struct ast_filestream *s)
 	   if we did, it would go here.  We also might want to check
 	   and be sure it's a valid file.  */
 	struct wav_desc *tmp = (struct wav_desc *)s->_private;
-	if ((tmp->maxlen = check_header(s->f, tmp->which)) < 0)
+	if ((tmp->maxlen = check_header(s->f)) < 0)
 		return -1;
 	return 0;
 }
 
-static int wav16_open(struct ast_filestream *s)
-{
-	struct wav_desc *tmp = (struct wav_desc *)s->_private;
-	tmp->which = 16000;
-	return wav_open(s);
-}
-
 static int wav_rewrite(struct ast_filestream *s, const char *comment)
 {
 	/* We don't have any header to read or anything really, but
 	   if we did, it would go here.  We also might want to check
 	   and be sure it's a valid file.  */
-	struct wav_desc *tmp = (struct wav_desc *)s->_private;
 
-	if (write_header(s->f, tmp->which))
+	if (write_header(s->f))
 		return -1;
 	return 0;
 }
 
-static int wav16_rewrite(struct ast_filestream *s, const char *comment)
-{
-	struct wav_desc *tmp = (struct wav_desc *)s->_private;
-	tmp->which = 16000;
-	return wav_rewrite(s, comment);
-}
-
 static void wav_close(struct ast_filestream *s)
 {
 	char zero = 0;
@@ -375,10 +351,6 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
 	/* Send a frame from the file to the appropriate channel */
 	struct wav_desc *fs = (struct wav_desc *)s->_private;
 
-	if (fs->which == 16000) {
-		bytes *= 2;
-	}
-
 	here = ftello(s->f);
 	if (fs->maxlen - here < bytes)		/* truncate if necessary */
 		bytes = fs->maxlen - here;
@@ -386,10 +358,10 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
 		bytes = 0;
 /* 	ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = fs->which == 16000 ? AST_FORMAT_SLINEAR16 : AST_FORMAT_SLINEAR;
+	s->fr.subclass = AST_FORMAT_SLINEAR;
 	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
-
+	
 	if ( (res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) <= 0 ) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
@@ -401,7 +373,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
 	tmp = (short *)(s->fr.data.ptr);
 #if __BYTE_ORDER == __BIG_ENDIAN
 	/* file format is little endian so we need to swap */
-	for( x = 0; x < samples * (fs->which == 16000 ? 2 : 1); x++)
+	for( x = 0; x < samples; x++)
 		tmp[x] = (tmp[x] << 8) | ((tmp[x] & 0xff00) >> 8);
 #endif
 
@@ -413,7 +385,7 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
 {
 #if __BYTE_ORDER == __BIG_ENDIAN
 	int x;
-	short tmp[16000], *tmpi;
+	short tmp[8000], *tmpi;
 #endif
 	struct wav_desc *s = (struct wav_desc *)fs->_private;
 	int res;
@@ -422,12 +394,9 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != AST_FORMAT_SLINEAR && s->which == 0) {
+	if (f->subclass != AST_FORMAT_SLINEAR) {
 		ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
 		return -1;
-	} else if (f->subclass != AST_FORMAT_SLINEAR16 && s->which == 16000) {
-		ast_log(LOG_WARNING, "Asked to write non-SLINEAR16 frame (%d)!\n", f->subclass);
-		return -1;
 	}
 	if (!f->datalen)
 		return -1;
@@ -452,15 +421,9 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
 	}
 
 	s->bytes += f->datalen;
-
+		
 	return 0;
-}
 
-static int wav16_write(struct ast_filestream *fs, struct ast_frame *f)
-{
-	struct wav_desc *s = (struct wav_desc *)fs->_private;
-	s->which = 16000;
-	return wav_write(fs, f);
 }
 
 static int wav_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
@@ -517,38 +480,16 @@ static const struct ast_format wav_f = {
 	.desc_size = sizeof(struct wav_desc),
 };
 
-static const struct ast_format Wav_f = {
-	.name = "wav16",
-	.exts = "Wav|wav16",
-	.format = AST_FORMAT_SLINEAR16,
-	.open =	wav16_open,
-	.rewrite = wav16_rewrite,
-	.write = wav16_write,
-	.seek = wav_seek,
-	.trunc = wav_trunc,
-	.tell =	wav_tell,
-	.read = wav_read,
-	.close = wav_close,
-	.buf_size = WAV_BUF_SIZE * 2 + AST_FRIENDLY_OFFSET,
-	.desc_size = sizeof(struct wav_desc),
-};
-
 static int load_module(void)
 {
 	if (ast_format_register(&wav_f))
 		return AST_MODULE_LOAD_FAILURE;
-	ast_format_register(&Wav_f);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int unload_module(void)
 {
-	int res;
-	if (!(res = ast_format_unregister(Wav_f.name))) {
-		return ast_format_unregister(wav_f.name);
-	} else {
-		return res;
-	}
+	return ast_format_unregister(wav_f.name);
 }	
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Microsoft WAV format (8000Hz Signed Linear)");
diff --git a/main/file.c b/main/file.c
index 9b0bfbbb17..a9b36e7f5d 100644
--- a/main/file.c
+++ b/main/file.c
@@ -248,8 +248,6 @@ static char *build_filename(const char *filename, const char *ext)
 
 	if (!strcmp(ext, "wav49"))
 		ext = "WAV";
-	if (!strcmp(ext, "wav16"))
-		ext = "Wav";
 
 	if (filename[0] == '/')
 		asprintf(&fn, "%s.%s", filename, ext);
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 26b18157ab..f3be16f7a5 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -324,7 +324,7 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock)
 		if (chan->monitor->joinfiles && !ast_strlen_zero(chan->monitor->filename_base)) {
 			char tmp[1024];
 			char tmp2[1024];
-			const char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : !strcasecmp(chan->monitor->format, "wav16") ? "Wav" : chan->monitor->format;
+			const char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
 			char *name = chan->monitor->filename_base;
 			int directory = strchr(name, '/') ? 1 : 0;
 			const char *dir = directory ? "" : ast_config_AST_MONITOR_DIR;
-- 
GitLab