[Asterisk-code-review] channel.c: Preserve tone playback on masquerades. (asterisk[master])

N A asteriskteam at digium.com
Sun Nov 20 13:38:04 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19572 )


Change subject: channel.c: Preserve tone playback on masquerades.
......................................................................

channel.c: Preserve tone playback on masquerades.

Currently, masquerades can result in inconsistent
channel state, notably when a tone is playing on
a channel that gets masqueraded.

This fixes this by copying over the generator fd
if there's a generator active so that tone playback
continues as expected after the masquerade.

ASTERISK-30320 #close

Change-Id: I4753d465bd4d5bb7fe205918e0f22b95a5e869e1
---
M main/channel.c
1 file changed, 25 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/72/19572/1

diff --git a/main/channel.c b/main/channel.c
index 97ba0f8..f593ce8 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -7150,8 +7150,13 @@
 
 	/* Copy all file descriptors present on clonechan to original, skipping generator */
 	for (x = 0; x < ast_channel_fd_count(clonechan); x++) {
-		if (x != AST_GENERATOR_FD)
+		/* However, if the original channel had a generator and the new one doesn't,
+		 * then it makes sense to move the generator over.
+		 * This way tone playback is preserved.
+		 */
+		if (x != AST_GENERATOR_FD || (generator_fd == -1 && ast_channel_fd(clonechan, x) > -1)) {
 			ast_channel_set_fd(original, x, ast_channel_fd(clonechan, x));
+		}
 	}
 
 	ast_app_group_update(clonechan, original);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19572
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I4753d465bd4d5bb7fe205918e0f22b95a5e869e1
Gerrit-Change-Number: 19572
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221120/953fae9b/attachment.html>


More information about the asterisk-code-review mailing list