add some sanity code to originate and conference

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3189 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-10-25 01:00:26 +00:00
parent 0fb5729590
commit 252afb823f
4 changed files with 87 additions and 33 deletions

View File

@@ -182,3 +182,37 @@ SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
buf[i] = ((buf[i] >> 8) & 0x00ff) | ((buf[i] << 8) & 0xff00);
}
}
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
{
double newrate = 0;
int div = 0;
switch_normalize_volume(vol);
if (vol > 0) {
vol++;
} else if (vol < 0) {
vol--;
}
newrate = vol * 1.3;
if (vol < 0) {
newrate *= -1;
div++;
}
if (newrate) {
int32_t tmp;
int x;
int16_t *fp = data;
for (x = 0; x < samples; x++) {
tmp = (double) div ? fp[x] / newrate : fp[x] * newrate;
switch_normalize_to_16bit(tmp);
fp[x] = tmp;
}
}
}