use API call for frame volume adjustment

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6878 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Kevin P. Fleming 20 years ago
parent a0cb07e467
commit f9a98f7110

@ -384,20 +384,6 @@ static void reset_volumes(struct ast_conf_user *user)
ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &zero_volume, sizeof(zero_volume), 0); ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &zero_volume, sizeof(zero_volume), 0);
} }
static void adjust_volume(struct ast_frame *f, int vol)
{
int count;
short *fdata = f->data;
for (count = 0; count < (f->datalen / sizeof(*fdata)); count++) {
if (vol > 0) {
fdata[count] *= abs(vol);
} else if (vol < 0) {
fdata[count] /= abs(vol);
}
}
}
static void conf_play(struct ast_channel *chan, struct ast_conference *conf, int sound) static void conf_play(struct ast_channel *chan, struct ast_conference *conf, int sound)
{ {
unsigned char *data; unsigned char *data;
@ -1239,9 +1225,9 @@ zapretry:
if (!f) if (!f)
break; break;
if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) { if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
if (user->talk.actual) { if (user->talk.actual)
adjust_volume(f, user->talk.actual); ast_frame_adjust_volume(f, user->talk.actual);
}
if (confflags & CONFFLAG_MONITORTALKER) { if (confflags & CONFFLAG_MONITORTALKER) {
int totalsilence; int totalsilence;
if (user->talking == -1) if (user->talking == -1)
@ -1476,7 +1462,7 @@ zapretry:
fr.data = buf; fr.data = buf;
fr.offset = AST_FRIENDLY_OFFSET; fr.offset = AST_FRIENDLY_OFFSET;
if (user->listen.actual) if (user->listen.actual)
adjust_volume(&fr, user->listen.actual); ast_frame_adjust_volume(&fr, user->listen.actual);
if (ast_write(chan, &fr) < 0) { if (ast_write(chan, &fr) < 0) {
ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno));
/* break; */ /* break; */

Loading…
Cancel
Save