[Asterisk-code-review] formats: Changed file-block reading from 20ms to 10ms. (asterisk[13])
Alexander Traud
asteriskteam at digium.com
Wed Oct 21 06:45:57 CDT 2015
Alexander Traud has uploaded a new change for review.
https://gerrit.asterisk.org/1462
Change subject: formats: Changed file-block reading from 20ms to 10ms.
......................................................................
formats: Changed file-block reading from 20ms to 10ms.
Asterisk uses the source media as clock generator for sending RTP payload.
Reading the built-in sound files in blocks of 20ms created packet-delay
variantions for iLBC 30 (and all audio codecs which do not use 20ms but are
configured/negotiated to a multiply of 10ms). To avoid this, Asterisk reads in
chunks of 10ms now.
ASTERISK-25483 #close
Change-Id: I87be42be3bcf0eb1ec349612769e1ac664d18e7c
---
M formats/format_g729.c
M formats/format_pcm.c
M formats/format_sln.c
M formats/format_wav.c
4 files changed, 22 insertions(+), 22 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/1462/1
diff --git a/formats/format_g729.c b/formats/format_g729.c
index 2c677b2..d64aa87 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -43,8 +43,8 @@
/* Portions of the conversion code are by guido at sienanet.it */
-#define BUF_SIZE 20 /* two G729 frames */
-#define G729A_SAMPLES 160
+#define BUF_SIZE 10 /* one G729 frame */
+#define G729A_SAMPLES 80
static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
{
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index beb0015..04c6d19 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -39,7 +39,7 @@
#include "asterisk/alaw.h"
#include "asterisk/format_cache.h"
-#define BUF_SIZE 160 /* 160 bytes, and same number of samples */
+#define BUF_SIZE 80 /* 80 bytes, and same number of samples */
static char ulaw_silence[BUF_SIZE];
static char alaw_silence[BUF_SIZE];
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 143e4da..e211adf 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -117,7 +117,7 @@
return ftello(fs->f) / 2;
}
-static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 320);}
+static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 160);}
static struct ast_format_def slin_f = {
.name = "sln",
.exts = "sln|raw",
@@ -126,10 +126,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear_read,
- .buf_size = 320 + AST_FRIENDLY_OFFSET,
+ .buf_size = 160 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear12_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 480);}
+static struct ast_frame *slinear12_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 240);}
static struct ast_format_def slin12_f = {
.name = "sln12",
.exts = "sln12",
@@ -138,10 +138,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear12_read,
- .buf_size = 480 + AST_FRIENDLY_OFFSET,
+ .buf_size = 240 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear16_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 640);}
+static struct ast_frame *slinear16_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 320);}
static struct ast_format_def slin16_f = {
.name = "sln16",
.exts = "sln16",
@@ -150,10 +150,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear16_read,
- .buf_size = 640 + AST_FRIENDLY_OFFSET,
+ .buf_size = 320 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear24_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 960);}
+static struct ast_frame *slinear24_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 480);}
static struct ast_format_def slin24_f = {
.name = "sln24",
.exts = "sln24",
@@ -162,10 +162,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear24_read,
- .buf_size = 960 + AST_FRIENDLY_OFFSET,
+ .buf_size = 480 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear32_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1280);}
+static struct ast_frame *slinear32_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 640);}
static struct ast_format_def slin32_f = {
.name = "sln32",
.exts = "sln32",
@@ -174,10 +174,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear32_read,
- .buf_size = 1280 + AST_FRIENDLY_OFFSET,
+ .buf_size = 640 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear44_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1764);}
+static struct ast_frame *slinear44_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 882);}
static struct ast_format_def slin44_f = {
.name = "sln44",
.exts = "sln44",
@@ -186,10 +186,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear44_read,
- .buf_size = 1764 + AST_FRIENDLY_OFFSET,
+ .buf_size = 882 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear48_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1920);}
+static struct ast_frame *slinear48_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 960);}
static struct ast_format_def slin48_f = {
.name = "sln48",
.exts = "sln48",
@@ -198,10 +198,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear48_read,
- .buf_size = 1920 + AST_FRIENDLY_OFFSET,
+ .buf_size = 960 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear96_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 3840);}
+static struct ast_frame *slinear96_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1920);}
static struct ast_format_def slin96_f = {
.name = "sln96",
.exts = "sln96",
@@ -210,10 +210,10 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear96_read,
- .buf_size = 3840 + AST_FRIENDLY_OFFSET,
+ .buf_size = 1920 + AST_FRIENDLY_OFFSET,
};
-static struct ast_frame *slinear192_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 7680);}
+static struct ast_frame *slinear192_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 3840);}
static struct ast_format_def slin192_f = {
.name = "sln192",
.exts = "sln192",
@@ -222,7 +222,7 @@
.trunc = slinear_trunc,
.tell = slinear_tell,
.read = slinear192_read,
- .buf_size = 7680 + AST_FRIENDLY_OFFSET,
+ .buf_size = 3840 + AST_FRIENDLY_OFFSET,
};
static struct ast_format_def *slin_list[] = {
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 90ef986..86beabb 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -43,7 +43,7 @@
/* Portions of the conversion code are by guido at sienanet.it */
-#define WAV_BUF_SIZE 320
+#define WAV_BUF_SIZE 160
#define WAV_HEADER_SIZE 44
--
To view, visit https://gerrit.asterisk.org/1462
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I87be42be3bcf0eb1ec349612769e1ac664d18e7c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
More information about the asterisk-code-review
mailing list