Merge "formats: Restore previous fread() behavior"
This commit is contained in:
commit
3025b47e8f
15 changed files with 87 additions and 161 deletions
|
@ -40,20 +40,15 @@
|
||||||
|
|
||||||
static struct ast_frame *g719read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *g719read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
/* Send a frame from the file to the appropriate channel */
|
|
||||||
|
|
||||||
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
unsigned short size;
|
unsigned short size;
|
||||||
int res;
|
size_t res;
|
||||||
int delay;
|
int delay;
|
||||||
/* Read the delay for the next packet, and schedule again if necessary */
|
/* Read the delay for the next packet, and schedule again if necessary */
|
||||||
/* XXX is this ignored ? */
|
/* XXX is this ignored ? */
|
||||||
|
@ -65,15 +65,10 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
|
||||||
/* Read the data into the buffer */
|
/* Read the data into the buffer */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,22 +117,17 @@ static int g726_16_rewrite(struct ast_filestream *s, const char *comment)
|
||||||
|
|
||||||
static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
struct g726_desc *fs = (struct g726_desc *)s->_private;
|
struct g726_desc *fs = (struct g726_desc *)s->_private;
|
||||||
|
|
||||||
/* Send a frame from the file to the appropriate channel */
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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;
|
s->fr.samples = 8 * FRAME_TIME;
|
||||||
if ((res = fread(s->fr.data.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,20 +46,16 @@
|
||||||
|
|
||||||
static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
|
|
||||||
/* Send a frame from the file to the appropriate channel */
|
/* Send a frame from the file to the appropriate channel */
|
||||||
s->fr.samples = G729A_SAMPLES;
|
s->fr.samples = G729A_SAMPLES;
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
if (res && res != 10) /* XXX what for ? */ {
|
||||||
if (res) {
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
"(expected %d bytes, read %d)\n",
|
strerror(errno));
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,19 +53,14 @@ static const char gsm_silence[] = /* 33 */
|
||||||
|
|
||||||
static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
|
|
||||||
AST_FRAME_SET_BUFFER(&(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 ((res = fread(s->fr.data.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), GSM_FRAME_SIZE, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), GSM_FRAME_SIZE, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ static int h263_open(struct ast_filestream *s)
|
||||||
|
|
||||||
static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
uint32_t mark;
|
uint32_t mark;
|
||||||
unsigned short len;
|
unsigned short len;
|
||||||
unsigned int ts;
|
unsigned int ts;
|
||||||
|
@ -85,15 +85,10 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
|
||||||
}
|
}
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ static int h264_open(struct ast_filestream *s)
|
||||||
|
|
||||||
static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
int mark = 0;
|
int mark = 0;
|
||||||
unsigned short len;
|
unsigned short len;
|
||||||
unsigned int ts;
|
unsigned int ts;
|
||||||
|
@ -77,15 +77,10 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
|
||||||
}
|
}
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,19 +45,15 @@
|
||||||
|
|
||||||
static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
|
|
||||||
/* Send a frame from the file to the appropriate channel */
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,21 +78,15 @@ static int pcma_rewrite(struct ast_filestream *s, const char *comment)
|
||||||
|
|
||||||
static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
|
|
||||||
/* Send a frame from the file to the appropriate channel */
|
/* Send a frame from the file to the appropriate channel */
|
||||||
|
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
|
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
|
||||||
if (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,20 +40,15 @@
|
||||||
|
|
||||||
static struct ast_frame *siren14read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *siren14read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
/* Send a frame from the file to the appropriate channel */
|
|
||||||
|
|
||||||
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,20 +40,15 @@
|
||||||
|
|
||||||
static struct ast_frame *siren7read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *siren7read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
/* Send a frame from the file to the appropriate channel */
|
|
||||||
|
|
||||||
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 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 (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,20 +34,15 @@
|
||||||
|
|
||||||
static struct ast_frame *generic_read(struct ast_filestream *s, int *whennext, unsigned int buf_size)
|
static struct ast_frame *generic_read(struct ast_filestream *s, int *whennext, unsigned int buf_size)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
/* Send a frame from the file to the appropriate channel */
|
|
||||||
|
|
||||||
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
|
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
|
||||||
if (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,20 +40,15 @@
|
||||||
|
|
||||||
static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
|
|
||||||
/* Send a frame from the file to the appropriate channel */
|
/* Send a frame from the file to the appropriate channel */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
|
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
|
||||||
if (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ static void wav_close(struct ast_filestream *s)
|
||||||
|
|
||||||
static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
|
static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
|
||||||
{
|
{
|
||||||
int res;
|
size_t res;
|
||||||
int samples; /* actual samples read */
|
int samples; /* actual samples read */
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
int x;
|
int x;
|
||||||
|
@ -391,16 +391,11 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
|
||||||
/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
|
/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
|
||||||
AST_FRAME_SET_BUFFER(&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.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
|
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) == 0) {
|
||||||
if (feof(s->f)) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
"(expected %d bytes, read %d)\n",
|
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
|
||||||
ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
|
strerror(errno));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,18 +419,13 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
|
||||||
} else {
|
} else {
|
||||||
/* read and convert */
|
/* read and convert */
|
||||||
unsigned char msdata[MSGSM_FRAME_SIZE];
|
unsigned char msdata[MSGSM_FRAME_SIZE];
|
||||||
int res;
|
size_t res;
|
||||||
|
|
||||||
if ((res = fread(msdata, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) {
|
if ((res = fread(msdata, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) {
|
||||||
if (feof(s->f)) {
|
if (res && res != 1) {
|
||||||
if (res) {
|
ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
|
||||||
ast_debug(3, "Incomplete frame data at end of %s file "
|
ast_format_get_name(s->fr.subclass.format), MSGSM_FRAME_SIZE, res,
|
||||||
"(expected %d bytes, read %d)\n",
|
strerror(errno));
|
||||||
ast_format_get_name(s->fr.subclass.format), MSGSM_FRAME_SIZE, res);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
|
|
||||||
ast_format_get_name(s->fr.subclass.format), strerror(errno));
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue