[Asterisk-code-review] formats: Changed file-block reading from 20ms to 10ms. (asterisk[11])

Alexander Traud asteriskteam at digium.com
Wed Oct 21 06:46:47 CDT 2015


Alexander Traud has uploaded a new change for review.

  https://gerrit.asterisk.org/1460

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: I5aa21a3c4f3a4ea78ac3cc80a3883317648464a4
---
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/60/1460/1

diff --git a/formats/format_g729.c b/formats/format_g729.c
index f11fa97..26795e0 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -42,8 +42,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 1ee333f..e67a8b6 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -38,7 +38,7 @@
 #include "asterisk/ulaw.h"
 #include "asterisk/alaw.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 30a1ebe..4f57dbf 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -128,7 +128,7 @@
 }
 
 static int slinear_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR);}
-static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 320, AST_FORMAT_SLINEAR);}
+static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 160, AST_FORMAT_SLINEAR);}
 static struct ast_format_def slin_f = {
 	.name = "sln",
 	.exts = "sln|raw",
@@ -137,11 +137,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear_read,
-	.buf_size = 320 + AST_FRIENDLY_OFFSET,
+	.buf_size = 160 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear12_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR12);}
-static struct ast_frame *slinear12_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 480, AST_FORMAT_SLINEAR12);}
+static struct ast_frame *slinear12_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 240, AST_FORMAT_SLINEAR12);}
 static struct ast_format_def slin12_f = {
 	.name = "sln12",
 	.exts = "sln12",
@@ -150,11 +150,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear12_read,
-	.buf_size = 480 + AST_FRIENDLY_OFFSET,
+	.buf_size = 240 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear16_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR16);}
-static struct ast_frame *slinear16_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 640, AST_FORMAT_SLINEAR16);}
+static struct ast_frame *slinear16_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 320, AST_FORMAT_SLINEAR16);}
 static struct ast_format_def slin16_f = {
 	.name = "sln16",
 	.exts = "sln16",
@@ -163,11 +163,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear16_read,
-	.buf_size = 640 + AST_FRIENDLY_OFFSET,
+	.buf_size = 320 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear24_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR24);}
-static struct ast_frame *slinear24_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 960, AST_FORMAT_SLINEAR24);}
+static struct ast_frame *slinear24_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 480, AST_FORMAT_SLINEAR24);}
 static struct ast_format_def slin24_f = {
 	.name = "sln24",
 	.exts = "sln24",
@@ -176,11 +176,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear24_read,
-	.buf_size = 960 + AST_FRIENDLY_OFFSET,
+	.buf_size = 480 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear32_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR32);}
-static struct ast_frame *slinear32_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1280, AST_FORMAT_SLINEAR32);}
+static struct ast_frame *slinear32_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 640, AST_FORMAT_SLINEAR32);}
 static struct ast_format_def slin32_f = {
 	.name = "sln32",
 	.exts = "sln32",
@@ -189,11 +189,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear32_read,
-	.buf_size = 1280 + AST_FRIENDLY_OFFSET,
+	.buf_size = 640 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear44_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR44);}
-static struct ast_frame *slinear44_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1764, AST_FORMAT_SLINEAR44);}
+static struct ast_frame *slinear44_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 882, AST_FORMAT_SLINEAR44);}
 static struct ast_format_def slin44_f = {
 	.name = "sln44",
 	.exts = "sln44",
@@ -202,11 +202,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear44_read,
-	.buf_size = 1764 + AST_FRIENDLY_OFFSET,
+	.buf_size = 882 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear48_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR48);}
-static struct ast_frame *slinear48_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1920, AST_FORMAT_SLINEAR48);}
+static struct ast_frame *slinear48_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 960, AST_FORMAT_SLINEAR48);}
 static struct ast_format_def slin48_f = {
 	.name = "sln48",
 	.exts = "sln48",
@@ -215,11 +215,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear48_read,
-	.buf_size = 1920 + AST_FRIENDLY_OFFSET,
+	.buf_size = 960 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear96_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR96);}
-static struct ast_frame *slinear96_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 3840, AST_FORMAT_SLINEAR96);}
+static struct ast_frame *slinear96_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1920, AST_FORMAT_SLINEAR96);}
 static struct ast_format_def slin96_f = {
 	.name = "sln96",
 	.exts = "sln96",
@@ -228,11 +228,11 @@
 	.trunc = slinear_trunc,
 	.tell = slinear_tell,
 	.read = slinear96_read,
-	.buf_size = 3840 + AST_FRIENDLY_OFFSET,
+	.buf_size = 1920 + AST_FRIENDLY_OFFSET,
 };
 
 static int slinear192_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR192);}
-static struct ast_frame *slinear192_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 7680, AST_FORMAT_SLINEAR192);}
+static struct ast_frame *slinear192_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 3840, AST_FORMAT_SLINEAR192);}
 static struct ast_format_def slin192_f = {
 	.name = "sln192",
 	.exts = "sln192",
@@ -241,7 +241,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 5418ea0..ee43cf2 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -40,7 +40,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/1460
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5aa21a3c4f3a4ea78ac3cc80a3883317648464a4
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>



More information about the asterisk-code-review mailing list