From 957fff010c04043f7ed26dced42a8fcfb3491ef8 Mon Sep 17 00:00:00 2001
From: Luigi Rizzo <rizzo@icir.org>
Date: Sun, 9 Apr 2006 22:31:38 +0000
Subject: [PATCH] rename FR_SET_BUF to AST_FRAME_SET_BUFFER

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@18639 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 formats/format_g723.c       |  2 +-
 formats/format_g726.c       |  2 +-
 formats/format_g729.c       |  2 +-
 formats/format_gsm.c        |  2 +-
 formats/format_h263.c       |  2 +-
 formats/format_h264.c       |  2 +-
 formats/format_ilbc.c       |  2 +-
 formats/format_ogg_vorbis.c |  2 +-
 formats/format_pcm.c        |  2 +-
 formats/format_sln.c        |  2 +-
 formats/format_vox.c        |  2 +-
 formats/format_wav.c        |  2 +-
 formats/format_wav_gsm.c    |  2 +-
 include/asterisk/frame.h    | 10 +++++++++-
 14 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/formats/format_g723.c b/formats/format_g723.c
index 594f3d1c0b..4beba0c648 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -76,7 +76,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_G723_1;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != size) {
 		ast_log(LOG_WARNING, "Short read (%d of %d bytes) (%s)!\n", res, size, strerror(errno));
 		return NULL;
diff --git a/formats/format_g726.c b/formats/format_g726.c
index 135e0a8fe2..d72f489919 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -137,7 +137,7 @@ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_G726;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
 	s->fr.samples = 8 * FRAME_TIME;
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
diff --git a/formats/format_g729.c b/formats/format_g729.c
index f2eef83e43..1719e3a5c8 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -62,7 +62,7 @@ static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
 	s->fr.subclass = AST_FORMAT_G729A;
 	s->fr.mallocd = 0;
 	s->fr.samples = G729A_SAMPLES;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res && (res != 10))	/* XXX what for ? */
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index bc91d1f0b2..423088c178 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -67,7 +67,7 @@ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
 
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_GSM;
-	FR_SET_BUF(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
+	AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
 	s->fr.mallocd = 0;
 	if ((res = fread(s->fr.data, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
 		if (res)
diff --git a/formats/format_h263.c b/formats/format_h263.c
index ee455beb3a..c64e001fde 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -88,7 +88,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VIDEO;
 	s->fr.subclass = AST_FORMAT_H263;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_h264.c b/formats/format_h264.c
index 3e358086ea..26db782e5a 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -84,7 +84,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VIDEO;
 	s->fr.subclass = AST_FORMAT_H264;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d of %d) (%s)!\n", res, len, strerror(errno));
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index 2a027cb994..940abf25f5 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -60,7 +60,7 @@ static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_ILBC;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index 2ca0cce34b..ee12e6a8fc 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -436,7 +436,7 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *fs,
 	fs->fr.frametype = AST_FRAME_VOICE;
 	fs->fr.subclass = AST_FORMAT_SLINEAR;
 	fs->fr.mallocd = 0;
-	FR_SET_BUF(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 
 	while (samples_out != SAMPLES_MAX) {
 		float **pcm;
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 493d8afe9d..889e7afc2e 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -95,7 +95,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = s->fmt->format;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 939a121bb9..3e4d2e0c9a 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -54,7 +54,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_SLINEAR;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_vox.c b/formats/format_vox.c
index 5afc1e322d..b1f7e688a2 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -56,7 +56,7 @@ static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_ADPCM;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_wav.c b/formats/format_wav.c
index f56cdae4dd..eb3b2d5ad5 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -369,7 +369,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_SLINEAR;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
 	
 	if ( (res = fread(s->fr.data, 1, s->fr.datalen, s->f)) <= 0 ) {
 		if (res)
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index 85b9902c7a..d2fa1c0ce2 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -379,7 +379,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
 	s->fr.offset = AST_FRIENDLY_OFFSET;
 	s->fr.samples = GSM_SAMPLES;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
 	if (fs->secondhalf) {
 		/* Just return a frame based on the second GSM frame */
 		s->fr.data = (char *)s->fr.data + GSM_FRAME_SIZE;
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 21b5969286..099e20080d 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -111,7 +111,15 @@ struct ast_frame {
 	struct ast_frame *next;			
 };
 
-#define	FR_SET_BUF(fr, _base, _ofs, _datalen)	\
+/*!
+ * Set the various field of a frame to point to a buffer.
+ * Typically you set the base address of the buffer, the offset as
+ * AST_FRIENDLY_OFFSET, and the datalen as the amount of bytes queued.
+ * The remaining things (to be done manually) is set the number of
+ * samples, which cannot be derived from the datalen unless you know
+ * the number of bits per sample.
+ */
+#define	AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)	\
 	{					\
 	(fr)->data = (char *)_base + (_ofs);	\
 	(fr)->offset = (_ofs);			\
-- 
GitLab