[Asterisk-code-review] func_scramble: Audio scrambler function (asterisk[master])

Kevin Harwell asteriskteam at digium.com
Wed Aug 11 15:05:24 CDT 2021


Attention is currently required from: N A, Richard Mudgett.
Kevin Harwell has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16231 )

Change subject: func_scramble: Audio scrambler function
......................................................................


Patch Set 7:

(1 comment)

File funcs/func_scramble.c:

https://gerrit.asterisk.org/c/asterisk/+/16231/comment/2fe42ac2_67681860 
PS6, Line 195: 	ast_channel_lock(chan);
             : 	if (!(datastore = ast_channel_datastore_find(chan, &scramble_datastore, NULL))) {
             : 		ast_channel_unlock(chan);
             : 		/* Allocate a new datastore to hold the reference to this audiohook information */
             : 		if (!(datastore = ast_datastore_alloc(&scramble_datastore, NULL))) {
             : 			return 0;
             : 		}
             : 		if (!(ni = ast_calloc(1, sizeof(*ni)))) {
             : 			ast_datastore_free(datastore);
             : 			return 0;
             : 		}
             : 		ast_audiohook_init(&ni->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "Voice scrambler", AST_AUDIOHOOK_MANIPULATE_ALL_RATES);
             : 		ni->audiohook.manipulate_callback = scramble_callback;
             : 		datastore->data = ni;
             : 		ast_channel_lock(chan);
             : 		ast_channel_datastore_add(chan, datastore);
             : 		ast_audiohook_attach(chan, &ni->audiohook);
             : 	} else {
             : 		ni = datastore->data;
             : 	}
             : 	ast_channel_unlock(chan);
> Done - as a general rule of thumb, is this a best practice? In other existing functions setting up a […]
In my opinion those other setups are wrong (yes the same issue exists in those), and it's best to do it with the channel locked throughout the process in order to avoid a possible memory leak, and data corruption.



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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I01020769d91060a1f56a708eb405f87648d1a67e
Gerrit-Change-Number: 16231
Gerrit-PatchSet: 7
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Attention: N A <mail at interlinked.x10host.com>
Gerrit-Attention: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Wed, 11 Aug 2021 20:05:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: N A <mail at interlinked.x10host.com>
Comment-In-Reply-To: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210811/96ee4e71/attachment-0001.html>


More information about the asterisk-code-review mailing list