Minor tweak. Don't manipulate volume of the audio in the buffer if no audio is actually there.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@80157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-08-21 15:51:49 +00:00
parent eaac379751
commit 937d83f7e4

View File

@@ -189,17 +189,18 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho
/* Start with the read factory... if there are enough samples, read them in */
if (ast_slinfactory_available(&audiohook->read_factory) >= samples) {
if (ast_slinfactory_read(&audiohook->read_factory, buf1, samples))
if (ast_slinfactory_read(&audiohook->read_factory, buf1, samples)) {
read_buf = buf1;
/* Adjust read volume if need be */
if (audiohook->options.read_volume) {
int count = 0;
short adjust_value = abs(audiohook->options.read_volume);
for (count = 0; count < samples; count++) {
if (audiohook->options.read_volume > 0)
ast_slinear_saturated_multiply(&buf1[count], &adjust_value);
else if (audiohook->options.read_volume < 0)
ast_slinear_saturated_divide(&buf1[count], &adjust_value);
/* Adjust read volume if need be */
if (audiohook->options.read_volume) {
int count = 0;
short adjust_value = abs(audiohook->options.read_volume);
for (count = 0; count < samples; count++) {
if (audiohook->options.read_volume > 0)
ast_slinear_saturated_multiply(&buf1[count], &adjust_value);
else if (audiohook->options.read_volume < 0)
ast_slinear_saturated_divide(&buf1[count], &adjust_value);
}
}
}
} else if (option_debug)
@@ -207,17 +208,18 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho
/* Move on to the write factory... if there are enough samples, read them in */
if (ast_slinfactory_available(&audiohook->write_factory) >= samples) {
if (ast_slinfactory_read(&audiohook->write_factory, buf2, samples))
if (ast_slinfactory_read(&audiohook->write_factory, buf2, samples)) {
write_buf = buf2;
/* Adjust write volume if need be */
if (audiohook->options.write_volume) {
int count = 0;
short adjust_value = abs(audiohook->options.write_volume);
for (count = 0; count < samples; count++) {
if (audiohook->options.write_volume > 0)
ast_slinear_saturated_multiply(&buf2[count], &adjust_value);
else if (audiohook->options.write_volume < 0)
ast_slinear_saturated_divide(&buf2[count], &adjust_value);
/* Adjust write volume if need be */
if (audiohook->options.write_volume) {
int count = 0;
short adjust_value = abs(audiohook->options.write_volume);
for (count = 0; count < samples; count++) {
if (audiohook->options.write_volume > 0)
ast_slinear_saturated_multiply(&buf2[count], &adjust_value);
else if (audiohook->options.write_volume < 0)
ast_slinear_saturated_divide(&buf2[count], &adjust_value);
}
}
}
} else if (option_debug)