aboutsummaryrefslogtreecommitdiffstats
path: root/formats
diff options
context:
space:
mode:
authordhubbard <dhubbard@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-06 22:29:53 +0000
committerdhubbard <dhubbard@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-06 22:29:53 +0000
commitb8d1a07eff74731f0f1e6ccd455ff9a1d823b427 (patch)
treeb373d55c0960d6e83dc76606a01556ae5c614cc3 /formats
parent47fc8fab177dca4a16fc861c040195e42c17f285 (diff)
removed GAIN preprocessor definition, removed needsgain from struct wav_desc, removed unnecessary gain code from wav_read() and wav_write()
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@60641 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'formats')
-rw-r--r--formats/format_wav.c54
1 files changed, 13 insertions, 41 deletions
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 2081433a6..e9c4e4303 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -53,7 +53,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
struct wav_desc { /* format-specific parameters */
int bytes;
- int needsgain;
int lasttimeout;
int maxlen;
struct timeval last;
@@ -61,9 +60,6 @@ struct wav_desc { /* format-specific parameters */
#define BLOCKSIZE 160
-#define GAIN 0 /* 2^GAIN is the multiple to increase the volume by. The original value of GAIN was 2, or 4x (12 dB),
- * but there were many reports of the clipping of loud signal peaks (issue 5823 for example). */
-
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htoll(b) (b)
#define htols(b) (b)
@@ -387,21 +383,6 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
tmp[x] = (tmp[x] << 8) | ((tmp[x] & 0xff00) >> 8);
#endif
- if (fs->needsgain) {
- for (x=0; x < samples; x++) {
- if (tmp[x] & ((1 << GAIN) - 1)) {
- /* If it has data down low, then it's not something we've artificially increased gain
- on, so we don't need to gain adjust it */
- fs->needsgain = 0;
- break;
- }
- }
- if (fs->needsgain) {
- for (x=0; x < samples; x++)
- tmp[x] = tmp[x] >> GAIN;
- }
- }
-
*whennext = samples;
return &s->fr;
}
@@ -409,8 +390,9 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
{
int x;
+#if __BYTE_ORDER == __BIG_ENDIAN
short tmp[8000], *tmpi;
- float tmpf;
+#endif
struct wav_desc *s = (struct wav_desc *)fs->private;
int res;
@@ -422,34 +404,24 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
return -1;
}
+ if (!f->datalen)
+ return -1;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+ /* swap and write */
if (f->datalen > sizeof(tmp)) {
ast_log(LOG_WARNING, "Data length is too long\n");
return -1;
}
- if (!f->datalen)
- return -1;
-
-#if 0
- printf("Data Length: %d\n", f->datalen);
-#endif
-
tmpi = f->data;
- /* Volume adjust here to accomodate */
- for (x=0;x<f->datalen/2;x++) {
- tmpf = ((float)tmpi[x]) * ((float)(1 << GAIN));
- if (tmpf > 32767.0)
- tmpf = 32767.0;
- if (tmpf < -32768.0)
- tmpf = -32768.0;
- tmp[x] = tmpf;
- tmp[x] &= ~((1 << GAIN) - 1);
-
-#if __BYTE_ORDER == __BIG_ENDIAN
- tmp[x] = (tmp[x] << 8) | ((tmp[x] & 0xff00) >> 8);
-#endif
+ for (x=0; x < f->datalen/2; x++)
+ tmp[x] = (tmpi[x] << 8) | ((tmpi[x] & 0xff00) >> 8);
- }
if ((res = fwrite(tmp, 1, f->datalen, fs->f)) != f->datalen ) {
+#else
+ /* just write */
+ if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen ) {
+#endif
ast_log(LOG_WARNING, "Bad write (%d): %s\n", res, strerror(errno));
return -1;
}