From 522dec1678e19f6e5378cf9c66c05823c498b4a2 Mon Sep 17 00:00:00 2001 From: file Date: Tue, 21 Aug 2007 15:51:49 +0000 Subject: Minor tweak. Don't manipulate volume of the audio in the buffer if no audio is actually there. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@80157 f38db490-d61c-443f-a65b-d21fe96a405b --- main/audiohook.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/main/audiohook.c b/main/audiohook.c index a7600a356..b1df90127 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -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) -- cgit v1.2.3