[Asterisk-code-review] translate.c: Take sampling rate into account when checking codec's bu... (asterisk[16])
Jean Aunis - Prescom
asteriskteam at digium.com
Wed Apr 28 01:15:15 CDT 2021
Jean Aunis - Prescom has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15832 )
Change subject: translate.c: Take sampling rate into account when checking codec's buffer size
......................................................................
translate.c: Take sampling rate into account when checking codec's buffer size
Up/down sampling changes the number of samples produced by a translation.
This must be taken into account when checking the codec's buffer size.
ASTERISK-29328
Change-Id: I9aebe2f8788e00321a7f5c47aa97c617f39e9055
---
M main/translate.c
1 file changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/15832/1
diff --git a/main/translate.c b/main/translate.c
index a9665ae..6604d14 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -408,12 +408,18 @@
}
}
if (pvt->t->buffer_samples) { /* do not pass empty frames to callback */
+ int src_srate = pvt->t->src_codec.sample_rate;
+ int dst_srate = pvt->t->dst_codec.sample_rate;
+
+ ast_assert(src_srate > 0);
+
if (f->datalen == 0) { /* perform native PLC if available */
/* If the codec has native PLC, then do that */
if (!pvt->t->native_plc)
return 0;
}
- if (pvt->samples + f->samples > pvt->t->buffer_samples) {
+
+ if (pvt->samples + (f->samples * dst_srate / src_srate) > pvt->t->buffer_samples) {
ast_log(LOG_WARNING, "Out of buffer space\n");
return -1;
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15832
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I9aebe2f8788e00321a7f5c47aa97c617f39e9055
Gerrit-Change-Number: 15832
Gerrit-PatchSet: 1
Gerrit-Owner: Jean Aunis - Prescom <jean.aunis at prescom.fr>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210428/b3ae829a/attachment-0001.html>
More information about the asterisk-code-review
mailing list