aboutsummaryrefslogtreecommitdiffstats
path: root/formats
diff options
context:
space:
mode:
authormvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-22 16:29:54 +0000
committermvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-22 16:29:54 +0000
commitc1210321e7aeb274076b14fc2f622edf442246fa (patch)
treebcbbf4eda53cdb8257bbc7add4616e01e31b1ae2 /formats
parent2d9ba021dd38039616c82a4e317f652abe246ba3 (diff)
- revert change to ast_queue_hangup and create ast_queue_hangup_with_cause
- make data member of the ast_frame struct a named union instead of a void Recently the ast_queue_hangup function got a new parameter, the hangupcause Feedback came in that this is no good and that instead a new function should be created. This I did. The hangupcause was stored in the seqno member of the ast_frame struct. This is not very elegant, and since there's already a data member that one should be used. Problem is, this member was a void *. Now it's a named union so it can hold a pointer, an uint32 and there's a padding in case someone wants to store another type in there in the future. This commit is so massive, because all ast_frame.data uses have to be altered to ast_frame.data.data Thanks russellb and kpfleming for the feedback. (closes issue #12674) Reported by: mvanbaak git-svn-id: http://svn.digium.com/svn/asterisk/trunk@117802 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'formats')
-rw-r--r--formats/format_g723.c4
-rw-r--r--formats/format_g726.c4
-rw-r--r--formats/format_g729.c4
-rw-r--r--formats/format_gsm.c6
-rw-r--r--formats/format_h263.c4
-rw-r--r--formats/format_h264.c4
-rw-r--r--formats/format_ilbc.c4
-rw-r--r--formats/format_jpeg.c4
-rw-r--r--formats/format_pcm.c4
-rw-r--r--formats/format_sln.c4
-rw-r--r--formats/format_sln16.c4
-rw-r--r--formats/format_vox.c4
-rw-r--r--formats/format_wav.c8
-rw-r--r--formats/format_wav_gsm.c10
14 files changed, 34 insertions, 34 deletions
diff --git a/formats/format_g723.c b/formats/format_g723.c
index 6e57b4fa8..7b527da8c 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -64,7 +64,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_G723_1;
s->fr.mallocd = 0;
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) {
+ if ((res = fread(s->fr.data.ptr, 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;
}
@@ -100,7 +100,7 @@ static int g723_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Unable to write size: res=%d (%s)\n", res, strerror(errno));
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
ast_log(LOG_WARNING, "Unable to write frame: res=%d (%s)\n", res, strerror(errno));
return -1;
}
diff --git a/formats/format_g726.c b/formats/format_g726.c
index e27476fed..d54b52d2c 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -123,7 +123,7 @@ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -151,7 +151,7 @@ static int g726_write(struct ast_filestream *s, struct ast_frame *f)
f->datalen, frame_size[fs->rate]);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n",
res, frame_size[fs->rate], strerror(errno));
return -1;
diff --git a/formats/format_g729.c b/formats/format_g729.c
index 8df463d81..cf7e20be7 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -50,7 +50,7 @@ static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
s->fr.mallocd = 0;
s->fr.samples = G729A_SAMPLES;
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 = fread(s->fr.data.ptr, 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));
return NULL;
@@ -74,7 +74,7 @@ static int g729_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 10\n", f->datalen);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/10): %s\n", res, strerror(errno));
return -1;
}
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index d43844e64..3506f563e 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -56,7 +56,7 @@ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_GSM;
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 = fread(s->fr.data.ptr, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -82,7 +82,7 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f)
/* This is in MSGSM format, need to be converted */
int len=0;
while(len < f->datalen) {
- conv65(f->data + len, gsm);
+ conv65(f->data.ptr + len, gsm);
if ((res = fwrite(gsm, 1, 2*GSM_FRAME_SIZE, fs->f)) != 2*GSM_FRAME_SIZE) {
ast_log(LOG_WARNING, "Bad write (%d/66): %s\n", res, strerror(errno));
return -1;
@@ -94,7 +94,7 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 33\n", f->datalen);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/33): %s\n", res, strerror(errno));
return -1;
}
diff --git a/formats/format_h263.c b/formats/format_h263.c
index b0b5cb27d..9b6ac6764 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -83,7 +83,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_H263;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -130,7 +130,7 @@ static int h263_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno));
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
return -1;
}
diff --git a/formats/format_h264.c b/formats/format_h264.c
index 06def313c..fa938a8c6 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -75,7 +75,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_H264;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 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));
return NULL;
@@ -119,7 +119,7 @@ static int h264_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno));
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
return -1;
}
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index aaddc6c38..22ca2edd1 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -48,7 +48,7 @@ static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_ILBC;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -72,7 +72,7 @@ static int ilbc_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 50\n", f->datalen);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/50): %s\n", res, strerror(errno));
return -1;
}
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 4d8d7855d..92117fce1 100644
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -49,7 +49,7 @@ static struct ast_frame *jpeg_read_image(int fd, int len)
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_IMAGE;
fr.subclass = AST_FORMAT_JPEG;
- fr.data = buf;
+ fr.data.ptr = buf;
fr.src = "JPEG Read";
fr.datalen = len;
return ast_frisolate(&fr);
@@ -79,7 +79,7 @@ static int jpeg_write_image(int fd, struct ast_frame *fr)
return -1;
}
if (fr->datalen) {
- res = write(fd, fr->data, fr->datalen);
+ res = write(fd, fr->data.ptr, fr->datalen);
if (res != fr->datalen) {
ast_log(LOG_WARNING, "Only wrote %d of %d bytes: %s\n", res, fr->datalen, strerror(errno));
return -1;
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 118353552..3ecc1c16e 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -83,7 +83,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = s->fmt->format;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -209,7 +209,7 @@ static int pcm_write(struct ast_filestream *fs, struct ast_frame *f)
}
#endif /* REALTIME_WRITE */
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
return -1;
}
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 51f796271..c78a4fdcb 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -42,7 +42,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -63,7 +63,7 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-slinear frame (%d)!\n", f->subclass);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
return -1;
}
diff --git a/formats/format_sln16.c b/formats/format_sln16.c
index 50349f2dd..78260f337 100644
--- a/formats/format_sln16.c
+++ b/formats/format_sln16.c
@@ -43,7 +43,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_SLINEAR16;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -65,7 +65,7 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%d)!\n", f->subclass);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
return -1;
}
diff --git a/formats/format_vox.c b/formats/format_vox.c
index f22b4881a..a9aef6070 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -44,7 +44,7 @@ static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_ADPCM;
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -65,7 +65,7 @@ static int vox_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%d)!\n", f->subclass);
return -1;
}
- if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
return -1;
}
diff --git a/formats/format_wav.c b/formats/format_wav.c
index bbeb20baf..5cf39ce99 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -362,7 +362,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
s->fr.mallocd = 0;
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 = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) <= 0 ) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
return NULL;
@@ -370,7 +370,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
s->fr.datalen = res;
s->fr.samples = samples = res / 2;
- tmp = (short *)(s->fr.data);
+ tmp = (short *)(s->fr.data.ptr);
#if __BYTE_ORDER == __BIG_ENDIAN
/* file format is little endian so we need to swap */
for( x = 0; x < samples; x++)
@@ -407,14 +407,14 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Data length is too long\n");
return -1;
}
- tmpi = f->data;
+ tmpi = f->data.ptr;
for (x=0; x < f->datalen/2; x++)
tmp[x] = (tmpi[x] << 8) | ((tmpi[x] & 0xff00) >> 8);
if ((res = fwrite(tmp, 1, f->datalen, fs->f)) != f->datalen ) {
#else
/* just write */
- if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen ) {
+ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen ) {
#endif
ast_log(LOG_WARNING, "Bad write (%d): %s\n", res, strerror(errno));
return -1;
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index aa576195c..4c3694cda 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -402,7 +402,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
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;
+ s->fr.data.ptr = (char *)s->fr.data.ptr + GSM_FRAME_SIZE;
s->fr.offset += GSM_FRAME_SIZE;
} else {
/* read and convert */
@@ -415,7 +415,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
return NULL;
}
/* Convert from MS format to two real GSM frames */
- conv65(msdata, s->fr.data);
+ conv65(msdata, s->fr.data.ptr);
}
fs->secondhalf = !fs->secondhalf;
*whennext = GSM_SAMPLES;
@@ -449,16 +449,16 @@ static int wav_write(struct ast_filestream *s, struct ast_frame *f)
int res;
unsigned char *src, msdata[MSGSM_FRAME_SIZE];
if (fs->secondhalf) { /* second half of raw gsm to be converted */
- memcpy(s->buf + GSM_FRAME_SIZE, f->data + len, GSM_FRAME_SIZE);
+ memcpy(s->buf + GSM_FRAME_SIZE, f->data.ptr + len, GSM_FRAME_SIZE);
conv66((unsigned char *) s->buf, msdata);
src = msdata;
fs->secondhalf = 0;
} else if (size == GSM_FRAME_SIZE) { /* first half of raw gsm */
- memcpy(s->buf, f->data + len, GSM_FRAME_SIZE);
+ memcpy(s->buf, f->data.ptr + len, GSM_FRAME_SIZE);
src = NULL; /* nothing to write */
fs->secondhalf = 1;
} else { /* raw msgsm data */
- src = f->data + len;
+ src = f->data.ptr + len;
}
if (src && (res = fwrite(src, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) {
ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno));