[asterisk-commits] audiohooks: Muting a hook can mute underlying frames (asterisk[14])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 2 11:51:19 CST 2017
Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4864 )
Change subject: audiohooks: Muting a hook can mute underlying frames
......................................................................
audiohooks: Muting a hook can mute underlying frames
If an audiohook is placed on a channel that does not require transcoding,
muting that hook will cause the underlying frames to be muted as well.
The original patch is from David Woolley but I have modified slightly.
ASTERISK-21094 #close
Reported by: David Woolley
Patches:
ASTERISK-21094-Patch-1.8-1.txt (license #5737) patch uploaded
by David Woolley
Change-Id: Ib2b68c6283e227cbeb5fa478b2d0f625dae338ed
---
M main/audiohook.c
1 file changed, 22 insertions(+), 18 deletions(-)
Approvals:
George Joseph: Looks good to me, approved
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/main/audiohook.c b/main/audiohook.c
index 4a73fbd..62c090e 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -158,6 +158,11 @@
return 0;
}
+#define SHOULD_MUTE(hook, dir) \
+ ((ast_test_flag(hook, AST_AUDIOHOOK_MUTE_READ) && (dir == AST_AUDIOHOOK_DIRECTION_READ)) || \
+ (ast_test_flag(hook, AST_AUDIOHOOK_MUTE_WRITE) && (dir == AST_AUDIOHOOK_DIRECTION_WRITE)) || \
+ (ast_test_flag(hook, AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE) == (AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE)))
+
/*! \brief Writes a frame into the audiohook structure
* \param audiohook Audiohook structure
* \param direction Direction the audio frame came from
@@ -173,7 +178,6 @@
int our_factory_ms;
int other_factory_samples;
int other_factory_ms;
- int muteme = 0;
/* Update last feeding time to be current */
*rwtime = ast_tvnow();
@@ -197,17 +201,6 @@
ast_debug(1, "Audiohook %p has stale audio in its factories. Flushing them both\n", audiohook);
ast_slinfactory_flush(factory);
ast_slinfactory_flush(other_factory);
- }
-
- /* swap frame data for zeros if mute is required */
- if ((ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ) && (direction == AST_AUDIOHOOK_DIRECTION_READ)) ||
- (ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_WRITE) && (direction == AST_AUDIOHOOK_DIRECTION_WRITE)) ||
- (ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE) == (AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE))) {
- muteme = 1;
- }
-
- if (muteme && frame->datalen > 0) {
- ast_frame_clear(frame);
}
/* Write frame out to respective factory */
@@ -248,8 +241,11 @@
return NULL;
}
- /* If a volume adjustment needs to be applied apply it */
- if (vol) {
+ if (SHOULD_MUTE(audiohook, direction)) {
+ /* Swap frame data for zeros if mute is required */
+ ast_frame_clear(&frame);
+ } else if (vol) {
+ /* If a volume adjustment needs to be applied apply it */
ast_frame_adjust_volume(&frame, vol);
}
@@ -298,8 +294,12 @@
if (usable_read) {
if (ast_slinfactory_read(&audiohook->read_factory, buf1, samples)) {
read_buf = buf1;
- /* Adjust read volume if need be */
- if (audiohook->options.read_volume) {
+
+ if ((ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ))) {
+ /* Clear the frame data if we are muting */
+ memset(buf1, 0, sizeof(buf1));
+ } else if (audiohook->options.read_volume) {
+ /* Adjust read volume if need be */
adjust_value = abs(audiohook->options.read_volume);
for (count = 0; count < samples; count++) {
if (audiohook->options.read_volume > 0) {
@@ -318,8 +318,12 @@
if (usable_write) {
if (ast_slinfactory_read(&audiohook->write_factory, buf2, samples)) {
write_buf = buf2;
- /* Adjust write volume if need be */
- if (audiohook->options.write_volume) {
+
+ if ((ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_WRITE))) {
+ /* Clear the frame data if we are muting */
+ memset(buf2, 0, sizeof(buf2));
+ } else if (audiohook->options.write_volume) {
+ /* Adjust write volume if need be */
adjust_value = abs(audiohook->options.write_volume);
for (count = 0; count < samples; count++) {
if (audiohook->options.write_volume > 0) {
--
To view, visit https://gerrit.asterisk.org/4864
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib2b68c6283e227cbeb5fa478b2d0f625dae338ed
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list