[Asterisk-code-review] translate.c: Fix silk 24kHz truncation in 'core show translation' (asterisk[master])

Joshua Colp asteriskteam at digium.com
Wed Jan 22 08:33:59 CST 2020


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13655 )

Change subject: translate.c: Fix silk 24kHz truncation in 'core show translation'
......................................................................

translate.c: Fix silk 24kHz truncation in 'core show translation'

SILK @ 24kHz is not shown in the 'core show translation' output because of an
off-by-one-error. Discovered while looking into ASTERISK~19871.

ASTERISK-28706
Reported by: Sean Bright

Change-Id: Ie1a551a8a484e07b45c8699cc0c90f1061029510
---
M main/translate.c
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/main/translate.c b/main/translate.c
index 5542107..6648931 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -983,14 +983,14 @@
 {
 	int x, y, i, k;
 	int longest = 7; /* slin192 */
-	int num_codecs = 0, curlen = 0;
+	int max_codec_index = 0, curlen = 0;
 	struct ast_str *out = ast_str_create(1024);
 	struct ast_codec *codec;
 
 	/* Get the length of the longest (usable?) codec name,
 	   so we know how wide the left side should be */
 	for (i = 1; (codec = ast_codec_get_by_id(i)); ao2_ref(codec, -1), ++i) {
-		++num_codecs;
+		++max_codec_index;
 		if (codec->type != AST_MEDIA_TYPE_AUDIO) {
 			continue;
 		}
@@ -1004,7 +1004,7 @@
 	ast_cli(a->fd, "         Translation times between formats (in microseconds) for one second of data\n");
 	ast_cli(a->fd, "          Source Format (Rows) Destination Format (Columns)\n\n");
 
-	for (i = 0; i < num_codecs; i++) {
+	for (i = 0; i <= max_codec_index; i++) {
 		struct ast_codec *row = i ? ast_codec_get_by_id(i) : NULL;
 
 		x = -1;
@@ -1019,7 +1019,7 @@
 		}
 
 		ast_str_set(&out, 0, " ");
-		for (k = 0; k < num_codecs; k++) {
+		for (k = 0; k <= max_codec_index; k++) {
 			int adjust = 0;
 			struct ast_codec *col = k ? ast_codec_get_by_id(k) : NULL;
 

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ie1a551a8a484e07b45c8699cc0c90f1061029510
Gerrit-Change-Number: 13655
Gerrit-PatchSet: 3
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200122/c94a7301/attachment.html>


More information about the asterisk-code-review mailing list